test: pin browser fallback calls

This commit is contained in:
Shakker
2026-05-11 14:32:36 +01:00
parent c8c1f46da1
commit 6f3fd2410c
@@ -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();
});
});