Files
openclaw/src/plugin-sdk/browser-host-inspection.test.ts
Josh Avant 33ad806a14 Browser: consolidate duplicate helper surfaces via facade delegation (#63957)
* Plugin SDK: route browser helper surfaces through browser facade

* Browser doctor flow: add facade path regression and export parity guards

* Contracts: dedupe browser facade parity checks without reducing coverage

* Browser tests: restore host-inspection semantics coverage in extension

* fix: add changelog note for browser facade consolidation (#63957) (thanks @joshavant)
2026-04-09 19:49:04 -05:00

57 lines
2.0 KiB
TypeScript

import { beforeEach, describe, expect, it, vi } from "vitest";
const loadBundledPluginPublicSurfaceModuleSync = vi.hoisted(() => vi.fn());
vi.mock("./facade-loader.js", () => ({
loadBundledPluginPublicSurfaceModuleSync,
}));
describe("browser host inspection", () => {
beforeEach(() => {
loadBundledPluginPublicSurfaceModuleSync.mockReset();
});
it("delegates browser host inspection helpers through the browser facade", async () => {
const resolveGoogleChromeExecutableForPlatform = vi.fn().mockReturnValue({
kind: "canary",
path: "/usr/bin/google-chrome-beta",
});
const readBrowserVersion = vi.fn().mockReturnValue("Google Chrome 144.0.7534.0");
const parseBrowserMajorVersion = vi.fn().mockReturnValue(144);
loadBundledPluginPublicSurfaceModuleSync.mockReturnValue({
resolveGoogleChromeExecutableForPlatform,
readBrowserVersion,
parseBrowserMajorVersion,
});
const hostInspection = await import("./browser-host-inspection.js");
expect(hostInspection.resolveGoogleChromeExecutableForPlatform("linux")).toEqual({
kind: "canary",
path: "/usr/bin/google-chrome-beta",
});
expect(hostInspection.readBrowserVersion("/usr/bin/google-chrome-beta")).toBe(
"Google Chrome 144.0.7534.0",
);
expect(hostInspection.parseBrowserMajorVersion("Google Chrome 144.0.7534.0")).toBe(144);
expect(loadBundledPluginPublicSurfaceModuleSync).toHaveBeenCalledWith({
dirName: "browser",
artifactBasename: "browser-host-inspection.js",
});
});
it("hard-fails when browser host inspection facade is unavailable", async () => {
loadBundledPluginPublicSurfaceModuleSync.mockImplementation(() => {
throw new Error("missing browser host inspection facade");
});
const hostInspection = await import("./browser-host-inspection.js");
expect(() => hostInspection.resolveGoogleChromeExecutableForPlatform("linux")).toThrow(
"missing browser host inspection facade",
);
});
});