gui tests: settings-groups waits for a pill's thumb to be refitted (#5839)

thumbsUnderPicks measured each pill's thumb once, straight after the
editor opened. The thumb is refitted by a ResizeObserver (thumbFit) once
the editor sizes its pill, so on a busy machine the measurement could
come first: "codex/wb: the pills' thumbs under their picks, 1 !== 0", 3
of 13 runs beside other GUI files on mote. It now waits up to 3s for
every thumb to sit under its pick, then asserts as before.

Run (mote, at this tree): settings-groups, editor-chips-wheel and
provider-models-rest at --test-concurrency=4, 8 times: settings-groups
green every time (provider-models-rest's reds are #4396).
Broken by hand: thumbFit's refit turned off, settings-groups red (codex's
thumbs, 4 subtests), then put back.
This commit is contained in:
yetone
2026-11-10 07:56:39 +08:00
parent 62a9ab743f
commit 5c47d59b56
+13 -3
View File
@@ -145,11 +145,21 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
// each editor shows its own service's rows alone
const visibleRows = () => page.locator(".editor .prov-prefs .row.pref:visible .who .name").allTextContents();
// each pill shown has its thumb under the option picked, drawn
// while its list was in the hidden holder or not
const thumbsUnderPicks = async (k) => assert.equal(await page.locator("#" + LISTS[k]).evaluate((l) => [...l.querySelectorAll(".segs")].filter((s) => {
// while its list was in the hidden holder or not. A ResizeObserver
// refits a thumb after the editor sizes its pill, so wait for that
// (on a busy machine it lands after the editor shows, #5839)
const thumbsOff = (l) => [...l.querySelectorAll(".segs")].filter((s) => {
const th = s.querySelector(":scope > .thumb").getBoundingClientRect(), on = s.querySelector(":scope > .on").getBoundingClientRect();
return !(Math.abs(th.left - on.left) <= 1 && Math.abs(th.width - on.width) <= 1);
}).length), 0, k + ": the pills' thumbs under their picks");
}).length;
const thumbsUnderPicks = async (k) => {
const list = await page.locator("#" + LISTS[k]).elementHandle();
await page.waitForFunction((l) => [...l.querySelectorAll(".segs")].every((s) => {
const th = s.querySelector(":scope > .thumb").getBoundingClientRect(), on = s.querySelector(":scope > .on").getBoundingClientRect();
return Math.abs(th.left - on.left) <= 1 && Math.abs(th.width - on.width) <= 1;
}), list, { timeout: 3000 }).catch(() => {});
assert.equal(await list.evaluate(thumbsOff), 0, k + ": the pills' thumbs under their picks");
};
// no coloured stripe down a list's or a row's left side
const stripes = () => page.evaluate(() => [...document.querySelectorAll(".editor .prov-prefs .list, .editor .prov-prefs .row")]
.filter((e) => { const c = getComputedStyle(e); return c.borderLeftWidth !== c.borderRightWidth || c.borderLeftColor !== c.borderRightColor; }).length);