From 352ff617da399045a71950ab19af99df84f614a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Sat, 22 Aug 2026 10:42:32 +0200 Subject: [PATCH] Stop the switched-payload spec failing on its own reload The scoped-sharing spec routes `/api/auth/me`, and the account switch it drives ends in a full reload. The reload cancels whatever call is in flight, Playwright marks the route handled, and the handler's `fulfill` then lands on it with "Route is already handled!". With `failOnFlakyTests` on CI that turns the whole shard red over a teardown race rather than over anything the test is checking. Same guard the record-session-fence spec and this file's own accessibility sibling already use. The `fetch` is guarded too, because a request cancelled mid-flight rejects there rather than at the fulfill, and the earlier of the two is the one that decides which error the run reports. --- e2e/v137-sharing-managed-profiles.spec.ts | 31 ++++++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/e2e/v137-sharing-managed-profiles.spec.ts b/e2e/v137-sharing-managed-profiles.spec.ts index b170c49fe..7799d023f 100644 --- a/e2e/v137-sharing-managed-profiles.spec.ts +++ b/e2e/v137-sharing-managed-profiles.spec.ts @@ -291,15 +291,32 @@ test.describe.serial("scoped sharing browser journeys", () => { let corruptAuthPayload = true; await page.route("**/api/auth/me", async (route) => { - const response = await route.fetch(); - if (!corruptAuthPayload) { - await route.fulfill({ response }); + // The switch this test drives ends in a full reload, and the reload + // cancels whatever `/api/auth/me` call is in flight. Playwright then + // considers the route handled, and the `fulfill` below lands on it with + // "Route is already handled!" — a failure of the teardown, not of the + // thing under test, and one that turns the whole shard red under + // `failOnFlakyTests`. + // + // Same guard as `v137-record-session-fence.spec.ts` and the a11y sibling + // of this file. The fetch is guarded too: a request cancelled mid-flight + // rejects there rather than at the fulfill. + let response; + try { + response = await route.fetch(); + } catch { return; } - await route.fulfill({ - response, - json: withDivergentActiveAccountAccess(await response.json()), - }); + if (!corruptAuthPayload) { + await route.fulfill({ response }).catch(() => {}); + return; + } + await route + .fulfill({ + response, + json: withDivergentActiveAccountAccess(await response.json()), + }) + .catch(() => {}); }); const ownerOnlyReads: string[] = [];