import { describe, expect, it } from "vitest"; import { buildExplorerCheckoutKey, resolveExplorerTabForCheckout, } from "@/stores/explorer-tab-memory"; describe("panel-store explorer tab resolution", () => { const serverId = "server-1"; const cwd = "/tmp/repo"; it("defaults to changes for git checkouts", () => { expect( resolveExplorerTabForCheckout({ serverId, cwd, isGit: true, explorerTabByCheckout: {}, }) ).toBe("changes"); }); it("defaults to files for non-git checkouts", () => { expect( resolveExplorerTabForCheckout({ serverId, cwd, isGit: false, explorerTabByCheckout: {}, }) ).toBe("files"); }); it("restores a stored files tab for git checkouts", () => { const key = buildExplorerCheckoutKey(serverId, cwd)!; expect( resolveExplorerTabForCheckout({ serverId, cwd, isGit: true, explorerTabByCheckout: { [key]: "files", }, }) ).toBe("files"); }); it("restores a stored terminals tab for git checkouts", () => { const key = buildExplorerCheckoutKey(serverId, cwd)!; expect( resolveExplorerTabForCheckout({ serverId, cwd, isGit: true, explorerTabByCheckout: { [key]: "terminals", }, }) ).toBe("terminals"); }); it("coerces stored changes to files for non-git checkouts", () => { const key = buildExplorerCheckoutKey(serverId, cwd)!; expect( resolveExplorerTabForCheckout({ serverId, cwd, isGit: false, explorerTabByCheckout: { [key]: "changes", }, }) ).toBe("files"); }); });