From 10de2a3c8b8e2e592e9a322f50ae0d692505c9b9 Mon Sep 17 00:00:00 2001 From: Hibryda Date: Wed, 18 Mar 2026 04:11:31 +0100 Subject: [PATCH] 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. --- tests/e2e/wdio.conf.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/e2e/wdio.conf.js b/tests/e2e/wdio.conf.js index 395d34a..7448ca4 100644 --- a/tests/e2e/wdio.conf.js +++ b/tests/e2e/wdio.conf.js @@ -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) {