From cfd2ee7f7ca3c26d290413470a2e41cae3262b28 Mon Sep 17 00:00:00 2001 From: yetone Date: Mon, 12 Oct 2026 01:06:43 +0800 Subject: [PATCH] gui tests: routing-side-calls measures a row once Routing's groups are in and the row has stayed put (#1640) "a title and magpie's web search say what they were" failed with "picking the request moved the row" in Chromium, now and then alone and often under load. The row hadn't moved because of the click: it was measured before the page was done. Recorded frame by frame, the day's list draws at one frame and the part above it grows on a later one (rt 271 -> 428px), while the click guard scrolls to hold the day that was clicked (scrollTop 0 -> 176), so the rows move 444 -> 424 before any row is clicked. The test measured "was" between the two. Holding Routing's groups answer (/api/groups) 300, 600 or 1000ms makes the old test fail in most runs (7 of 9 runs red); that is what landed late. The test now waits for the first groups answer and for the row to stay put for 10 frames before measuring. Nothing a reader sees changes: the clicked day stays where it was, as the click guard means it to. Run: with groups held 600 and 2500ms the fixed test is green every run (3 runs each); 20/20 green in WebKit and 20/20 in Chromium. --- internal/gui/tests/routing-side-calls.test.cjs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/internal/gui/tests/routing-side-calls.test.cjs b/internal/gui/tests/routing-side-calls.test.cjs index 44f45e088..3ec4badfe 100644 --- a/internal/gui/tests/routing-side-calls.test.cjs +++ b/internal/gui/tests/routing-side-calls.test.cjs @@ -80,15 +80,29 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", } await browser.close(); }); + // Routing's groups, drawn above the list, can land after the day's + // list does and push it down (#1640): what is measured below is the + // page with them in + const grouped = page.waitForResponse((r) => new URL(r.url()).pathname === "/api/groups"); await page.goto("http://magpie.test/?view=routing"); await page.locator(".rt-days .rt-day").nth(1).click(); await page.locator(".rt-req").nth(routes.length - 1).waitFor(); + await grouped; const tags = await page.locator(".rt-req").evaluateAll((rows) => rows.map((r) => r.querySelector(".asked .kind")?.textContent || "")); assert.deepEqual(tags, want[lang].tags); const story = async (i) => { const row = page.locator(".rt-req").nth(i); + // the list is there a frame or two before the page is done with it: + // the next frame's redraw and fit grow the part above, and the day + // clicked is held in place by scrolling. Where the row was is taken + // once it has stayed put for 10 frames, not as it is drawn (#1640) + await row.evaluate((e) => new Promise((done) => { + let last = e.getBoundingClientRect().top, still = 0; + const look = () => { const y = e.getBoundingClientRect().top; if (y === last) still++; else { last = y; still = 0; } if (still >= 10) done(); else requestAnimationFrame(look); }; + requestAnimationFrame(look); + })); const was = await row.evaluate((e) => e.getBoundingClientRect().top); const scrolled = await page.evaluate(() => document.scrollingElement.scrollTop); await row.click();