browser: add Windows Chrome executable detection

This commit is contained in:
Mourad Boustani
2026-01-08 02:22:06 +01:00
committed by Peter Steinberger
parent 92a62bc300
commit 7294ba037d
2 changed files with 97 additions and 1 deletions

View File

@@ -8,6 +8,7 @@ import { afterEach, describe, expect, it, vi } from "vitest";
import {
decorateClawdProfile,
findChromeExecutableMac,
findChromeExecutableWindows,
isChromeReachable,
stopClawdChrome,
} from "./chrome.js";
@@ -155,6 +156,34 @@ describe("browser chrome helpers", () => {
exists.mockRestore();
});
it("picks the first existing Chrome candidate on Windows", () => {
const exists = vi
.spyOn(fs, "existsSync")
.mockImplementation((p) => String(p).includes("Chrome SxS"));
const exe = findChromeExecutableWindows();
expect(exe?.kind).toBe("canary");
expect(exe?.path).toMatch(/Chrome SxS/);
exists.mockRestore();
});
it("finds Chrome in Program Files on Windows", () => {
// Use path.join to match how the function builds paths (cross-platform)
const marker = path.join("Program Files", "Google", "Chrome");
const exists = vi
.spyOn(fs, "existsSync")
.mockImplementation((p) => String(p).includes(marker));
const exe = findChromeExecutableWindows();
expect(exe?.kind).toBe("chrome");
expect(exe?.path).toMatch(/chrome\.exe$/);
exists.mockRestore();
});
it("returns null when no Chrome candidate exists on Windows", () => {
const exists = vi.spyOn(fs, "existsSync").mockReturnValue(false);
expect(findChromeExecutableWindows()).toBeNull();
exists.mockRestore();
});
it("reports reachability based on /json/version", async () => {
vi.stubGlobal(
"fetch",