diff --git a/extensions/browser/src/browser/chrome-mcp.test.ts b/extensions/browser/src/browser/chrome-mcp.test.ts index 2601f5935a5c..3602c4bb787d 100644 --- a/extensions/browser/src/browser/chrome-mcp.test.ts +++ b/extensions/browser/src/browser/chrome-mcp.test.ts @@ -17,6 +17,11 @@ type ToolCall = { name: string; arguments?: Record; }; +type ToolCallMock = { + mock: { + calls: Array<[ToolCall]>; + }; +}; type ChromeMcpSessionFactory = Exclude< Parameters[0], @@ -256,9 +261,9 @@ describe("chrome MCP page parsing", () => { name: "new_page", arguments: { url: "about:blank", timeout: 5000 }, }); - expect(session.client.callTool).not.toHaveBeenCalledWith( - expect.objectContaining({ name: "navigate_page" }), - ); + const callToolMock = session.client.callTool as unknown as ToolCallMock; + const callNames = callToolMock.mock.calls.map(([call]) => call.name); + expect(callNames).not.toContain("navigate_page"); }); it("parses evaluate_script text responses when structuredContent is missing", async () => { @@ -654,12 +659,11 @@ describe("chrome MCP page parsing", () => { // intentionally no timeoutMs }); - expect(session.client.callTool).toHaveBeenCalledWith( - expect.objectContaining({ - name: "navigate_page", - arguments: expect.objectContaining({ timeout: 20_000 }), - }), - ); + const callToolMock = session.client.callTool as unknown as ToolCallMock; + const navigateCall = callToolMock.mock.calls.find( + ([call]) => call.name === "navigate_page", + )?.[0]; + expect(navigateCall?.arguments?.timeout).toBe(20_000); }); it("resets the Chrome MCP session when a navigate_page call hangs past the safety-net timeout", async () => { diff --git a/extensions/browser/src/browser/pw-ai.e2e.test.ts b/extensions/browser/src/browser/pw-ai.e2e.test.ts index 0fd529082171..b671048591b6 100644 --- a/extensions/browser/src/browser/pw-ai.e2e.test.ts +++ b/extensions/browser/src/browser/pw-ai.e2e.test.ts @@ -96,10 +96,8 @@ describe("pw-ai", () => { targetId: "T1", }); - expect(res.refs).toMatchObject({ - e1: { role: "button", name: "OK" }, - e2: { role: "link", name: "Docs" }, - }); + expect(res.refs.e1).toEqual({ role: "button", name: "OK" }); + expect(res.refs.e2).toEqual({ role: "link", name: "Docs" }); await clickViaPlaywright({ cdpUrl: "http://127.0.0.1:18792", @@ -142,10 +140,8 @@ describe("pw-ai", () => { expect(res.snapshot).toContain("[ref=1]"); expect(res.snapshot).toContain("[ref=2]"); - expect(res.refs).toMatchObject({ - 1: { role: "button", name: "OK" }, - 2: { role: "link", name: "Docs" }, - }); + expect(res.refs["1"]).toEqual({ role: "button", name: "OK" }); + expect(res.refs["2"]).toEqual({ role: "link", name: "Docs" }); await clickViaPlaywright({ cdpUrl: "http://127.0.0.1:18792", diff --git a/extensions/browser/src/node-host/invoke-browser.test.ts b/extensions/browser/src/node-host/invoke-browser.test.ts index f56372d6b6e1..f2abae34bbe7 100644 --- a/extensions/browser/src/node-host/invoke-browser.test.ts +++ b/extensions/browser/src/node-host/invoke-browser.test.ts @@ -335,11 +335,8 @@ describe("runBrowserProxyCommand", () => { }), ); - expect(dispatcherMocks.dispatch).toHaveBeenCalledWith( - expect.objectContaining({ - path: "/snapshot", - }), - ); + const [request] = dispatcherMocks.dispatch.mock.calls[0] as [{ path?: string }, ...unknown[]]; + expect(request.path).toBe("/snapshot"); }); it("rejects unauthorized body.profile when allowProfiles is configured", async () => { @@ -436,12 +433,12 @@ describe("runBrowserProxyCommand", () => { }), ); - expect(dispatcherMocks.dispatch).toHaveBeenCalledWith( - expect.objectContaining({ - path: "/stop", - query: { profile: "openclaw" }, - }), - ); + const [request] = dispatcherMocks.dispatch.mock.calls[0] as [ + { path?: string; query?: unknown }, + ...unknown[], + ]; + expect(request.path).toBe("/stop"); + expect(request.query).toEqual({ profile: "openclaw" }); }); it("rejects persistent profile creation when allowProfiles is empty", async () => {