History

Default diffs to working changes (#3974)

Jake Leventhal committed 3 months ago

Commit 38e0bb01 parent 765e1b54 files · +47 −9Browse files

Showing the changes to apps/web/src/diffPanelStore.test.ts (1 of 4 files). Show all

Unified · Split

apps/web/src/diffPanelStore.test.ts+15−1
@@ -9,12 +9,26 @@ const THREAD_REF = scopeThreadRef(EnvironmentId.make("environment-1"), ThreadId. · 8 unmodified lines
99 describe("diffPanelStore", () => {
1010 beforeEach(() => useDiffPanelStore.setState({ byThreadKey: {}, branchBaseRefByThreadKey: {} }));
1111
12− it("defaults each thread to branch changes with automatic base selection", () => {
12+ it("defaults each thread to branch changes when the working tree is clean", () => {
1313 expect(
1414 selectThreadDiffPanelSelection(useDiffPanelStore.getState().byThreadKey, THREAD_REF),
1515 ).toEqual({ kind: "branch", baseRef: null });
1616 });
1717
18+ it("defaults each thread to working changes when the working tree is dirty", () => {
19+ expect(
20+ selectThreadDiffPanelSelection(useDiffPanelStore.getState().byThreadKey, THREAD_REF, true),
21+ ).toEqual({ kind: "unstaged" });
22+ });
23+
24+ it("preserves an explicit scope selection when the working tree state changes", () => {
25+ useDiffPanelStore.getState().selectGitScope(THREAD_REF, "branch");
26+
27+ expect(
28+ selectThreadDiffPanelSelection(useDiffPanelStore.getState().byThreadKey, THREAD_REF, true),
29+ ).toEqual({ kind: "branch", baseRef: null });
30+ });
31+
1832 it("clears incompatible selection fields when changing scopes", () => {
1933 const store = useDiffPanelStore.getState();
2034 store.selectTurn(THREAD_REF, TurnId.make("turn-1"), "src/app.ts");