|
5 | 5 | deriveLocalBranchNameFromRemoteRef, |
6 | 6 | resolveEnvironmentOptionLabel, |
7 | 7 | resolveBranchSelectionTarget, |
| 8 | + resolveCurrentWorkspaceLabel, |
8 | 9 | resolveDraftEnvModeAfterBranchChange, |
| 10 | + resolveEffectiveEnvMode, |
9 | 11 | resolveEnvModeLabel, |
10 | 12 | resolveBranchToolbarValue, |
11 | 13 | shouldIncludeBranchPickerItem, |
@@ -116,13 +118,45 @@ describe("resolveEnvironmentOptionLabel", () => { |
116 | 118 | }); |
117 | 119 | }); |
118 | 120 |
|
| 121 | +describe("resolveEffectiveEnvMode", () => { |
| 122 | + it("treats draft threads already attached to a worktree as current-checkout mode", () => { |
| 123 | + expect( |
| 124 | + resolveEffectiveEnvMode({ |
| 125 | + activeWorktreePath: "/repo/.t3/worktrees/feature-a", |
| 126 | + hasServerThread: false, |
| 127 | + draftThreadEnvMode: "worktree", |
| 128 | + }), |
| 129 | + ).toBe("local"); |
| 130 | + }); |
| 131 | + |
| 132 | + it("keeps explicit new-worktree mode for draft threads without a worktree path", () => { |
| 133 | + expect( |
| 134 | + resolveEffectiveEnvMode({ |
| 135 | + activeWorktreePath: null, |
| 136 | + hasServerThread: false, |
| 137 | + draftThreadEnvMode: "worktree", |
| 138 | + }), |
| 139 | + ).toBe("worktree"); |
| 140 | + }); |
| 141 | +}); |
| 142 | + |
119 | 143 | describe("resolveEnvModeLabel", () => { |
120 | 144 | it("uses explicit workspace labels", () => { |
121 | 145 | expect(resolveEnvModeLabel("local")).toBe("Current checkout"); |
122 | 146 | expect(resolveEnvModeLabel("worktree")).toBe("New worktree"); |
123 | 147 | }); |
124 | 148 | }); |
125 | 149 |
|
| 150 | +describe("resolveCurrentWorkspaceLabel", () => { |
| 151 | + it("describes the main repo checkout when no worktree path is active", () => { |
| 152 | + expect(resolveCurrentWorkspaceLabel(null)).toBe("Current checkout"); |
| 153 | + }); |
| 154 | + |
| 155 | + it("describes the active checkout as a worktree when one is attached", () => { |
| 156 | + expect(resolveCurrentWorkspaceLabel("/repo/.t3/worktrees/feature-a")).toBe("Current worktree"); |
| 157 | + }); |
| 158 | +}); |
| 159 | + |
126 | 160 | describe("deriveLocalBranchNameFromRemoteRef", () => { |
127 | 161 | it("strips the remote prefix from a remote ref", () => { |
128 | 162 | expect(deriveLocalBranchNameFromRemoteRef("origin/feature/demo")).toBe("feature/demo"); |
|
0 commit comments