From de43f6496d7c6393b06bfb4e6bfc45742902490f Mon Sep 17 00:00:00 2001 From: yetone Date: Sun, 11 Oct 2026 04:56:17 +0800 Subject: [PATCH] gui tests: usage-alert checks the currency click from where its row is in view usage-alert was red in WebKit zh ("no click moved the page", 206 !== 207) since e9221e96d (#1518) added the Allowance reads row to Settings > Usage (bisected). In zh the wheel now stops at the bottom of the settings with the currency row 0.02px above the view (opt top 49.98, view top 50.00). Playwright scrolls a click's target into view before clicking, and that scroll is the 1px. scrollIntoViewIfNeeded alone moves it 207 -> 206; no app script writes scrollTop, and focus, mouse down and up on the option move nothing. The app changed on purpose and a reader's click moves nothing, so the test is fixed: the alert clicks are checked against the wheel's position as before, then the currency row is brought into view and its click is checked against that. Run: usage-alert alone, webkit and chromium, en and zh: 5/5 each. Broken by hand (served app.js: hold() a no-op, the CNY click scrolls the settings up 30px 600ms later): the new check goes red in en (90 !== 120) and zh (176 !== 206), in both engines. --- internal/gui/tests/usage-alert.test.cjs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/internal/gui/tests/usage-alert.test.cjs b/internal/gui/tests/usage-alert.test.cjs index ba89f53f8..52496031a 100644 --- a/internal/gui/tests/usage-alert.test.cjs +++ b/internal/gui/tests/usage-alert.test.cjs @@ -172,15 +172,24 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", assert.equal((await posted(4)).balanceAlert, 2.5); await settled(); - // another setting saved later keeps both alerts - await page.locator("#currencySegs .opt", { hasText: w.cny }).click(); + // another setting saved later keeps both alerts. The currency row + // sits above the alert rows: in zh, since the Allowance reads row + // (e9221e96d), the wheel stops at the bottom with it 0.02px above + // the view, and Playwright scrolls a target into view before it + // clicks. So the alert clicks are checked here, and the currency + // click from where its row is in view. + assert.equal(await view(page), before, "no alert click moved the page"); + const cny = page.locator("#currencySegs .opt", { hasText: w.cny }); + await cny.scrollIntoViewIfNeeded(); + const atCurrency = await view(page); + await cny.click(); const c = await posted(5); assert.equal(c.currency, "cny"); assert.equal(c.usageAlert, 90, "the usage alert is kept by another save"); assert.equal(c.balanceAlert, 2.5, "the balance alert is kept by another save"); await settled(); assert.equal(await share.inputValue(), "90"); - assert.equal(await view(page), before, "no click moved the page"); + assert.equal(await view(page), atCurrency, "the currency click moved nothing"); // Off saves 0, and the field goes await usageSegs.nth(0).click();