From ad46e95df941b2173eb48d175f6a412c06243521 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Thu, 15 Jan 2026 05:29:32 +0000 Subject: [PATCH] test: relax browser act contract timeout on Windows --- ...-contract-form-layout-act-commands.test.ts | 128 +++++++++--------- src/wizard/onboarding.finalize.ts | 3 +- 2 files changed, 68 insertions(+), 63 deletions(-) diff --git a/src/browser/server.agent-contract-form-layout-act-commands.test.ts b/src/browser/server.agent-contract-form-layout-act-commands.test.ts index 92895c0ff..20ad4ba73 100644 --- a/src/browser/server.agent-contract-form-layout-act-commands.test.ts +++ b/src/browser/server.agent-contract-form-layout-act-commands.test.ts @@ -263,72 +263,78 @@ describe("browser control server", () => { return (await res.json()) as T; }; - it("agent contract: form + layout act commands", async () => { - const base = await startServerAndBase(); + const slowTimeoutMs = process.platform === "win32" ? 40_000 : 20_000; - const select = (await postJson(`${base}/act`, { - kind: "select", - ref: "5", - values: ["a", "b"], - })) as { ok: boolean }; - expect(select.ok).toBe(true); - expect(pwMocks.selectOptionViaPlaywright).toHaveBeenCalledWith({ - cdpUrl: cdpBaseUrl, - targetId: "abcd1234", - ref: "5", - values: ["a", "b"], - }); + it( + "agent contract: form + layout act commands", + async () => { + const base = await startServerAndBase(); - const fill = (await postJson(`${base}/act`, { - kind: "fill", - fields: [{ ref: "6", type: "textbox", value: "hello" }], - })) as { ok: boolean }; - expect(fill.ok).toBe(true); - expect(pwMocks.fillFormViaPlaywright).toHaveBeenCalledWith({ - cdpUrl: cdpBaseUrl, - targetId: "abcd1234", - fields: [{ ref: "6", type: "textbox", value: "hello" }], - }); + const select = (await postJson(`${base}/act`, { + kind: "select", + ref: "5", + values: ["a", "b"], + })) as { ok: boolean }; + expect(select.ok).toBe(true); + expect(pwMocks.selectOptionViaPlaywright).toHaveBeenCalledWith({ + cdpUrl: cdpBaseUrl, + targetId: "abcd1234", + ref: "5", + values: ["a", "b"], + }); - const resize = (await postJson(`${base}/act`, { - kind: "resize", - width: 800, - height: 600, - })) as { ok: boolean }; - expect(resize.ok).toBe(true); - expect(pwMocks.resizeViewportViaPlaywright).toHaveBeenCalledWith({ - cdpUrl: cdpBaseUrl, - targetId: "abcd1234", - width: 800, - height: 600, - }); + const fill = (await postJson(`${base}/act`, { + kind: "fill", + fields: [{ ref: "6", type: "textbox", value: "hello" }], + })) as { ok: boolean }; + expect(fill.ok).toBe(true); + expect(pwMocks.fillFormViaPlaywright).toHaveBeenCalledWith({ + cdpUrl: cdpBaseUrl, + targetId: "abcd1234", + fields: [{ ref: "6", type: "textbox", value: "hello" }], + }); - const wait = (await postJson(`${base}/act`, { - kind: "wait", - timeMs: 5, - })) as { ok: boolean }; - expect(wait.ok).toBe(true); - expect(pwMocks.waitForViaPlaywright).toHaveBeenCalledWith({ - cdpUrl: cdpBaseUrl, - targetId: "abcd1234", - timeMs: 5, - text: undefined, - textGone: undefined, - }); + const resize = (await postJson(`${base}/act`, { + kind: "resize", + width: 800, + height: 600, + })) as { ok: boolean }; + expect(resize.ok).toBe(true); + expect(pwMocks.resizeViewportViaPlaywright).toHaveBeenCalledWith({ + cdpUrl: cdpBaseUrl, + targetId: "abcd1234", + width: 800, + height: 600, + }); - const evalRes = (await postJson(`${base}/act`, { - kind: "evaluate", - fn: "() => 1", - })) as { ok: boolean; result?: unknown }; - expect(evalRes.ok).toBe(true); - expect(evalRes.result).toBe("ok"); - expect(pwMocks.evaluateViaPlaywright).toHaveBeenCalledWith({ - cdpUrl: cdpBaseUrl, - targetId: "abcd1234", - fn: "() => 1", - ref: undefined, - }); - }, 20_000); + const wait = (await postJson(`${base}/act`, { + kind: "wait", + timeMs: 5, + })) as { ok: boolean }; + expect(wait.ok).toBe(true); + expect(pwMocks.waitForViaPlaywright).toHaveBeenCalledWith({ + cdpUrl: cdpBaseUrl, + targetId: "abcd1234", + timeMs: 5, + text: undefined, + textGone: undefined, + }); + + const evalRes = (await postJson(`${base}/act`, { + kind: "evaluate", + fn: "() => 1", + })) as { ok: boolean; result?: unknown }; + expect(evalRes.ok).toBe(true); + expect(evalRes.result).toBe("ok"); + expect(pwMocks.evaluateViaPlaywright).toHaveBeenCalledWith({ + cdpUrl: cdpBaseUrl, + targetId: "abcd1234", + fn: "() => 1", + ref: undefined, + }); + }, + slowTimeoutMs, + ); it("agent contract: hooks + response + downloads + screenshot", async () => { const base = await startServerAndBase(); diff --git a/src/wizard/onboarding.finalize.ts b/src/wizard/onboarding.finalize.ts index a65310b88..06d914cc5 100644 --- a/src/wizard/onboarding.finalize.ts +++ b/src/wizard/onboarding.finalize.ts @@ -134,8 +134,7 @@ export async function finalizeOnboardingWizard(options: FinalizeOnboardingOption if ( !loaded || - (loaded && - (await service.isLoaded({ profile: process.env.CLAWDBOT_PROFILE })) === false) + (loaded && (await service.isLoaded({ profile: process.env.CLAWDBOT_PROFILE })) === false) ) { const devMode = process.argv[1]?.includes(`${path.sep}src${path.sep}`) && process.argv[1]?.endsWith(".ts");