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); }); });