browser: add Windows Chrome executable detection
This commit is contained in:
committed by
Peter Steinberger
parent
92a62bc300
commit
7294ba037d
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user