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.
This commit is contained in:
@@ -306,7 +306,10 @@ describe("browser tab-supervisor — cmux tab close mid-run (#4499)", () => {
|
||||
}
|
||||
},
|
||||
);
|
||||
const warn = spyOn(logger, "warn").mockImplementation(() => {});
|
||||
const warningLogged = Promise.withResolvers<void>();
|
||||
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",
|
||||
|
||||
@@ -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<void>();
|
||||
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",
|
||||
|
||||
Reference in New Issue
Block a user