* 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.
50 lines
1.4 KiB
TypeScript
50 lines
1.4 KiB
TypeScript
import { homedir } from 'node:os'
|
|
import { dirname, join } from 'node:path'
|
|
import { fileURLToPath } from 'node:url'
|
|
|
|
import type { TauriCapabilities } from '@wdio/tauri-service'
|
|
|
|
const root = dirname(fileURLToPath(import.meta.url))
|
|
const binaryName = process.platform === 'win32' ? 'OpenPencil.exe' : 'OpenPencil'
|
|
const appBinary = join(root, 'desktop', 'target', 'debug', binaryName)
|
|
|
|
const capability: TauriCapabilities = {
|
|
browserName: 'tauri',
|
|
'tauri:options': { application: appBinary }
|
|
}
|
|
|
|
// Keep the spawned MCP server's discovery file out of the user's application
|
|
// support directory. It stays inside the home directory because the app only
|
|
// accepts a server-reported path within it.
|
|
process.env.OPENPENCIL_MCP_DISCOVERY_PATH = join(
|
|
homedir(),
|
|
'.openpencil-native-test',
|
|
'mcp.json'
|
|
)
|
|
|
|
export const config: WebdriverIO.Config = {
|
|
runner: 'local',
|
|
tsConfigPath: join(root, 'tests', 'e2e', 'native', 'tsconfig.json'),
|
|
specs: [join(root, 'tests', 'e2e', 'native', '**', '*.spec.ts')],
|
|
maxInstances: 1,
|
|
maxInstancesPerCapability: 1,
|
|
capabilities: [capability],
|
|
services: [
|
|
[
|
|
'@wdio/tauri-service',
|
|
{
|
|
appBinaryPath: appBinary,
|
|
driverProvider: 'embedded',
|
|
startTimeout: 120_000
|
|
}
|
|
]
|
|
],
|
|
framework: 'mocha',
|
|
reporters: ['spec'],
|
|
logLevel: 'warn',
|
|
waitforTimeout: 20_000,
|
|
connectionRetryTimeout: 120_000,
|
|
connectionRetryCount: 1,
|
|
mochaOpts: { ui: 'bdd', timeout: 60_000 }
|
|
}
|