75 lines
1.7 KiB
TypeScript
75 lines
1.7 KiB
TypeScript
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("falls back to default when stored tab is invalid", () => {
|
|
const key = buildExplorerCheckoutKey(serverId, cwd)!;
|
|
expect(
|
|
resolveExplorerTabForCheckout({
|
|
serverId,
|
|
cwd,
|
|
isGit: true,
|
|
explorerTabByCheckout: {
|
|
[key]: "terminals" as any,
|
|
},
|
|
})
|
|
).toBe("changes");
|
|
});
|
|
|
|
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");
|
|
});
|
|
});
|