From fff5ad0ef7a92eecbbb5bdbf09ce83b93e135463 Mon Sep 17 00:00:00 2001 From: yetone Date: Thu, 29 Oct 2026 18:01:01 +0800 Subject: [PATCH] gui tests: context-tune waits for the picker's box while the row re-renders under the wheel (#4221) "webkit: a window of the reader's own" read `(await row.locator(".ctx-tune-pick").boundingBox()).y` in its scroll loop. When the row re-renders after the history answers, the picker has no box for a moment, boundingBox() returns null and the test throws "Cannot read properties of null (reading 'y')" (zh-TW 360x760 in a WSL run). The loop now waits up to ~1s for a box and fails with a plain message if none comes. Run (WSL, magpie-desktop, at this tree on origin/main f41b63232): - context-tune, i18n-keys, gui-zh-tw, gui-ja, gui-de with --test-concurrency=2 (Chromium + WebKit): 127 of 127 pass Broken by hand: a copy of the test that hides the picker for 150ms just before the scroll loop fails every case of "a window of the reader's own" with the #4221 error on the old loop, and passes 22 of 22 with the new one. Not tried: reproducing the original re-render timing without injection. --- internal/gui/tests/context-tune.test.cjs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/internal/gui/tests/context-tune.test.cjs b/internal/gui/tests/context-tune.test.cjs index 2133eef9e..dab439ad2 100644 --- a/internal/gui/tests/context-tune.test.cjs +++ b/internal/gui/tests/context-tune.test.cjs @@ -239,7 +239,17 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", await page.locator(".ctx-none").waitFor(); // the history has answered: the pane is its full length // the reader scrolls to the picker, as a wheel does await page.mouse.move(width / 2, 300); - for (let i = 0; i < 20 && (await row.locator(".ctx-tune-pick").boundingBox()).y > height * 0.6; i++) { + // the row can re-render under the wheel, and a picker being replaced has no box + // for a moment: wait for one instead of reading null (#4221) + const pickY = async () => { + for (let i = 0; i < 50; i++) { + const b = await row.locator(".ctx-tune-pick").boundingBox(); + if (b) return b.y; + await page.waitForTimeout(20); + } + throw new Error("the picker never had a box"); + }; + for (let i = 0; i < 20 && (await pickY()) > height * 0.6; i++) { await page.mouse.wheel(0, 120); await page.waitForTimeout(60); }