From eca63d7ca23de081a465d626c1dd351fd7d98653 Mon Sep 17 00:00:00 2001 From: yetone Date: Sun, 11 Oct 2026 00:16:45 +0800 Subject: [PATCH] gui test: plugin-moved-signin's fake server keeps the provider being signed in to, so a late poll after the test empties its log doesn't throw (#1440) The Factory step empties asked while ZCode's sign-in may still poll /api/signin/s1. The handler read the provider back as asked.filter(...).at(-1)[1], which was undefined, so the route threw and the browser closed: "Cannot read properties of undefined (reading '1')", then "Target page, context or browser has been closed". It failed 2 of 3 runs here, in chromium alone, not only under a 4-wide run. Ran: plugin-moved-signin.test.cjs, chromium+webkit, 6 runs: 6/6 pass. Before the change it failed in runs 1 and 3. --- internal/gui/tests/plugin-moved-signin.test.cjs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/internal/gui/tests/plugin-moved-signin.test.cjs b/internal/gui/tests/plugin-moved-signin.test.cjs index 3361f7d00..470213482 100644 --- a/internal/gui/tests/plugin-moved-signin.test.cjs +++ b/internal/gui/tests/plugin-moved-signin.test.cjs @@ -28,7 +28,9 @@ function server(lang, asked) { account: { agent: "cursor", agentName: "Cursor", agentIcon: "cursor", user: "a@c", logins: [{ user: "a@c", active: true, on: true }, { user: "b@c", on: true }] } }], presets: [], excluded: [], gateway: { running: true, window: true }, plugins, onPlugins: ["zcode", "factory", "cursor"], }); - let polls = 0; + // the provider being signed in to: kept apart from asked, which the test + // empties while the last sign-in's poll may still be on its way (#1440) + let polls = 0, signing = ""; return async (route) => { const url = new URL(route.request().url()); const json = (data) => route.fulfill({ json: data }); @@ -44,11 +46,12 @@ function server(lang, asked) { const b = body(); asked.push(["signin", b]); polls = 0; + signing = b.provider; return json({ id: "s1", agent: b.provider, state: "waiting", url: "https://fake.test/device", code: b.provider === "factory" ? "ABCD-EFGH" : "", instructions: "Confirm the code ABCD-EFGH on Factory's page" }); } if (url.pathname === "/api/signin/s1") { // ZCode's fails on the second look, to be tried again - const p = asked.filter(([k]) => k === "signin").at(-1)[1].provider; + const p = signing; if (++polls < 2 || p !== "zcode") return json({ id: "s1", agent: p, state: "waiting", url: "https://fake.test/device", code: p === "factory" ? "ABCD-EFGH" : "" }); return json({ id: "s1", agent: "zcode", state: "failed", error: "the sign-in page expired" }); }