From efbacd4e54798ef50e73c5b79f2dcdc8f812096c Mon Sep 17 00:00:00 2001 From: yetone Date: Wed, 14 Oct 2026 05:10:47 +0800 Subject: [PATCH] gui tests: session-terminal clicks Theme only once the Ghostty save has drawn the page again MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- internal/gui/tests/session-terminal.test.cjs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/gui/tests/session-terminal.test.cjs b/internal/gui/tests/session-terminal.test.cjs index 7e0428d14..fbfb0c465 100644 --- a/internal/gui/tests/session-terminal.test.cjs +++ b/internal/gui/tests/session-terminal.test.cjs @@ -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");