From d6066400758a9a9a2516aa6d22be8b88c4b500da Mon Sep 17 00:00:00 2001 From: Connor Burgess Date: Sat, 5 Dec 2026 16:25:02 +0700 Subject: [PATCH] test(e2e): three assertions that fail on a busy runner hold on what the test is about split.spec.ts:662 compared window.scrollY after the covering panel closed with the number it had before it opened. Under the covering panel the pointer is off the list, so the board is not held, and a demo session that adds a card scrolls the page on by its height. The test now asks that a card on the board before and after the close is where it was in the window. mobile.spec.ts:1050 asked for a height of at least 44 and got 43.999969482421875 on the CI runner. It now allows for float rounding. pool-surfaces.spec.ts fromFirstTurn asked for no switch row whenever "Older turns" was shown. For a while the newest page both holds the switch and has older turns behind it. The helper now only loads them. Signed-off-by: Connor Burgess --- test/e2e/mobile.spec.ts | 4 +++- test/e2e/pool-surfaces.spec.ts | 5 +++-- test/e2e/split.spec.ts | 26 +++++++++++++++++++++++++- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/test/e2e/mobile.spec.ts b/test/e2e/mobile.spec.ts index 7d12c7ff..eeb29060 100644 --- a/test/e2e/mobile.spec.ts +++ b/test/e2e/mobile.spec.ts @@ -1065,7 +1065,9 @@ test.describe("phone: new session", () => { const look = await tinted(discard); expect(look.color).toBe(look.tint); expect(look.weight).toBeLessThan(600); - expect((await discard.boundingBox())!.height).toBeGreaterThanOrEqual(44); + // 44 CSS px, less the float rounding of a box measured at 3 device px to the px + // (43.99997 on the CI runner). + expect((await discard.boundingBox())!.height).toBeGreaterThanOrEqual(44 - 0.01); // Cancel is no discard: the sheet closes, and opens again with the words. await page.locator("[data-ns-cancel]").click(); await expect(sheet).toHaveCount(0); diff --git a/test/e2e/pool-surfaces.spec.ts b/test/e2e/pool-surfaces.spec.ts index 42ec344c..0fabff91 100644 --- a/test/e2e/pool-surfaces.spec.ts +++ b/test/e2e/pool-surfaces.spec.ts @@ -33,11 +33,12 @@ async function poolSession(page: Page): Promise<{ harness: string; id: string }> /** The session from its first turn, where the switch fell. The pooled session takes a turn * every few minutes and never ends, so late in the run its newest page no longer reaches - * back to that turn: until "Older turns" brings it, no turn on the page holds the switch. */ + * back to that turn, and "Older turns" brings it. Nothing is asked of the page before + * that: for a while the newest page still holds the switch and already has older turns + * behind it. */ async function fromFirstTurn(page: Page): Promise { await expect(page.locator("li.turn").first()).toBeVisible(); const older = page.locator("li.older button"); - if (await older.count()) await expect(page.locator("[data-swap]")).toHaveCount(0); while (await older.count()) { await older.click(); // A page of 200 events is drawn into the chat; on a busy runner that takes a while. diff --git a/test/e2e/split.spec.ts b/test/e2e/split.spec.ts index 8ea347a8..6d7fba06 100644 --- a/test/e2e/split.spec.ts +++ b/test/e2e/split.spec.ts @@ -697,9 +697,33 @@ test.describe("split panel", () => { expect(state.mainOverflowY).toBe("hidden"); expect(state.windowScrollY).toBe(0); + // Under the covering panel the pointer is off the list, so the board is not held: the + // demo's sessions add and move cards, and the page scrolls on by their height to keep + // what is on screen in place. So window.scrollY need not come back to the number it + // had. What must hold is that the page did not move under the reader: a card that is + // on the board before and after the close is where it was in the window. + const tops = () => + page.evaluate(() => + Object.fromEntries( + [...document.querySelectorAll("article.card a.card-link")].map((a) => [ + a.getAttribute("href"), + a.getBoundingClientRect().top, + ]), + ), + ); + const before = await tops(); await page.keyboard.press("Escape"); await expect(panel(page)).not.toHaveClass(/panel--open/); - await expect.poll(() => page.evaluate((want) => Math.abs(window.scrollY - want), beforeY)).toBeLessThanOrEqual(2); + await expect + .poll(async () => { + const after = await tops(); + const moved = Object.keys(before) + .filter((k) => k in after) + .map((k) => Math.abs(after[k]! - before[k]!)); + return Math.min(...moved); + }) + .toBeLessThanOrEqual(2); + expect(await page.evaluate(() => window.scrollY)).toBeGreaterThan(0); }); });