From 6f3fd2410c2a79666db8ce8ecedbb480ad15aeb7 Mon Sep 17 00:00:00 2001 From: Shakker Date: Mon, 11 May 2026 14:32:36 +0100 Subject: [PATCH] test: pin browser fallback calls --- ...xt.remote-profile-tab-ops.fallback.test.ts | 52 ++++++++++--------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/extensions/browser/src/browser/server-context.remote-profile-tab-ops.fallback.test.ts b/extensions/browser/src/browser/server-context.remote-profile-tab-ops.fallback.test.ts index d8252b2dc0a7..94f0c0d4b7ab 100644 --- a/extensions/browser/src/browser/server-context.remote-profile-tab-ops.fallback.test.ts +++ b/extensions/browser/src/browser/server-context.remote-profile-tab-ops.fallback.test.ts @@ -153,16 +153,15 @@ describe("browser remote profile fallback and attachOnly behavior", () => { const opened = await remote.openTab("https://example.com"); expect(opened.targetId).toBe("T_REMOTE"); - expect(createTargetViaCdp).toHaveBeenCalledWith( - expect.objectContaining({ - cdpUrl: "https://1.1.1.1:9222/chrome?token=abc", - url: "https://example.com", - timeouts: { - httpTimeoutMs: 4321, - handshakeTimeoutMs: 8765, - }, - }), - ); + expect(createTargetViaCdp).toHaveBeenCalledWith({ + cdpUrl: "https://1.1.1.1:9222/chrome?token=abc", + url: "https://example.com", + ssrfPolicy: { allowPrivateNetwork: true }, + timeouts: { + httpTimeoutMs: 4321, + handshakeTimeoutMs: 8765, + }, + }); }); it("uses remote-class tab-open timeouts for attachOnly loopback CDP profiles", async () => { @@ -195,15 +194,15 @@ describe("browser remote profile fallback and attachOnly behavior", () => { const opened = await ctx.forProfile("openclaw").openTab("https://example.com"); expect(opened.targetId).toBe("T_ATTACH"); - expect(createTargetViaCdp).toHaveBeenCalledWith( - expect.objectContaining({ - cdpUrl: "http://127.0.0.1:18800", - timeouts: { - httpTimeoutMs: 2345, - handshakeTimeoutMs: 6789, - }, - }), - ); + expect(createTargetViaCdp).toHaveBeenCalledWith({ + cdpUrl: "http://127.0.0.1:18800", + url: "https://example.com", + ssrfPolicy: undefined, + timeouts: { + httpTimeoutMs: 2345, + handshakeTimeoutMs: 6789, + }, + }); }); it("keeps managed loopback tab opens on local CDP defaults", async () => { @@ -265,12 +264,15 @@ describe("browser remote profile fallback and attachOnly behavior", () => { ); expect(Date.now() - startedAt).toBeLessThan(700); - expect(fetchMock).toHaveBeenCalledWith( - expect.stringContaining("/json/new"), - expect.objectContaining({ - method: "PUT", - signal: expect.any(AbortSignal), - }), + expect(fetchMock).toHaveBeenCalledTimes(1); + const [fetchUrl, fetchInit] = fetchMock.mock.calls[0] ?? []; + expect(String(fetchUrl)).toBe( + "https://1.1.1.1:9222/chrome/json/new?token=abc&url=https%3A%2F%2Fexample.com", ); + expect(fetchInit.method).toBe("PUT"); + expect(fetchInit.headers).toEqual({}); + expect(fetchInit.redirect).toBe("manual"); + expect(fetchInit.signal).toBeInstanceOf(AbortSignal); + expect(fetchInit.dispatcher).toBeDefined(); }); });