mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-12 09:41:11 +00:00
* 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)
57 lines
2.0 KiB
TypeScript
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",
|
|
);
|
|
});
|
|
});
|