From 38e60d7449e094a90b7731be06198522f2b245b3 Mon Sep 17 00:00:00 2001 From: yetone Date: Mon, 16 Nov 2026 00:12:45 +0800 Subject: [PATCH] gui tests: a page's page-away beacon is left out of the writes they count, as update/using is (#6709) 80a315a70 (11-14) sends POST /api/page-away when the page is hidden. WebKit's page fires visibilitychange hidden in agent-bulk-visibility, so its write count read 6 for 5, red in every language in WebKit alone since then (git bisect run from e430e2750, red alone every time in 2.7s). The seven files that leave the window's update/using ping out of their counts now leave page-away out too; it writes nothing either. Run (rebased on 47ce008da, mote): agent-bulk-visibility, agent-disconnect-preview, library-bar-more, provider-find, sessions-folder-delete, settings-search, signin-close: pass 74 fail 0. Without the change: pass 69 fail 5 (the five WebKit subtests of agent-bulk-visibility). Not done: a shared helper for "the page's writes", which would carry the next such ping to every counting test at once; each file still has its own route. --- internal/gui/tests/agent-bulk-visibility.test.cjs | 4 ++-- internal/gui/tests/agent-disconnect-preview.test.cjs | 4 ++-- internal/gui/tests/library-bar-more.test.cjs | 4 ++-- internal/gui/tests/provider-find.test.cjs | 4 ++-- internal/gui/tests/sessions-folder-delete.test.cjs | 4 ++-- internal/gui/tests/settings-search.test.cjs | 2 +- internal/gui/tests/signin-close.test.cjs | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/internal/gui/tests/agent-bulk-visibility.test.cjs b/internal/gui/tests/agent-bulk-visibility.test.cjs index 433b21a74..23dae3439 100644 --- a/internal/gui/tests/agent-bulk-visibility.test.cjs +++ b/internal/gui/tests/agent-bulk-visibility.test.cjs @@ -29,8 +29,8 @@ for (const engine of process.env.BROWSER ? [process.env.BROWSER] : ['chromium', await page.route('**/*', async (route) => { const req = route.request(), url = new URL(req.url()); const json = (data) => route.fulfill({ json: data }); - // the window saying it is in use (update/using) is not the page's doing - if (req.method() === 'POST' && url.pathname !== '/api/update/using') posts.push([url.pathname, req.postDataJSON()]); + // the window saying it is in use (update/using), or that it went from view (page-away), is not the page's doing + if (req.method() === 'POST' && url.pathname !== '/api/update/using' && url.pathname !== '/api/page-away') posts.push([url.pathname, req.postDataJSON()]); if (url.pathname === '/boot.js') return route.fulfill({ contentType: 'text/javascript', body: `window.bootPrefs = ${JSON.stringify({lang, theme, web:true})};` }); if (url.pathname === '/wails/runtime.js') return route.fulfill({ contentType: 'text/javascript', body: 'export const Window = {};' }); if (url.pathname === '/api/state') return json(state); diff --git a/internal/gui/tests/agent-disconnect-preview.test.cjs b/internal/gui/tests/agent-disconnect-preview.test.cjs index 8e8f895fe..851c4e689 100644 --- a/internal/gui/tests/agent-disconnect-preview.test.cjs +++ b/internal/gui/tests/agent-disconnect-preview.test.cjs @@ -35,8 +35,8 @@ function serve(lang, textSize, posts) { return async (route) => { const req = route.request(), url = new URL(req.url()); const json = (data) => route.fulfill({ json: data }); - // the window saying it is in use (update/using) is not the page's doing - if (req.method() === "POST" && url.pathname !== "/api/update/using") posts.push(url.pathname); + // the window saying it is in use (update/using), or that it went from view (page-away), is not the page's doing + if (req.method() === "POST" && url.pathname !== "/api/update/using" && url.pathname !== "/api/page-away") posts.push(url.pathname); if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = ${JSON.stringify({ lang, theme: "light", textSize, web: false })};` }); if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" }); if (url.pathname === "/api/state") return json(state); diff --git a/internal/gui/tests/library-bar-more.test.cjs b/internal/gui/tests/library-bar-more.test.cjs index e6ecc2407..b9ad6d651 100644 --- a/internal/gui/tests/library-bar-more.test.cjs +++ b/internal/gui/tests/library-bar-more.test.cjs @@ -24,8 +24,8 @@ function server(lang, state, posts) { const req = route.request(); const url = new URL(req.url()); const json = (data) => route.fulfill({ json: data }); - // the window saying it is in use (update/using) is not the page's doing (#5982) - if (req.method() === "POST" && url.pathname !== "/api/update/using") posts.push(url.pathname); + // the window saying it is in use (update/using), or that it went from view (page-away), is not the page's doing (#5982) + if (req.method() === "POST" && url.pathname !== "/api/update/using" && url.pathname !== "/api/page-away") posts.push(url.pathname); if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:true};` }); if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" }); if (url.pathname === "/api/state") return json({ agents: [], profiles: [], settings: { lang, theme: "light" } }); diff --git a/internal/gui/tests/provider-find.test.cjs b/internal/gui/tests/provider-find.test.cjs index 1d772799f..151d8ceb5 100644 --- a/internal/gui/tests/provider-find.test.cjs +++ b/internal/gui/tests/provider-find.test.cjs @@ -63,8 +63,8 @@ function fixture(lang) { providers.providers = order.map((id) => providers.providers.find((p) => p.id === id)); return json(providers); } - // the window saying it is in use (update/using) is not the page's doing - if (request.method() !== "GET" && url.pathname !== "/api/update/using") posted.push(url.pathname); + // the window saying it is in use (update/using), or that it went from view (page-away), is not the page's doing + if (request.method() !== "GET" && url.pathname !== "/api/update/using" && url.pathname !== "/api/page-away") posted.push(url.pathname); if (url.pathname === "/api/providers") return json(providers); if (url.pathname === "/api/groups") return json({ groups: [] }); if (url.pathname === "/api/plugins") return json({ plugins: [] }); diff --git a/internal/gui/tests/sessions-folder-delete.test.cjs b/internal/gui/tests/sessions-folder-delete.test.cjs index 20691a2f1..f03b7c66f 100644 --- a/internal/gui/tests/sessions-folder-delete.test.cjs +++ b/internal/gui/tests/sessions-folder-delete.test.cjs @@ -73,8 +73,8 @@ function serve(lang, calls) { return json(out); } if (url.pathname.startsWith("/api/")) { - // the window's in-use ping (update/using) is no part of a delete - if (req.method() === "POST" && url.pathname !== "/api/update/using") calls.push({ path: url.pathname }); + // the window's in-use ping (update/using) and its page-away are no part of a delete + if (req.method() === "POST" && url.pathname !== "/api/update/using" && url.pathname !== "/api/page-away") calls.push({ path: url.pathname }); return json({}); } const file = path.join(assets, url.pathname === "/" ? "index.html" : url.pathname); diff --git a/internal/gui/tests/settings-search.test.cjs b/internal/gui/tests/settings-search.test.cjs index 376b23aa6..f7739b6c8 100644 --- a/internal/gui/tests/settings-search.test.cjs +++ b/internal/gui/tests/settings-search.test.cjs @@ -37,7 +37,7 @@ function server(lang, posts, web, { provs = ["codex", "claude"], off = [], built const req = route.request(), url = new URL(req.url()); const json = (data) => route.fulfill({ json: data }); // the window's in-use signal (any key or click, 10c4dc109) writes no setting (#6133) - if (req.method() !== "GET" && url.pathname !== "/api/update/using") posts.push(url.pathname); + if (req.method() !== "GET" && url.pathname !== "/api/update/using" && url.pathname !== "/api/page-away") posts.push(url.pathname); if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:${web},textSize:100,featuresOff:${JSON.stringify(off)}};` }); if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" }); if (url.pathname === "/api/state") return json({ agents: [], profiles: [], settings: { lang, theme: "light", textSize: 100 }, fx: cur.fx }); diff --git a/internal/gui/tests/signin-close.test.cjs b/internal/gui/tests/signin-close.test.cjs index a73b9434a..d9ebcee70 100644 --- a/internal/gui/tests/signin-close.test.cjs +++ b/internal/gui/tests/signin-close.test.cjs @@ -167,7 +167,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", const missing = await page.evaluate(() => ["Stop waiting for this sign-in"].filter((k) => !I18N.zh[k])); assert.deepEqual(missing, []); // a Windows window tints its title bar to the page (6927bedfc), which changes nothing; so does the "in use" ping a click sends (10c4dc109) - assert.deepEqual(ctl.other.filter((o) => o.startsWith("POST") && !o.includes("/api/open") && !o.includes("/api/window/titlebar") && !o.includes("/api/update/using")), [], "nothing else was changed"); + assert.deepEqual(ctl.other.filter((o) => o.startsWith("POST") && !o.includes("/api/open") && !o.includes("/api/window/titlebar") && !o.includes("/api/update/using") && !o.includes("/api/page-away")), [], "nothing else was changed"); assert.deepEqual(errors, []); }); }