mirror of
https://github.com/backnotprop/plannotator.git
synced 2026-09-14 14:17:26 +08:00
69ef11bdfb
* feat(review): add jj support for local diffs * feat(review): add jj review workflows * fix(review): tighten jj diff defaults * test(review): add jj manual sandbox * fix(review): share jj agent diff prompts * fix(review): quote jj agent revsets * feat(review): share jj vcs handling with pi * fix(review): tighten jj bookmark and pi pr handling * fix(review): tighten jj defaults and detection * fix(review): harden jj diff and vcs detection --------- Co-authored-by: Michael Ramos <mdramos8@gmail.com>
49 lines
1.6 KiB
TypeScript
49 lines
1.6 KiB
TypeScript
import { describe, expect, test } from "bun:test";
|
|
import type { GitContext } from "@plannotator/shared/review-core";
|
|
import { resolveInitialDiffType } from "./vcs";
|
|
|
|
function context(overrides: Partial<GitContext>): GitContext {
|
|
return {
|
|
currentBranch: "feature",
|
|
defaultBranch: "main",
|
|
diffOptions: [
|
|
{ id: "uncommitted", label: "Uncommitted changes" },
|
|
{ id: "merge-base", label: "Committed changes" },
|
|
],
|
|
worktrees: [],
|
|
availableBranches: { local: [], remote: [] },
|
|
vcsType: "git",
|
|
...overrides,
|
|
};
|
|
}
|
|
|
|
describe("resolveInitialDiffType", () => {
|
|
test("preserves configured Git diff modes when available", () => {
|
|
expect(resolveInitialDiffType(context({}), "merge-base")).toBe("merge-base");
|
|
});
|
|
|
|
test("uses p4-default for P4 contexts", () => {
|
|
expect(resolveInitialDiffType(context({ vcsType: "p4" }), "merge-base")).toBe("p4-default");
|
|
});
|
|
|
|
test("ignores saved Git defaults for jj contexts", () => {
|
|
const jjContext = context({
|
|
defaultBranch: "trunk()",
|
|
diffOptions: [
|
|
{ id: "jj-current", label: "Current change" },
|
|
{ id: "jj-line", label: "Line of work" },
|
|
{ id: "jj-all", label: "All files" },
|
|
],
|
|
vcsType: "jj",
|
|
});
|
|
|
|
expect(resolveInitialDiffType(jjContext, "all")).toBe("jj-current");
|
|
expect(resolveInitialDiffType(jjContext, "merge-base")).toBe("jj-current");
|
|
expect(resolveInitialDiffType(jjContext, "unstaged")).toBe("jj-current");
|
|
});
|
|
|
|
test("falls back to the first available option for unknown non-jj modes", () => {
|
|
expect(resolveInitialDiffType(context({}), "jj-current")).toBe("uncommitted");
|
|
});
|
|
});
|