From 2e5166498d62cb0e6027a3c6d40a6fdf83669e00 Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Sun, 15 Nov 2026 21:19:03 +0000 Subject: [PATCH] test(ui-react): cut B's recovery read short in the parallel-sessions case (#3414) Under load, B's recovery read after its failure was sometimes still in flight when the 390-phone case fast-forwarded the page clock 2:05. The fake clock also runs the read's `AbortSignal.timeout`, so the read aborted, B went `can't check`, and the next read's same failure was announced a second time. #3980 fixed the announcer; this makes the condition a step of the case instead of something only load produces. B's recovery reads are held from just before its failure until the fast-forward has turned B `can't check`, then answered, and the case waits for B to read `failed` again. Every assertion and deadline is unchanged. With the #3980 guard removed the case now fails at "a ticking age announces nothing" with the duplicate announcement. Refs #3414 Co-Authored-By: Claude Opus 5.5 --- .../tests/parallel-sessions-runtime.test.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/ui-react/tests/parallel-sessions-runtime.test.ts b/packages/ui-react/tests/parallel-sessions-runtime.test.ts index 98338b81a3..2aa39a1423 100644 --- a/packages/ui-react/tests/parallel-sessions-runtime.test.ts +++ b/packages/ui-react/tests/parallel-sessions-runtime.test.ts @@ -721,14 +721,28 @@ describe.skipIf(!executablePath)("mounted parallel sessions", () => { // labelled from the session list, so wait until the list has read B's // host title; before that the label falls back to B's first prompt. await until(a.page, `p.listedTitle(${JSON.stringify(B)}) === ${JSON.stringify(titles.get(B))}`); + // B's recovery reads from here on answer only after the clock moves, + // as a slow read under load does (#3414): the fake clock also runs + // the read's timeout, so the fast-forward below cuts B's read short. + let answerB!: () => void; + const slowB = new Promise((resolve) => { answerB = resolve; }); + const readsB = `**/api/sessions/${B}/recovery`; + await a.context.route(readsB, async (route) => { await slowB; await route.continue().catch(() => {}); }); await release(pb, "fail"); await until(a.page, `${state(B)}?.state === "failed"`); await until(a.page, "p.spoken().length >= 1"); await a.page.waitForTimeout(300); expect(await probe(a.page, (p) => p.spoken()), "B's failure is spoken once").toEqual([`${titles.get(B)} failed.`]); + await until(a.page, `p.recoveryReads()[${JSON.stringify(B)}]?.complete === false`); - // Two minutes pass: A's age is redrawn, and nothing is announced for it. + // Two minutes pass: A's age is redrawn, and nothing is announced for + // it. B's cut-short read makes B "can't check" until the next read + // answers it failed again: the same failure, which is not a change. await a.page.clock.fastForward("02:05"); + await until(a.page, `${state(B)}?.state === "cant_check"`); + answerB(); + await a.context.unroute(readsB); + await until(a.page, `${state(B)}?.state === "failed"`); const age = trackerControl(run, a.page, A).first(); await a.page.waitForFunction((el) => el?.textContent?.includes("running ยท 2m") ?? false, await age.elementHandle(), { timeout: 10_000 }); expect(await age.getAttribute("aria-label")).toBe(`${titles.get(A)}, running, 2m. Open session.`);