mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 06:00:43 +00:00
test(browser): cover tilde edge cases for executablePath (#71439)
* test(browser): cover tilde edge cases for executablePath
Adds coverage for cases the original tilde-expansion fix in 95a2c9b
intentionally supports but does not assert:
- bare "~" expands to the home directory
- Windows-style "~\AppData\..." expands to $HOME on Windows
- a stray "~" mid-path (e.g. /opt/~chromium/chrome) is preserved verbatim,
guarding the regex anchor against future regressions
No production code changes; tests only.
* test(browser): skip Windows-style ~\ tilde test on POSIX
path.resolve treats backslashes as literal characters on POSIX, so
"~\AppData\..." cannot resolve to "$HOME/AppData/..." on Linux/macOS.
Gate that case to win32 to keep the assertion meaningful.
This commit is contained in:
@@ -168,6 +168,39 @@ describe("browser config", () => {
|
||||
expect(resolved.executablePath).toBeUndefined();
|
||||
});
|
||||
|
||||
it("expands a bare ~ executablePath to the OS home directory", () => {
|
||||
const resolved = resolveBrowserConfig({
|
||||
executablePath: "~",
|
||||
});
|
||||
|
||||
expect(resolved.executablePath).toBe(path.resolve(os.homedir()));
|
||||
});
|
||||
|
||||
// Windows-only: on POSIX path.resolve treats `\` as a literal character,
|
||||
// so "~\foo" cannot resolve to "$HOME/foo". The helper's regex still matches
|
||||
// a leading `~\` on every platform; we only assert the resolved form where
|
||||
// the OS path module agrees.
|
||||
(process.platform === "win32" ? it : it.skip)(
|
||||
"expands a Windows-style ~\\ executablePath to the OS home directory",
|
||||
() => {
|
||||
const resolved = resolveBrowserConfig({
|
||||
executablePath: "~\\AppData\\Local\\Chromium\\chrome.exe",
|
||||
});
|
||||
|
||||
expect(resolved.executablePath).toBe(
|
||||
path.resolve(os.homedir(), "AppData/Local/Chromium/chrome.exe"),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
it("does not expand executablePath values where ~ is not the home prefix", () => {
|
||||
const resolved = resolveBrowserConfig({
|
||||
executablePath: "/opt/~chromium/chrome",
|
||||
});
|
||||
|
||||
expect(resolved.executablePath).toBe("/opt/~chromium/chrome");
|
||||
});
|
||||
|
||||
it("normalizes invalid browser tab cleanup numbers to defaults", () => {
|
||||
const resolved = resolveBrowserConfig({
|
||||
tabCleanup: {
|
||||
|
||||
Reference in New Issue
Block a user