mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 08:27:39 +00:00
refactor(browser): share chrome resolution helpers
This commit is contained in:
@@ -10,6 +10,7 @@ import {
|
||||
findChromeExecutableMac,
|
||||
findChromeExecutableWindows,
|
||||
isChromeReachable,
|
||||
resolveBrowserExecutableForPlatform,
|
||||
stopClawdChrome,
|
||||
} from "./chrome.js";
|
||||
import {
|
||||
@@ -185,6 +186,29 @@ describe("browser chrome helpers", () => {
|
||||
exists.mockRestore();
|
||||
});
|
||||
|
||||
it("resolves Windows executables without LOCALAPPDATA", () => {
|
||||
vi.stubEnv("LOCALAPPDATA", "");
|
||||
vi.stubEnv("ProgramFiles", "C:\\Program Files");
|
||||
vi.stubEnv("ProgramFiles(x86)", "C:\\Program Files (x86)");
|
||||
const marker = path.win32.join(
|
||||
"Program Files",
|
||||
"Google",
|
||||
"Chrome",
|
||||
"Application",
|
||||
"chrome.exe",
|
||||
);
|
||||
const exists = vi
|
||||
.spyOn(fs, "existsSync")
|
||||
.mockImplementation((p) => String(p).includes(marker));
|
||||
const exe = resolveBrowserExecutableForPlatform(
|
||||
{} as Parameters<typeof resolveBrowserExecutableForPlatform>[0],
|
||||
"win32",
|
||||
);
|
||||
expect(exe?.kind).toBe("chrome");
|
||||
expect(exe?.path).toMatch(/chrome\.exe$/);
|
||||
exists.mockRestore();
|
||||
});
|
||||
|
||||
it("reports reachability based on /json/version", async () => {
|
||||
vi.stubGlobal(
|
||||
"fetch",
|
||||
|
||||
Reference in New Issue
Block a user