perf(browser): remove duplicate heavy test wrappers

This commit is contained in:
Vincent Koc
2026-04-03 18:55:47 +09:00
parent 355dc7f3a8
commit 2bfbddb81f
4 changed files with 15 additions and 12 deletions

View File

@@ -1,2 +0,0 @@
import "./server-context.remote-profile-tab-ops.suite.js";
import "./server-context.tab-selection-state.suite.js";

View File

@@ -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[] } },

View File

@@ -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;

View File

@@ -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"]