diff --git a/internal/gui/tests/reader.cjs b/internal/gui/tests/reader.cjs index 72364a45..a747d5a8 100644 --- a/internal/gui/tests/reader.cjs +++ b/internal/gui/tests/reader.cjs @@ -1,5 +1,10 @@ // The app deliberately undoes unsolicited scrollIntoView (including Playwright's // automatic scroll). Bring a control into sight with real wheel input first. +// Wholly in sight: one cut off by a fraction of a pixel at the view's foot +// was scrolled the rest of the way by Playwright's click itself, before the +// app saw the click, and the page moved 1px under it (860 to 861 on the +// Usage page's Fetch from archive, once the archive switch in its header +// had moved the rows 4px down). async function inView(page, locator) { await locator.waitFor({state:"visible"}); if (await locator.evaluate(e => !e.closest("#view-usage"))) return; @@ -9,11 +14,12 @@ async function inView(page, locator) { for (let i = 0; i < 80; i++) { const b = await locator.boundingBox(); if (!b) { await page.waitForTimeout(40); continue; } - if (b.y >= v.y - 1 && b.y + b.height <= v.y + v.height + 1) { + // one taller than the view: its top in sight + if (b.y >= v.y && (b.y + b.height <= v.y + v.height || (b.height > v.height && b.y < v.y + v.height))) { await page.waitForTimeout(300); return; } - const delta = b.y < v.y - 1 ? -20 : 20; + const delta = b.y < v.y ? -20 : 20; await page.mouse.wheel(0, delta); await page.waitForTimeout(40); } diff --git a/internal/gui/tests/request-archive-usage.test.cjs b/internal/gui/tests/request-archive-usage.test.cjs index 5435d1c5..372c00e5 100644 --- a/internal/gui/tests/request-archive-usage.test.cjs +++ b/internal/gui/tests/request-archive-usage.test.cjs @@ -117,9 +117,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", const at = await top(); await loc.click(); await p.waitForTimeout(200); - // magpie web's page settles a row's first opening up to a pixel - // off, on main before #447 as well - assert(Math.abs((await top()) - at) <= (web ? 1 : 0), `a click moved the page: ${at} to ${await top()}`); + assert.equal(await top(), at, "a click moved the page"); }; const wait = async (n) => { for (let i = 0; i < 60 && seen.length < n; i++) await p.waitForTimeout(50); };