test(browser): cover tilde edge cases for executablePath (#71439) · openclaw/openclaw@bc2d53d
Quratulain-b
·
2026-04-25
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -168,6 +168,39 @@ describe("browser config", () => {
|
168 | 168 | expect(resolved.executablePath).toBeUndefined(); |
169 | 169 | }); |
170 | 170 | |
| 171 | +it("expands a bare ~ executablePath to the OS home directory", () => { |
| 172 | +const resolved = resolveBrowserConfig({ |
| 173 | +executablePath: "~", |
| 174 | +}); |
| 175 | + |
| 176 | +expect(resolved.executablePath).toBe(path.resolve(os.homedir())); |
| 177 | +}); |
| 178 | + |
| 179 | +// Windows-only: on POSIX path.resolve treats `\` as a literal character, |
| 180 | +// so "~\foo" cannot resolve to "$HOME/foo". The helper's regex still matches |
| 181 | +// a leading `~\` on every platform; we only assert the resolved form where |
| 182 | +// the OS path module agrees. |
| 183 | +(process.platform === "win32" ? it : it.skip)( |
| 184 | +"expands a Windows-style ~\\ executablePath to the OS home directory", |
| 185 | +() => { |
| 186 | +const resolved = resolveBrowserConfig({ |
| 187 | +executablePath: "~\\AppData\\Local\\Chromium\\chrome.exe", |
| 188 | +}); |
| 189 | + |
| 190 | +expect(resolved.executablePath).toBe( |
| 191 | +path.resolve(os.homedir(), "AppData/Local/Chromium/chrome.exe"), |
| 192 | +); |
| 193 | +}, |
| 194 | +); |
| 195 | + |
| 196 | +it("does not expand executablePath values where ~ is not the home prefix", () => { |
| 197 | +const resolved = resolveBrowserConfig({ |
| 198 | +executablePath: "/opt/~chromium/chrome", |
| 199 | +}); |
| 200 | + |
| 201 | +expect(resolved.executablePath).toBe("/opt/~chromium/chrome"); |
| 202 | +}); |
| 203 | + |
171 | 204 | it("normalizes invalid browser tab cleanup numbers to defaults", () => { |
172 | 205 | const resolved = resolveBrowserConfig({ |
173 | 206 | tabCleanup: { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。