gui tests: checkin-account waits for the wheel's scroll to stop, not 100ms

After 3eb5aa2ad (the window's footer takes no room) the WebKit 420px zh
and zh-TW runs of "each WorkBuddy account's check-in on its own" went red
on Linux: "the switch moved the page", 983 against 973/976. The page
hadn't moved for the click: wheelTo waited a fixed 100ms after each
wheel, WebKit's scroll was still easing in, and the test took the
position mid-scroll; it reached the end (983, scrollHeight 1777 less 794)
after. With the 28px footer the wheel had always landed at the end
already (1011 of 1011 at the parent), which hid it.

wheelTo now waits until no box has scrolled for ten frames before it
measures, and once more before it returns.

Run (wsl-run, magpie-desktop): checkin-account.test.cjs 40 of 40, three
times. Geometry before and after the click logged at the parent and at
3eb5aa2ad to find it.
Not run: mote (browser launches hang there, #4125).
This commit is contained in:
yetone
2026-10-31 07:53:13 +08:00
parent 03d21ab8e1
commit 11fc687c0e
+12 -1
View File
@@ -63,15 +63,26 @@ const words = {
const scrolls = (page) => page.evaluate(() => [scrollY, ...[...document.querySelectorAll("*")].filter((e) => e.scrollTop).map((e) => e.scrollTop)].join(","));
// still: until no box has scrolled for ten frames, as a wheel's scroll in
// WebKit is still easing in after a fixed wait, and the page went on
// moving under the click that was to leave it where it was
const still = (page) => page.evaluate(() => new Promise((done) => {
let last = "", same = 0;
const at = () => [scrollY, ...[...document.querySelectorAll("*")].map((e) => e.scrollTop)].join(",");
const f = () => { const now = at(); same = now === last ? same + 1 : 0; last = now; if (same >= 10) done(); else requestAnimationFrame(f); };
requestAnimationFrame(f);
}));
// wheelTo scrolls the page until loc is above the window's foot
async function wheelTo(page, loc, x) {
await page.mouse.move(x, 400);
for (let i = 0; i < 15; i++) {
await still(page);
const r = await loc.boundingBox(), foot = await page.locator("footer.foot").boundingBox();
if (r && foot && r.y + r.height < foot.y - 8) return;
await page.mouse.wheel(0, 200);
await page.waitForTimeout(100);
}
await still(page);
}
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {