fix(e2e): wait for post-login redirect before forcing navigation (#341)

Removing the analytics-consent PUT (#340) also removed the async HTTP
round-trip that incidentally let the app's own post-login redirect
(/login -> /) commit before the explicit page.goto("/"). Without it,
page.goto raced the in-flight client-side redirect and aborted with
'Navigation to / is interrupted by another navigation to /', failing the
auth setup projects. Desktop smoke passed on timing luck; mobile
emulation is slower and lost the race.

Wait for the app's redirect to settle (waitForURL) before the explicit
goto so they no longer race. Platform-timing-independent.
This commit is contained in:
SnapOtter
2026-06-24 14:45:37 +08:00
committed by GitHub
parent 6917a8b0c7
commit 5b75d813b8
2 changed files with 8 additions and 5 deletions
+4 -4
View File
@@ -19,11 +19,11 @@ setup("authenticate", async ({ page }) => {
timeout: 15_000,
});
// Navigate to "/" and let any client-side redirect settle
// Use waitUntil: "domcontentloaded" to avoid racing with client-side redirects
await page.goto("/", { waitUntil: "domcontentloaded" });
// Wait for the URL to settle (app may redirect through auth guards)
// After login the app redirects to "/" on its own. Wait for that redirect to
// settle before forcing navigation, otherwise page.goto races the in-flight
// client-side redirect and aborts ("interrupted by another navigation").
await page.waitForURL((url) => url.pathname === "/", { timeout: 30_000 }).catch(() => {});
await page.goto("/", { waitUntil: "domcontentloaded" });
await page.waitForLoadState("load");
// Fail fast on a misconfigured/stale e2e server. A correctly-configured e2e
+4 -1
View File
@@ -18,8 +18,11 @@ setup("authenticate for QA", async ({ page }) => {
timeout: 15_000,
});
await page.goto("/", { waitUntil: "domcontentloaded" });
// After login the app redirects to "/" on its own. Wait for that redirect to
// settle before forcing navigation, otherwise page.goto races the in-flight
// client-side redirect and aborts ("interrupted by another navigation").
await page.waitForURL((url) => url.pathname === "/", { timeout: 15_000 }).catch(() => {});
await page.goto("/", { waitUntil: "domcontentloaded" });
await page.waitForLoadState("load");
await page.context().storageState({ path: authFile });