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, 03:37 UTC
| 1 | import { describe, expect, it } from "vite-plus/test"; |
| 2 | |
| 3 | import { resolveLinuxPasswordStoreSwitch } from "./linuxSecretStorage.ts"; |
| 4 | |
| 5 | const autoSwitch = (env: NodeJS.ProcessEnv) => |
| 6 | resolveLinuxPasswordStoreSwitch({ preference: "auto", env }); |
| 7 | |
| 8 | describe("linuxSecretStorage", () => { |
| 9 | it("leaves canonical KDE sessions to Electron's own wallet selection", () => { |
| 10 | expect(autoSwitch({ XDG_CURRENT_DESKTOP: "KDE" })).toBeNull(); |
| 11 | expect(autoSwitch({ XDG_CURRENT_DESKTOP: "KDE", KDE_SESSION_VERSION: "6" })).toBeNull(); |
| 12 | expect(autoSwitch({ XDG_CURRENT_DESKTOP: "KDE", KDE_SESSION_VERSION: "5" })).toBeNull(); |
| 13 | expect(autoSwitch({ XDG_CURRENT_DESKTOP: "KDE:plasma" })).toBeNull(); |
| 14 | }); |
| 15 | |
| 16 | it("recognizes a known desktop later in a colon-separated XDG_CURRENT_DESKTOP list", () => { |
| 17 | expect(autoSwitch({ XDG_CURRENT_DESKTOP: "niri:GNOME" })).toBeNull(); |
| 18 | expect(autoSwitch({ XDG_CURRENT_DESKTOP: "ubuntu:GNOME" })).toBeNull(); |
| 19 | }); |
| 20 | |
| 21 | it("forces gnome-libsecret for unrecognized Linux desktop sessions", () => { |
| 22 | expect(autoSwitch({ XDG_CURRENT_DESKTOP: "niri" })).toBe("gnome-libsecret"); |
| 23 | expect(autoSwitch({ XDG_CURRENT_DESKTOP: "Hyprland" })).toBe("gnome-libsecret"); |
| 24 | expect(autoSwitch({})).toBe("gnome-libsecret"); |
| 25 | }); |
| 26 | |
| 27 | it("forces gnome-libsecret for desktops Electron recognizes but leaves on basic text", () => { |
| 28 | expect(autoSwitch({ XDG_CURRENT_DESKTOP: "LXQt" })).toBe("gnome-libsecret"); |
| 29 | expect(autoSwitch({ XDG_CURRENT_DESKTOP: "LXQt:GNOME" })).toBe("gnome-libsecret"); |
| 30 | expect(autoSwitch({ XDG_CURRENT_DESKTOP: "LXQt:KDE" })).toBe("gnome-libsecret"); |
| 31 | expect(autoSwitch({ XDG_CURRENT_DESKTOP: "LXQt:plasma" })).toBe("gnome-libsecret"); |
| 32 | }); |
| 33 | |
| 34 | it("does not treat lowercase desktop names as ones Electron recognizes", () => { |
| 35 | expect(autoSwitch({ XDG_CURRENT_DESKTOP: "gnome" })).toBe("gnome-libsecret"); |
| 36 | expect(autoSwitch({ XDG_CURRENT_DESKTOP: "xfce" })).toBe("gnome-libsecret"); |
| 37 | expect(autoSwitch({ XDG_CURRENT_DESKTOP: "kde", KDE_SESSION_VERSION: "6" })).toBe( |
| 38 | "gnome-libsecret", |
| 39 | ); |
| 40 | }); |
| 41 | |
| 42 | it("overrides KDE sessions identified only by legacy variables", () => { |
| 43 | expect(autoSwitch({ XDG_CURRENT_DESKTOP: "plasma" })).toBe("gnome-libsecret"); |
| 44 | for (const session of [ |
| 45 | "kde", |
| 46 | "kde-plasma", |
| 47 | "kde4", |
| 48 | "plasma", |
| 49 | "plasmawayland", |
| 50 | "plasmawayland-dev", |
| 51 | "plasmax11", |
| 52 | "plasmax11-dev", |
| 53 | ]) { |
| 54 | expect(autoSwitch({ DESKTOP_SESSION: session })).toBe("gnome-libsecret"); |
| 55 | expect(autoSwitch({ XDG_SESSION_DESKTOP: session })).toBe("gnome-libsecret"); |
| 56 | expect(autoSwitch({ GDMSESSION: session })).toBe("gnome-libsecret"); |
| 57 | } |
| 58 | expect(autoSwitch({ DESKTOP_SESSION: "kde", KDE_SESSION_VERSION: "6" })).toBe( |
| 59 | "gnome-libsecret", |
| 60 | ); |
| 61 | expect(autoSwitch({ KDE_SESSION_VERSION: "6" })).toBe("gnome-libsecret"); |
| 62 | expect(autoSwitch({ KDE_FULL_SESSION: "true", KDE_SESSION_VERSION: "6" })).toBe( |
| 63 | "gnome-libsecret", |
| 64 | ); |
| 65 | }); |
| 66 | |
| 67 | it("ignores stale session hints when XDG_CURRENT_DESKTOP is authoritative", () => { |
| 68 | expect( |
| 69 | autoSwitch({ XDG_CURRENT_DESKTOP: "niri", DESKTOP_SESSION: "gnome", GDMSESSION: "gnome" }), |
| 70 | ).toBe("gnome-libsecret"); |
| 71 | expect(autoSwitch({ XDG_CURRENT_DESKTOP: "niri", KDE_SESSION_VERSION: "6" })).toBe( |
| 72 | "gnome-libsecret", |
| 73 | ); |
| 74 | expect(autoSwitch({ XDG_CURRENT_DESKTOP: "niri", XDG_SESSION_DESKTOP: "GNOME" })).toBe( |
| 75 | "gnome-libsecret", |
| 76 | ); |
| 77 | expect(autoSwitch({ XDG_CURRENT_DESKTOP: "niri:plasma" })).toBe("gnome-libsecret"); |
| 78 | expect( |
| 79 | autoSwitch({ |
| 80 | XDG_CURRENT_DESKTOP: "Hyprland", |
| 81 | XDG_SESSION_DESKTOP: "KDE", |
| 82 | KDE_SESSION_VERSION: "6", |
| 83 | }), |
| 84 | ).toBe("gnome-libsecret"); |
| 85 | }); |
| 86 | }); |