diff options
| author | Adam <[email protected]> | 2026-02-08 05:02:19 -0600 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-02-08 05:02:19 -0600 |
| commit | d1ebe0767c264d395c8bc504c0957ccc3af90103 (patch) | |
| tree | 4e10adf10def7a5ec731d1b33a6f21dbe67769f6 /packages/app/src/pages/layout/helpers.test.ts | |
| parent | 19b1222cd85060f7b0999b99586e93f84821b94b (diff) | |
| download | opencode-d1ebe0767c264d395c8bc504c0957ccc3af90103.tar.gz opencode-d1ebe0767c264d395c8bc504c0957ccc3af90103.zip | |
chore: refactoring and tests (#12629)
Diffstat (limited to 'packages/app/src/pages/layout/helpers.test.ts')
| -rw-r--r-- | packages/app/src/pages/layout/helpers.test.ts | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/packages/app/src/pages/layout/helpers.test.ts b/packages/app/src/pages/layout/helpers.test.ts index 8a8ea78c7..83d8f4748 100644 --- a/packages/app/src/pages/layout/helpers.test.ts +++ b/packages/app/src/pages/layout/helpers.test.ts @@ -12,6 +12,27 @@ describe("layout deep links", () => { expect(parseDeepLink("https://example.com")).toBeUndefined() }) + test("ignores malformed deep links safely", () => { + expect(() => parseDeepLink("opencode://open-project/%E0%A4%A%")).not.toThrow() + expect(parseDeepLink("opencode://open-project/%E0%A4%A%")).toBeUndefined() + }) + + test("parses links when URL.canParse is unavailable", () => { + const original = Object.getOwnPropertyDescriptor(URL, "canParse") + Object.defineProperty(URL, "canParse", { configurable: true, value: undefined }) + try { + expect(parseDeepLink("opencode://open-project?directory=/tmp/demo")).toBe("/tmp/demo") + } finally { + if (original) Object.defineProperty(URL, "canParse", original) + if (!original) Reflect.deleteProperty(URL, "canParse") + } + }) + + test("ignores open-project deep links without directory", () => { + expect(parseDeepLink("opencode://open-project")).toBeUndefined() + expect(parseDeepLink("opencode://open-project?directory=")).toBeUndefined() + }) + test("collects only valid open-project directories", () => { const result = collectOpenProjectDeepLinks([ "opencode://open-project?directory=/a", @@ -39,6 +60,14 @@ describe("layout workspace helpers", () => { expect(workspaceKey("C:\\tmp\\demo\\\\")).toBe("C:\\tmp\\demo") }) + test("preserves posix and drive roots in workspace key", () => { + expect(workspaceKey("/")).toBe("/") + expect(workspaceKey("///")).toBe("/") + expect(workspaceKey("C:\\")).toBe("C:\\") + expect(workspaceKey("C:\\\\\\")).toBe("C:\\") + expect(workspaceKey("C:///")).toBe("C:/") + }) + test("keeps local first while preserving known order", () => { const result = syncWorkspaceOrder("/root", ["/root", "/b", "/c"], ["/root", "/c", "/a", "/b"]) expect(result).toEqual(["/root", "/c", "/b"]) |
