browser: add Windows Chrome executable detection

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

No files matched your search

+29
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",