|
1 | 1 | // Browser tests cover chromeefault browser plugin behavior. |
2 | | -import { beforeEach, describe, expect, it, vi } from "vitest"; |
| 2 | +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; |
3 | 3 |
|
4 | 4 | vi.mock("node:child_process", async () => { |
5 | 5 | const { mockNodeBuiltinModule } = await import("openclaw/plugin-sdk/test-node-mocks"); |
@@ -72,6 +72,10 @@ describe("browser default executable detection", () => { |
72 | 72 | vi.mocked(os.homedir).mockReturnValue("/Users/test"); |
73 | 73 | }); |
74 | 74 |
|
| 75 | + afterEach(() => { |
| 76 | + vi.unstubAllEnvs(); |
| 77 | + }); |
| 78 | + |
75 | 79 | it("prefers default Chromium browser on macOS", () => { |
76 | 80 | mockMacDefaultBrowser("com.google.Chrome", "/Applications/Google Chrome.app"); |
77 | 81 | mockChromeExecutableExists(); |
@@ -214,6 +218,25 @@ describe("browser default executable detection", () => { |
214 | 218 | expect(exe?.path.toLowerCase()).toMatch(/\\google\\chrome\\application\\chrome\.exe$/); |
215 | 219 | }); |
216 | 220 |
|
| 221 | + it("uses standard Windows install roots when ProgramFiles overrides are blank", () => { |
| 222 | + vi.stubEnv("ProgramFiles", " "); |
| 223 | + vi.stubEnv("ProgramFiles(x86)", ""); |
| 224 | + vi.mocked(fs.existsSync).mockImplementation( |
| 225 | + (candidate) => |
| 226 | + String(candidate) === "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe", |
| 227 | + ); |
| 228 | + |
| 229 | + expect( |
| 230 | + resolveBrowserExecutableForPlatform( |
| 231 | + {} as Parameters<typeof resolveBrowserExecutableForPlatform>[0], |
| 232 | + "win32", |
| 233 | + ), |
| 234 | + ).toEqual({ |
| 235 | + kind: "chrome", |
| 236 | + path: "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe", |
| 237 | + }); |
| 238 | + }); |
| 239 | + |
217 | 240 | it("canonicalizes an explicitly configured Opera launcher", () => { |
218 | 241 | const installDir = "C:\\Users\\test\\AppData\\Local\\Programs\\Opera"; |
219 | 242 | const launcher = `${installDir}\\launcher.exe`; |
|
0 commit comments