mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 12:32:43 +00:00
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.
This commit is contained in:
1 parent
d5dde3eb1c
commit
352ff617da
1 file changed
+24
-7
@@ -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[] = [];
|
||||
|
||||
Reference in new issue
Block a user