The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 1 | import { describe, expect, it } from "vite-plus/test"; |
| 2 | |
| 3 | import type { SidebarProjectSnapshot } from "../../sidebarProjectGrouping"; |
| 4 | import { |
| 5 | selectEnvironmentAxis, |
| 6 | selectProjectAxis, |
| 7 | settingsScopeCheckoutChoices, |
| 8 | settingsScopeCheckoutLabel, |
| 9 | } from "./settingsScopeAxis"; |
| 10 | |
| 11 | const member = (environmentId: string, physicalProjectKey: string, workspaceRoot = "") => |
| 12 | ({ |
| 13 | environmentId, |
| 14 | physicalProjectKey, |
| 15 | workspaceRoot, |
| 16 | }) as SidebarProjectSnapshot["memberProjects"][number]; |
| 17 | const group = (...memberProjects: SidebarProjectSnapshot["memberProjects"]) => |
| 18 | ({ memberProjects }) as SidebarProjectSnapshot; |
| 19 | |
| 20 | describe("settings scope axes", () => { |
| 21 | it("drops a checkout narrowing from older links when either axis changes", () => { |
| 22 | const checkout = { project: "app", checkout: "app@first", machine: "first" }; |
| 23 | expect(selectEnvironmentAxis(checkout, "second")).toEqual({ |
| 24 | project: "app", |
| 25 | machine: "second", |
| 26 | }); |
| 27 | expect(selectProjectAxis(checkout, "app")).toEqual({ project: "app", machine: "first" }); |
| 28 | }); |
| 29 | |
| 30 | it("offers checkouts only where an environment cannot tell them apart", () => { |
| 31 | const a = member("laptop", "a"); |
| 32 | const b = member("laptop", "b"); |
| 33 | const c = member("server", "c"); |
| 34 | |
| 35 | expect(settingsScopeCheckoutChoices(group(a, b, c), { machine: "laptop" })).toEqual([a, b]); |
| 36 | expect(settingsScopeCheckoutChoices(group(a, b), {})).toEqual([a, b]); |
| 37 | expect(settingsScopeCheckoutChoices(group(a, b, c), { checkout: "b" })).toEqual([a, b]); |
| 38 | expect(settingsScopeCheckoutChoices(group(a, b, c), {})).toEqual([]); |
| 39 | expect(settingsScopeCheckoutChoices(group(a, b, c), { machine: "server" })).toEqual([]); |
| 40 | }); |
| 41 | |
| 42 | it("labels a checkout by its full path only when its folder name repeats", () => { |
| 43 | const first = member("laptop", "a", "/work/one/app"); |
| 44 | const second = member("laptop", "b", "C:\\work\\two\\app"); |
| 45 | const other = member("laptop", "c", "/work/tools"); |
| 46 | |
| 47 | expect(settingsScopeCheckoutLabel(second, [first, second, other])).toBe("C:\\work\\two\\app"); |
| 48 | expect(settingsScopeCheckoutLabel(other, [first, second, other])).toBe("tools"); |
| 49 | }); |
| 50 | }); |