test: relax browser act contract timeout on Windows

This commit is contained in:
Peter Steinberger
2026-01-15 05:29:32 +00:00
parent 7d4f2d9aed
commit ad46e95df9
2 changed files with 68 additions and 63 deletions

View File

@@ -263,72 +263,78 @@ describe("browser control server", () => {
return (await res.json()) as T; return (await res.json()) as T;
}; };
it("agent contract: form + layout act commands", async () => { const slowTimeoutMs = process.platform === "win32" ? 40_000 : 20_000;
const base = await startServerAndBase();
const select = (await postJson(`${base}/act`, { it(
kind: "select", "agent contract: form + layout act commands",
ref: "5", async () => {
values: ["a", "b"], const base = await startServerAndBase();
})) as { ok: boolean };
expect(select.ok).toBe(true);
expect(pwMocks.selectOptionViaPlaywright).toHaveBeenCalledWith({
cdpUrl: cdpBaseUrl,
targetId: "abcd1234",
ref: "5",
values: ["a", "b"],
});
const fill = (await postJson(`${base}/act`, { const select = (await postJson(`${base}/act`, {
kind: "fill", kind: "select",
fields: [{ ref: "6", type: "textbox", value: "hello" }], ref: "5",
})) as { ok: boolean }; values: ["a", "b"],
expect(fill.ok).toBe(true); })) as { ok: boolean };
expect(pwMocks.fillFormViaPlaywright).toHaveBeenCalledWith({ expect(select.ok).toBe(true);
cdpUrl: cdpBaseUrl, expect(pwMocks.selectOptionViaPlaywright).toHaveBeenCalledWith({
targetId: "abcd1234", cdpUrl: cdpBaseUrl,
fields: [{ ref: "6", type: "textbox", value: "hello" }], targetId: "abcd1234",
}); ref: "5",
values: ["a", "b"],
});
const resize = (await postJson(`${base}/act`, { const fill = (await postJson(`${base}/act`, {
kind: "resize", kind: "fill",
width: 800, fields: [{ ref: "6", type: "textbox", value: "hello" }],
height: 600, })) as { ok: boolean };
})) as { ok: boolean }; expect(fill.ok).toBe(true);
expect(resize.ok).toBe(true); expect(pwMocks.fillFormViaPlaywright).toHaveBeenCalledWith({
expect(pwMocks.resizeViewportViaPlaywright).toHaveBeenCalledWith({ cdpUrl: cdpBaseUrl,
cdpUrl: cdpBaseUrl, targetId: "abcd1234",
targetId: "abcd1234", fields: [{ ref: "6", type: "textbox", value: "hello" }],
width: 800, });
height: 600,
});
const wait = (await postJson(`${base}/act`, { const resize = (await postJson(`${base}/act`, {
kind: "wait", kind: "resize",
timeMs: 5, width: 800,
})) as { ok: boolean }; height: 600,
expect(wait.ok).toBe(true); })) as { ok: boolean };
expect(pwMocks.waitForViaPlaywright).toHaveBeenCalledWith({ expect(resize.ok).toBe(true);
cdpUrl: cdpBaseUrl, expect(pwMocks.resizeViewportViaPlaywright).toHaveBeenCalledWith({
targetId: "abcd1234", cdpUrl: cdpBaseUrl,
timeMs: 5, targetId: "abcd1234",
text: undefined, width: 800,
textGone: undefined, height: 600,
}); });
const evalRes = (await postJson(`${base}/act`, { const wait = (await postJson(`${base}/act`, {
kind: "evaluate", kind: "wait",
fn: "() => 1", timeMs: 5,
})) as { ok: boolean; result?: unknown }; })) as { ok: boolean };
expect(evalRes.ok).toBe(true); expect(wait.ok).toBe(true);
expect(evalRes.result).toBe("ok"); expect(pwMocks.waitForViaPlaywright).toHaveBeenCalledWith({
expect(pwMocks.evaluateViaPlaywright).toHaveBeenCalledWith({ cdpUrl: cdpBaseUrl,
cdpUrl: cdpBaseUrl, targetId: "abcd1234",
targetId: "abcd1234", timeMs: 5,
fn: "() => 1", text: undefined,
ref: undefined, textGone: undefined,
}); });
}, 20_000);
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 () => { it("agent contract: hooks + response + downloads + screenshot", async () => {
const base = await startServerAndBase(); const base = await startServerAndBase();

View File

@@ -134,8 +134,7 @@ export async function finalizeOnboardingWizard(options: FinalizeOnboardingOption
if ( if (
!loaded || !loaded ||
(loaded && (loaded && (await service.isLoaded({ profile: process.env.CLAWDBOT_PROFILE })) === false)
(await service.isLoaded({ profile: process.env.CLAWDBOT_PROFILE })) === false)
) { ) {
const devMode = const devMode =
process.argv[1]?.includes(`${path.sep}src${path.sep}`) && process.argv[1]?.endsWith(".ts"); process.argv[1]?.includes(`${path.sep}src${path.sep}`) && process.argv[1]?.endsWith(".ts");