



























@@ -6,6 +6,7 @@ vi.hoisted(() => {
66});
7788import "./server-context.chrome-test-harness.js";
9+import { CDP_JSON_NEW_TIMEOUT_MS } from "./cdp-timeouts.js";
910import * as cdpHelpersModule from "./cdp.helpers.js";
1011import * as cdpModule from "./cdp.js";
1112import { InvalidBrowserNavigationUrlError } from "./navigation-guard.js";
@@ -36,13 +37,14 @@ function seedRunningProfileState(
36373738async function expectOldManagedTabClose(fetchMock: ReturnType<typeof vi.fn>): Promise<void> {
3839await vi.waitFor(() => {
39-expect(fetchMock).toHaveBeenCalledWith(
40-expect.stringContaining("/json/close/OLD1"),
41-expect.any(Object),
42-);
40+expect(fetchCallUrls(fetchMock).some((url) => url.includes("/json/close/OLD1"))).toBe(true);
4341});
4442}
454344+function fetchCallUrls(fetchMock: ReturnType<typeof vi.fn>): string[] {
45+return fetchMock.mock.calls.map(([url]) => String(url));
46+}
47+4648function createOldTabCleanupFetchMock(
4749existingTabs: ReturnType<typeof makeManagedTabsWithNew>,
4850params?: { rejectNewTabClose?: boolean },
@@ -192,10 +194,7 @@ describe("browser server-context tab selection state", () => {
192194const opened = await openManagedTabWithRunningProfile({ fetchMock });
193195expect(opened.targetId).toBe("NEW");
194196await expectOldManagedTabClose(fetchMock);
195-expect(fetchMock).not.toHaveBeenCalledWith(
196-expect.stringContaining("/json/close/NEW"),
197-expect.anything(),
198-);
197+expect(fetchCallUrls(fetchMock).some((url) => url.includes("/json/close/NEW"))).toBe(false);
199198});
200199201200it("does not fail tab open when managed-tab cleanup list fails", async () => {
@@ -253,10 +252,7 @@ describe("browser server-context tab selection state", () => {
253252254253const opened = await openclaw.openTab("http://127.0.0.1:3009");
255254expect(opened.targetId).toBe("NEW");
256-expect(fetchMock).not.toHaveBeenCalledWith(
257-expect.stringContaining("/json/close/"),
258-expect.anything(),
259-);
255+expect(fetchCallUrls(fetchMock).some((url) => url.includes("/json/close/"))).toBe(false);
260256});
261257262258it("does not block openTab on slow best-effort cleanup closes", async () => {
@@ -321,19 +317,18 @@ describe("browser server-context tab selection state", () => {
321317322318const opened = await openclaw.openTab("https://example.com");
323319expect(opened.targetId).toBe("NEW");
324-expect(fetchJson).toHaveBeenNthCalledWith(
325- 1,
326-expect.stringContaining("/json/new"),
327-expect.any(Number),
320+const jsonNewEndpoint = "http://127.0.0.1:18800/json/new?https%3A%2F%2Fexample.com";
321+expect(fetchJson.mock.calls[0]).toEqual([
322+jsonNewEndpoint,
323+CDP_JSON_NEW_TIMEOUT_MS,
328324{ method: "PUT" },
329325undefined,
330-);
331-expect(fetchJson).toHaveBeenNthCalledWith(
332-2,
333-expect.stringContaining("/json/new"),
334-expect.any(Number),
326+]);
327+expect(fetchJson.mock.calls[1]).toEqual([
328+jsonNewEndpoint,
329+CDP_JSON_NEW_TIMEOUT_MS,
335330undefined,
336331undefined,
337-);
332+]);
338333});
339334});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。