From 271e621a02e3e8300a802127f839b0cb121a2770 Mon Sep 17 00:00:00 2001 From: brymko <47984664+brymko@users.noreply.github.com> Date: Wed, 5 Aug 2026 17:41:40 +0800 Subject: [PATCH] test(coding-agent): synchronized browser rejection checks Waited for the observable warning event instead of assuming late continuations settle within a fixed wall-clock delay under CI load. --- .../test/tools/browser-cmux-release-mid-run.test.ts | 7 +++++-- .../coding-agent/test/tools/browser-tab-evaluate.test.ts | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/coding-agent/test/tools/browser-cmux-release-mid-run.test.ts b/packages/coding-agent/test/tools/browser-cmux-release-mid-run.test.ts index 8e130c14b..768021be3 100644 --- a/packages/coding-agent/test/tools/browser-cmux-release-mid-run.test.ts +++ b/packages/coding-agent/test/tools/browser-cmux-release-mid-run.test.ts @@ -306,7 +306,10 @@ describe("browser tab-supervisor — cmux tab close mid-run (#4499)", () => { } }, ); - const warn = spyOn(logger, "warn").mockImplementation(() => {}); + const warningLogged = Promise.withResolvers(); + const warn = spyOn(logger, "warn").mockImplementation(message => { + if (message === "Unhandled rejection after browser run ended") warningLogged.resolve(); + }); const browser = await acquireBrowser(makeKind("late-rejection"), { cwd: "/tmp" }); await acquireTab("late-rejection", browser, { timeoutMs: 5_000, @@ -329,7 +332,7 @@ describe("browser tab-supervisor — cmux tab close mid-run (#4499)", () => { }); expect(result.returnValue).toBe("completed"); - await Bun.sleep(150); + await warningLogged.promise; expect(warn).toHaveBeenCalledWith("Unhandled rejection after browser run ended", { runId: expect.any(String), error: "late cmux continuation failed", diff --git a/packages/coding-agent/test/tools/browser-tab-evaluate.test.ts b/packages/coding-agent/test/tools/browser-tab-evaluate.test.ts index 57ad531e2..30c299a20 100644 --- a/packages/coding-agent/test/tools/browser-tab-evaluate.test.ts +++ b/packages/coding-agent/test/tools/browser-tab-evaluate.test.ts @@ -458,7 +458,10 @@ describe.skipIf(!CHROMIUM_AVAILABLE)("browser tab evaluation", () => { }, 30_000); it("logs a user continuation rejection after its browser run ends", async () => { - const warn = vi.spyOn(logger, "warn").mockImplementation(() => {}); + const warningLogged = Promise.withResolvers(); + const warn = vi.spyOn(logger, "warn").mockImplementation(message => { + if (message === "Unhandled rejection after browser run ended") warningLogged.resolve(); + }); const tool = new BrowserTool(makeSession()); const name = `late-continuation-rejection-${process.pid}`; @@ -484,7 +487,7 @@ describe.skipIf(!CHROMIUM_AVAILABLE)("browser tab evaluation", () => { }); expect(result.content).toEqual([{ type: "text", text: "completed" }]); - await Bun.sleep(150); + await warningLogged.promise; expect(warn).toHaveBeenCalledWith("Unhandled rejection after browser run ended", { runId: expect.any(String), error: "late continuation failed",