gui tests: session-terminal clicks Theme only once the Ghostty save has drawn the page again

The Theme click resolved its button before the Ghostty save came back.
When the save then redrew Settings, the click landed on the button from
before, whose handler still holds the page as it was drawn
(sessionTerminal ""). Against the new prefsBase that "" reads as a change,
so the theme save sent the terminal back to System default, and line 119
saw "". It failed 1 to 2 runs in 5 when 5 ran in parallel, on origin/main
591ed58b5 as well as on the P2 branch.

The test now marks the Theme buttons before the pick and waits for new
ones, as a reader can only click what is on the page.

Run: holding the Ghostty POST 400ms and the Theme click 600ms fails the
old test every time and passes the new one; 5 parallel runs
(chromium ×4, chromium+webkit ×1) all green.
This commit is contained in:
yetone
2026-10-14 08:33:23 +08:00
parent 82f3befd29
commit efbacd4e54
@@ -109,10 +109,16 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
assert.equal((await select.textContent()).trim(), lang === "zh" ? "系统默认(Terminal)" : "System default (Terminal)");
const top = await page.evaluate(() => document.scrollingElement.scrollTop);
// the page is drawn again once the save is in; a Theme button from
// before then still sends the page as it was drawn, the old terminal
// with it, so the Theme click below waits for the new buttons, as a
// reader can only click what is on the page
await page.evaluate(() => document.querySelectorAll("#themeSegs .opt").forEach((b) => { b.dataset.before = "1"; }));
await choose("Ghostty");
assert.equal(await page.evaluate(() => document.scrollingElement.scrollTop), top, "the page doesn't move");
await page.waitForFunction(() => document.querySelector("#sessionTerminalSelect").dataset.value === "com.mitchellh.ghostty");
assert.equal((await select.textContent()).trim(), "Ghostty");
await page.waitForFunction(() => !document.querySelector("#themeSegs .opt[data-before]"));
// another setting saved (Theme, scrolled away above) keeps the terminal
await page.locator("#themeSegs .opt").last().evaluate((b) => b.click());
await page.waitForFunction(() => document.documentElement.dataset.theme === "dark");