fix(e2e): detect devUrl port conflict before launching tests

Debug binary has devUrl (localhost:9700) baked in via cfg(debug_assertions).
If another app (Docker, Nuxt, etc.) serves on that port, the Tauri WebView
loads the WRONG frontend. onPrepare now fails fast with a clear message
if port 9700 is occupied, preventing false test results against wrong app.
This commit is contained in:
Hibryda 2026-03-18 04:11:31 +01:00
parent c73a2e1caf
commit 10de2a3c8b

View file

@ -112,6 +112,24 @@ export const config = {
}
} catch { /* no process on port — good */ }
// CRITICAL: The debug binary has devUrl (localhost:9700) baked in.
// If another app (e.g., BridgeCoach) is serving on that port, the Tauri
// WebView loads the WRONG frontend. Fail fast if port 9700 is in use.
const DEV_URL_PORT = 9700;
try {
const devPids = execSync(`lsof -ti:${DEV_URL_PORT} 2>/dev/null`, { encoding: 'utf8' }).trim();
if (devPids) {
throw new Error(
`Port ${DEV_URL_PORT} (Tauri devUrl) is in use by another process (PIDs: ${devPids}). ` +
`The debug binary will load that app instead of Agent Orchestrator frontend. ` +
`Either stop the process on port ${DEV_URL_PORT}, or use a release build.`
);
}
} catch (e) {
if (e.message.includes('Port 9700')) throw e;
// lsof returned non-zero = port is free, good
}
// Verify binary exists
if (!existsSync(tauriBinary)) {
if (process.env.SKIP_BUILD) {