Files
openclaw/extensions/browser/plugin-registration.node-host-laziness.test.ts
Dallin Romney d0091b001c fix(browser): isolate startup upload cleanup runtime (#126136)
* fix(browser): keep node-host cleanup lazy

* fix(browser): isolate upload cleanup runtime
2026-08-20 20:52:41 -07:00

28 lines
938 B
TypeScript

import { expect, it, vi } from "vitest";
const cleanupMocks = vi.hoisted(() => ({
ensureBrowserProxyUploadCleanup: vi.fn(async () => undefined),
}));
vi.mock("./register.runtime.js", () => {
throw new Error("node-host availability must not load the broad browser runtime");
});
vi.mock("./src/browser-proxy-upload-cleanup.runtime.js", () => ({
ensureBrowserProxyUploadCleanup: cleanupMocks.ensureBrowserProxyUploadCleanup,
}));
const { browserPluginNodeHostCommands } = await import("./plugin-registration.js");
it("starts node-host upload cleanup without loading the broad browser runtime", async () => {
const uploadCommand = browserPluginNodeHostCommands.find(
(command) => command.command === "browser.proxy.upload.v1",
);
uploadCommand?.watchAvailability?.({ config: {}, env: {} }, vi.fn());
await vi.waitFor(() => {
expect(cleanupMocks.ensureBrowserProxyUploadCleanup).toHaveBeenCalledOnce();
});
});