mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-05 22:32:12 +00:00
perf(browser): remove duplicate heavy test wrappers
This commit is contained in:
@@ -1,2 +0,0 @@
|
||||
import "./server-context.remote-profile-tab-ops.suite.js";
|
||||
import "./server-context.tab-selection-state.suite.js";
|
||||
@@ -1,4 +1,4 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
const controlServiceMocks = vi.hoisted(() => ({
|
||||
createBrowserControlContext: vi.fn(() => ({ control: true })),
|
||||
@@ -36,14 +36,18 @@ vi.mock("../core-api.js", async () => ({
|
||||
startBrowserControlServiceFromConfig: controlServiceMocks.startBrowserControlServiceFromConfig,
|
||||
}));
|
||||
|
||||
let resetBrowserProxyCommandStateForTests: typeof import("./invoke-browser.js").resetBrowserProxyCommandStateForTests;
|
||||
let runBrowserProxyCommand: typeof import("./invoke-browser.js").runBrowserProxyCommand;
|
||||
|
||||
beforeAll(async () => {
|
||||
({ resetBrowserProxyCommandStateForTests, runBrowserProxyCommand } =
|
||||
await import("./invoke-browser.js"));
|
||||
});
|
||||
|
||||
describe("runBrowserProxyCommand", () => {
|
||||
beforeEach(async () => {
|
||||
// No-isolate runs can reuse a cached invoke-browser module that was loaded
|
||||
// via node-host entrypoints before this file's mocks were declared.
|
||||
beforeEach(() => {
|
||||
vi.useRealTimers();
|
||||
vi.resetModules();
|
||||
resetBrowserProxyCommandStateForTests();
|
||||
dispatcherMocks.dispatch.mockReset();
|
||||
dispatcherMocks.createBrowserRouteDispatcher.mockReset().mockImplementation(() => ({
|
||||
dispatch: dispatcherMocks.dispatch,
|
||||
@@ -58,7 +62,6 @@ describe("runBrowserProxyCommand", () => {
|
||||
enabled: true,
|
||||
defaultProfile: "openclaw",
|
||||
});
|
||||
({ runBrowserProxyCommand } = await import("./invoke-browser.js"));
|
||||
configMocks.loadConfig.mockReturnValue({
|
||||
browser: {},
|
||||
nodeHost: { browserProxy: { enabled: true, allowProfiles: [] as string[] } },
|
||||
|
||||
@@ -51,6 +51,12 @@ function resolveBrowserProxyConfig() {
|
||||
|
||||
let browserControlReady: Promise<void> | null = null;
|
||||
|
||||
// Keep the production singleton but give tests a cheap reset seam so they do
|
||||
// not need to reload the entire module graph between cases.
|
||||
export function resetBrowserProxyCommandStateForTests(): void {
|
||||
browserControlReady = null;
|
||||
}
|
||||
|
||||
async function ensureBrowserControlService(): Promise<void> {
|
||||
if (browserControlReady) {
|
||||
return browserControlReady;
|
||||
|
||||
@@ -12,10 +12,6 @@
|
||||
"deltaKb": 2474639,
|
||||
"sources": ["checks-fast-extensions:2026-04-03"]
|
||||
},
|
||||
"extensions/browser/src/browser/server-context.remote-tab-ops.test.ts": {
|
||||
"deltaKb": 1855980,
|
||||
"sources": ["checks-fast-extensions:2026-04-03"]
|
||||
},
|
||||
"extensions/acpx/src/runtime.test.ts": {
|
||||
"deltaKb": 1824522,
|
||||
"sources": ["checks-fast-extensions:2026-04-03"]
|
||||
|
||||
Reference in New Issue
Block a user