mirror of
https://github.com/getpaseo/paseo.git
synced 2026-10-27 19:52:49 +00:00
* feat(git): default review to all branch changes Keep the selected comparison stable while agents edit and commit so reviewing the complete result does not require switching scopes or interrupt unfinished comments. * test(git): release Windows checkout handles during cleanup Allow transient filesystem handles from subscription teardown to close before removing the test repository.
47 lines
1.6 KiB
TypeScript
47 lines
1.6 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
resolveWorkingDiffComparisonFromState,
|
|
selectWorkingDiffComparisonInState,
|
|
type WorkingDiffComparisonState,
|
|
workingDiffComparisonKey,
|
|
} from "./state";
|
|
|
|
const checkout = { serverId: "server-1", workspaceId: "workspace-1", cwd: "/repo" };
|
|
|
|
function emptyState(): WorkingDiffComparisonState {
|
|
return { overrides: {} };
|
|
}
|
|
|
|
describe("working diff comparison", () => {
|
|
it("scopes selection to the workspace checkout rather than a panel", () => {
|
|
expect(workingDiffComparisonKey(checkout)).toBe(
|
|
"working-diff:server=server-1:workspace=workspace-1",
|
|
);
|
|
expect(workingDiffComparisonKey({ ...checkout, workspaceId: "workspace-2" })).not.toBe(
|
|
workingDiffComparisonKey(checkout),
|
|
);
|
|
expect(workingDiffComparisonKey({ ...checkout, workspaceId: null, cwd: "/repo/" })).toBe(
|
|
"working-diff:server=server-1:cwd=%2Frepo",
|
|
);
|
|
});
|
|
|
|
it.each([true, false])("defaults to All changes when checkout dirtiness is %s", (isDirty) => {
|
|
const status = { ...checkout, isDirty };
|
|
expect(resolveWorkingDiffComparisonFromState(emptyState(), status)).toBe("all");
|
|
});
|
|
|
|
it.each(["all", "base", "uncommitted"] as const)(
|
|
"keeps the selected %s comparison",
|
|
(comparison) => {
|
|
const selected = selectWorkingDiffComparisonInState(emptyState(), {
|
|
...checkout,
|
|
comparison,
|
|
});
|
|
expect(resolveWorkingDiffComparisonFromState(selected, checkout)).toBe(comparison);
|
|
expect(
|
|
resolveWorkingDiffComparisonFromState(selected, { ...checkout, workspaceId: "other" }),
|
|
).toBe("all");
|
|
},
|
|
);
|
|
});
|