gui tests: account-eye reads an eye again when a re-render replaced its card (#5052)

The Usage card test's first read, opacity(card(ME).locator(".acct-eye")),
came back '' in Chromium under parallel runs. Instrumented on mica, every
such read was of a button no longer in the document (isConnected false,
an empty computed style): a re-render replaced the card between the
locator's resolve and the evaluate. The helper now reads again, which
resolves the locator afresh, until the element is attached (at most 21
reads; it never waits a fixed time).

Run on mica at this head (origin/main 2e1c0a377 plus this file), 8
parallel runs of account-eye.test.cjs, both engines:
- before: the Usage-card test alone, 8 runs, 32 of 40 red at line 294;
- after: 8 of 8 runs pass 30 of 30, 240 of 240.

Not changed: why the Usage page re-renders the card once more after
its first .quota-alias shows. That second render is expected (a later
poll repaints), and nothing a user sees depends on the same element
staying.
This commit is contained in:
yetone
2026-11-15 14:26:16 +08:00
parent c2c3e0c6f6
commit 17d230d65f
+9 -1
View File
@@ -75,7 +75,15 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
const scrolled = (page) => page.evaluate(() => [window.scrollY, ...[...document.querySelectorAll("*")].filter((e) => e.scrollTop > 0).map((e) => `${e.className}:${e.scrollTop}`)].join(" "));
const wide = (page) => page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth);
const stripes = (page, sel) => page.evaluate((sel) => [...document.querySelectorAll(sel)].map((e) => getComputedStyle(e).borderLeftWidth).filter((b) => parseFloat(b) > 1), sel);
const opacity = (loc) => loc.evaluate((e) => getComputedStyle(e).display === "none" ? "none" : getComputedStyle(e).opacity);
// a re-render can replace the card between the locator's resolve and
// the read, and a detached element's computed display is '' (#5052):
// read again, which resolves the locator afresh, until it is attached
const opacity = async (loc) => {
for (let i = 0; ; i++) {
const v = await loc.evaluate((e) => !e.isConnected ? null : getComputedStyle(e).display === "none" ? "none" : getComputedStyle(e).opacity);
if (v !== null || i === 20) return v ?? "detached";
}
};
// what of an element is in sight: its text and every tooltip in it
const seen = (loc) => loc.evaluate((e) => [e.textContent, ...[e, ...e.querySelectorAll("[title]")].map((x) => x.title || "")].join(" | "));
// a sentence and a tooltip elsewhere in the window naming both accounts