* feat(app): expose archive for every workspace Workspace actions now archive one workspace by id. The daemon remains responsible for backing-specific cleanup, including removing a managed worktree only after its final workspace is archived. * refactor(app): clarify archive descriptor name * fix(app): preserve workspace archive safety * fix(app): allow archive without upstream * refactor(app): remove stale archive callback * test(app): cover workspace archive ownership
76 lines
2.1 KiB
TypeScript
76 lines
2.1 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import {
|
|
buildWorktreeArchiveConfirmationMessage,
|
|
buildWorktreeArchiveRiskReasons,
|
|
toWorktreeArchiveRisk,
|
|
} from "@/git/worktree-archive-warning";
|
|
|
|
describe("workspace archive warning for worktree backing", () => {
|
|
it("does not require a confirmation for clean and pushed worktrees", () => {
|
|
expect(
|
|
buildWorktreeArchiveConfirmationMessage({
|
|
workspaceName: "feature",
|
|
isDirty: false,
|
|
aheadOfOrigin: 0,
|
|
diffStat: null,
|
|
}),
|
|
).toBeNull();
|
|
});
|
|
|
|
it("explains uncommitted line changes", () => {
|
|
expect(
|
|
buildWorktreeArchiveRiskReasons({
|
|
isDirty: true,
|
|
aheadOfOrigin: 0,
|
|
diffStat: { additions: 12, deletions: 1 },
|
|
}),
|
|
).toEqual(["Uncommitted changes (12 added lines, 1 deleted line)"]);
|
|
});
|
|
|
|
it("treats nonzero diff stats as dirty when dirty state is missing", () => {
|
|
expect(
|
|
buildWorktreeArchiveRiskReasons({
|
|
isDirty: undefined,
|
|
aheadOfOrigin: 0,
|
|
diffStat: { additions: 4, deletions: 0 },
|
|
}),
|
|
).toEqual(["Uncommitted changes (4 added lines)"]);
|
|
});
|
|
|
|
it("explains unpushed commits", () => {
|
|
expect(
|
|
buildWorktreeArchiveRiskReasons({
|
|
isDirty: false,
|
|
aheadOfOrigin: 2,
|
|
diffStat: null,
|
|
}),
|
|
).toEqual(["2 unpushed commits"]);
|
|
});
|
|
|
|
it("includes every archive risk in the confirmation copy", () => {
|
|
expect(
|
|
buildWorktreeArchiveConfirmationMessage({
|
|
workspaceName: "risky-feature",
|
|
isDirty: true,
|
|
aheadOfOrigin: 1,
|
|
diffStat: { additions: 1, deletions: 3 },
|
|
}),
|
|
).toBe("Uncommitted changes (1 added line, 3 deleted lines)\n1 unpushed commit");
|
|
});
|
|
|
|
it("maps archive workspace fields into the shared worktree risk shape", () => {
|
|
expect(
|
|
toWorktreeArchiveRisk({
|
|
archiveHasUncommittedChanges: true,
|
|
archiveUnpushedCommitCount: 3,
|
|
diffStat: { additions: 2, deletions: 1 },
|
|
}),
|
|
).toEqual({
|
|
isDirty: true,
|
|
aheadOfOrigin: 3,
|
|
diffStat: { additions: 2, deletions: 1 },
|
|
});
|
|
});
|
|
});
|