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
9describe("diffPanelStore", () => {9describe("diffPanelStore", () => {
10 beforeEach(() => useDiffPanelStore.setState({ byThreadKey: {}, branchBaseRefByThreadKey: {} }));10 beforeEach(() => useDiffPanelStore.setState({ byThreadKey: {}, branchBaseRefByThreadKey: {} }));
11 11
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", () => {
13 expect(13 expect(
14 selectThreadDiffPanelSelection(useDiffPanelStore.getState().byThreadKey, THREAD_REF),14 selectThreadDiffPanelSelection(useDiffPanelStore.getState().byThreadKey, THREAD_REF),
15 ).toEqual({ kind: "branch", baseRef: null });15 ).toEqual({ kind: "branch", baseRef: null });
16 });16 });
17 17
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
18 it("clears incompatible selection fields when changing scopes", () => {32 it("clears incompatible selection fields when changing scopes", () => {
19 const store = useDiffPanelStore.getState();33 const store = useDiffPanelStore.getState();
20 store.selectTurn(THREAD_REF, TurnId.make("turn-1"), "src/app.ts");34 store.selectTurn(THREAD_REF, TurnId.make("turn-1"), "src/app.ts");