gui tests: quota-curve measures the tray's spark in one go once it is drawn, so it no longer reads a card that was just redrawn as having no box

quota-curve.test.cjs could fail with "TypeError: Cannot read properties of
null (reading 'height')". It looked up the tray's spark and its card in one
call each, then measured them. When the tab opens, the allowances it reads
come back and the cards are drawn again (#1588). Under load, the card found
first could be taken out before it was measured, so boundingBox() gave null.

Now one waitForFunction finds the card and the spark, and measures both, in
a single pass in the page, once the spark has a width.

What was run, with one busy-looping node per CPU:
- origin/main 5dfcf4346, chromium only, 3 runs: red in 1 of 6 tests.
- This branch before this change, same load: red in 4 of 6.
- After this change, same load: 6 of 6 pass.
- Without load: quota-curve, balance-curve and panel-balance-order pass in
  both engines.
This commit is contained in:
yetone
2026-10-12 01:19:37 +08:00
parent 7c23ecea9d
commit 781cb386cc
+11 -1
View File
@@ -187,7 +187,17 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
// the line ends at now already; in 16px a dotted now line read as a
// stray mark under the curve (#1601)
assert.equal(await spark.locator("line.qc-now").count(), 0, "no now line in the thin spark");
const sb = await spark.boundingBox(), cb = await pcard.boundingBox();
// measured in one go once drawn: the cards are drawn again when the
// allowances read on opening the tab come back, and a card looked up
// in one call and measured in the next could be the one taken out
// (red under load, on main too)
const { sb, cb } = await panel.waitForFunction(() => {
const c = [...document.querySelectorAll("#panelQuota .pq-card")].find((c) => c.textContent.includes("a@x.com"));
const s = c?.querySelector(".pq-spark");
if (!s || !s.getBoundingClientRect().width) return null;
const box = (e) => { const r = e.getBoundingClientRect(); return { width: r.width, height: r.height }; };
return { sb: box(s), cb: box(c) };
}).then((h) => h.jsonValue());
assert.ok(sb.height <= 17 && sb.width > cb.width * 0.7, `thin and across the card: ${JSON.stringify(sb)}`);
assert.equal(await panel.locator(".pq-card", { hasText: "Kimi" }).locator(".pq-spark").count(), 0);
// a click into the list, then a key to scroll it, rings nothing: the