diff --git a/tests/mobile/cdp.mjs b/tests/mobile/cdp.mjs index c9cb0ec..913cfc5 100644 --- a/tests/mobile/cdp.mjs +++ b/tests/mobile/cdp.mjs @@ -97,12 +97,13 @@ export async function attachPhone(port) { /* The devtools socket is registered by the WebView, not by the process, so there is a window after a launch where the app is up, focused and has a pid, and the socket does not exist yet. On a loaded machine that window - has been as long as ten seconds — a walk that attached once and gave up - read it as "is SoulStream on screen?" when it plainly was. Try for a - while, re-reading the pid each time in case the app restarted under us. */ + has been longer than CDP.attach’s own forty seconds of patience — and the walk + then reported "is SoulStream on screen?" about an app that plainly was. Each + attempt below already waits 40s; three of them is the ceiling, re-reading the + pid each time in case the app restarted underneath us. */ let pid = ""; let last = null; - for (let attempt = 0; attempt < 6; attempt++) { + for (let attempt = 0; attempt < 3; attempt++) { pid = adb("shell", "pidof", "com.soulstream.app").toString().trim(); if (pid) { adb("forward", "--remove-all"); diff --git a/tests/mobile/smoke.mjs b/tests/mobile/smoke.mjs index 4937ac6..0c0a69c 100644 --- a/tests/mobile/smoke.mjs +++ b/tests/mobile/smoke.mjs @@ -2290,6 +2290,23 @@ async function main() { steps = PHONE_STEPS; expect = PHONE_EXPECT; prefix = "phone-"; still = phoneStill; console.log("attached to the phone's WebView (pid " + pid + ")"); + /* A walk follows a fresh install, so the app is always cold here: the + shell mounts, the library loads, Soulseek logs in and the share + index is built. Attaching only proves the WebView answers — it says + nothing about the app being up. Starting anyway means the first + steps run against a half-mounted page and get reported as broken + features, which is exactly how an hour went once. Wait for the + handle the walk actually drives. */ + const upFrom = Date.now(); + let up = false; + while (Date.now() - upFrom < 90_000) { + try { + if (await cdp.evaluate(`!!(window.__ss && document.querySelector('.app'))`) === true) { up = true; break; } + } catch { /* a page mid-navigation answers nothing; ask again */ } + await sleep(1000); + } + if (!up) throw new Error("the app never came up on the phone (no __ss and no .app after 90s)"); + console.log("the app is up (" + ((Date.now() - upFrom) / 1000).toFixed(1) + "s after attaching)"); } else { if (!CHROME) throw new Error("Chrome not found"); console.log("building dist-smoke/ …");