* test(native): cover the desktop MCP server lifecycle `tests/e2e/native/**` had no MCP coverage, so nothing verified that the real Tauri shell finds and spawns a server. Browser E2E cannot: the spawn path short-circuits to the Vite-managed server in development. Add a native spec that asserts what the app actually resolved: a missing install reports its own reason, a resolvable binary either becomes healthy with a discovery file and answering port or is refused with a version explanation, and hiding the resolved binary then reports the missing install without relaunching. Also generate the desktop icons in `build:native-test`, since they are ignored and the build failed on a clean checkout, and let the snapping spec select its own section instead of assuming the dialog state. * test(native): resolve the home directory portably process.env.HOME is unset on Windows, which put the discovery override outside the home directory. The app accepts a server-reported discovery path only inside it, so it fell back to its own path and could not read the test server's token.
60 lines
2.5 KiB
TypeScript
60 lines
2.5 KiB
TypeScript
import { strict as assert } from 'node:assert'
|
|
|
|
import { invokeNative } from '#tests/helpers/tauri/invoke'
|
|
|
|
function settingsOpen(): Promise<boolean> {
|
|
return browser.execute(() =>
|
|
Boolean(document.querySelector('[data-test-id="app-settings-dialog"]'))
|
|
)
|
|
}
|
|
|
|
describe('native preferences', () => {
|
|
it('opens Settings with the platform shortcut while an input is focused', async () => {
|
|
await browser.waitUntil(
|
|
async () => browser.execute(() => Boolean(window.openPencil?.getStore?.())),
|
|
{ timeout: 30_000, timeoutMsg: 'OpenPencil editor did not initialize' }
|
|
)
|
|
await browser.execute(() => {
|
|
const input = document.createElement('input')
|
|
input.setAttribute('data-test-id', 'native-settings-shortcut-input')
|
|
document.body.append(input)
|
|
})
|
|
const input = await $('[data-test-id="native-settings-shortcut-input"]')
|
|
await input.click()
|
|
await browser.keys([process.platform === 'darwin' ? 'Meta' : 'Control', ','])
|
|
await browser.waitUntil(settingsOpen, {
|
|
timeout: 10_000,
|
|
timeoutMsg: 'Native settings shortcut did not open Settings'
|
|
})
|
|
|
|
assert.equal(await settingsOpen(), true)
|
|
})
|
|
|
|
it('keeps native snapping checkmarks synchronized with preferences', async () => {
|
|
await browser.waitUntil(
|
|
async () => browser.execute(() => Boolean(window.openPencil?.getStore?.())),
|
|
{ timeout: 30_000, timeoutMsg: 'OpenPencil editor did not initialize' }
|
|
)
|
|
const initial = await invokeNative<boolean>('native_menu_checked', { id: 'snap-objects' })
|
|
assert.equal(initial, true)
|
|
|
|
await browser.keys([process.platform === 'darwin' ? 'Meta' : 'Control', ','])
|
|
await browser.waitUntil(settingsOpen, {
|
|
timeout: 10_000,
|
|
timeoutMsg: 'Settings did not open for the snapping checkmark test'
|
|
})
|
|
// Spec files share one app process, so select the section this test needs
|
|
// instead of assuming the dialog opened on it.
|
|
await (await $('[data-test-id="settings-section-general"]')).click()
|
|
await (await $('[data-test-id="settings-snap-objects"]')).waitForDisplayed({ timeout: 10_000 })
|
|
await (await $('[data-test-id="settings-snap-objects"]')).click()
|
|
await browser.waitUntil(
|
|
async () =>
|
|
(await invokeNative<boolean>('native_menu_checked', { id: 'snap-objects' })) === false,
|
|
{ timeout: 5_000, timeoutMsg: 'Native snapping checkmark did not follow the preference' }
|
|
)
|
|
const updated = await invokeNative<boolean>('native_menu_checked', { id: 'snap-objects' })
|
|
assert.equal(updated, false)
|
|
})
|
|
})
|