mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 08:51:23 +00:00
test: add fetch mock helper and reaction coverage
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { withFetchPreconnect } from "../test-utils/fetch-mock.js";
|
||||
import type { BrowserServerState } from "./server-context.js";
|
||||
import "./server-context.chrome-test-harness.js";
|
||||
import { createBrowserRouteContext } from "./server-context.js";
|
||||
@@ -56,7 +57,7 @@ function stubChromeJsonList(responses: unknown[]) {
|
||||
} as unknown as Response;
|
||||
});
|
||||
|
||||
global.fetch = fetchMock;
|
||||
global.fetch = withFetchPreconnect(fetchMock);
|
||||
return fetchMock;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { withFetchPreconnect } from "../test-utils/fetch-mock.js";
|
||||
import * as cdpModule from "./cdp.js";
|
||||
import * as pwAiModule from "./pw-ai-module.js";
|
||||
import type { BrowserServerState } from "./server-context.js";
|
||||
@@ -70,7 +71,7 @@ describe("browser server-context remote profile tab operations", () => {
|
||||
throw new Error("unexpected fetch");
|
||||
});
|
||||
|
||||
global.fetch = fetchMock;
|
||||
global.fetch = withFetchPreconnect(fetchMock);
|
||||
|
||||
const state = makeState("remote");
|
||||
const ctx = createBrowserRouteContext({ getState: () => state });
|
||||
@@ -135,7 +136,7 @@ describe("browser server-context remote profile tab operations", () => {
|
||||
throw new Error("unexpected fetch");
|
||||
});
|
||||
|
||||
global.fetch = fetchMock;
|
||||
global.fetch = withFetchPreconnect(fetchMock);
|
||||
|
||||
const state = makeState("remote");
|
||||
const ctx = createBrowserRouteContext({ getState: () => state });
|
||||
@@ -162,7 +163,7 @@ describe("browser server-context remote profile tab operations", () => {
|
||||
throw new Error("unexpected fetch");
|
||||
});
|
||||
|
||||
global.fetch = fetchMock;
|
||||
global.fetch = withFetchPreconnect(fetchMock);
|
||||
|
||||
const state = makeState("remote");
|
||||
const ctx = createBrowserRouteContext({ getState: () => state });
|
||||
@@ -188,7 +189,7 @@ describe("browser server-context remote profile tab operations", () => {
|
||||
throw new Error("unexpected fetch");
|
||||
});
|
||||
|
||||
global.fetch = fetchMock;
|
||||
global.fetch = withFetchPreconnect(fetchMock);
|
||||
|
||||
const state = makeState("remote");
|
||||
const ctx = createBrowserRouteContext({ getState: () => state });
|
||||
@@ -220,7 +221,7 @@ describe("browser server-context remote profile tab operations", () => {
|
||||
} as unknown as Response;
|
||||
});
|
||||
|
||||
global.fetch = fetchMock;
|
||||
global.fetch = withFetchPreconnect(fetchMock);
|
||||
|
||||
const state = makeState("remote");
|
||||
const ctx = createBrowserRouteContext({ getState: () => state });
|
||||
@@ -255,7 +256,7 @@ describe("browser server-context tab selection state", () => {
|
||||
} as unknown as Response;
|
||||
});
|
||||
|
||||
global.fetch = fetchMock;
|
||||
global.fetch = withFetchPreconnect(fetchMock);
|
||||
|
||||
const state = makeState("openclaw");
|
||||
const ctx = createBrowserRouteContext({ getState: () => state });
|
||||
|
||||
Reference in New Issue
Block a user