| ... | ... | @@ -8,6 +8,7 @@ import { |
| 8 | 8 | GitRunStackedActionResult, |
| 9 | 9 | GitRunStackedActionInput, |
| 10 | 10 | GitResolvePullRequestResult, |
| 11 | VcsStatusLocalResult, |
| 11 | 12 | } from "./git.ts"; |
| 12 | 13 | |
| 13 | 14 | const decodeCreateWorktreeInput = Schema.decodeUnknownSync(VcsCreateWorktreeInput); |
| ... | ... | @@ -20,6 +21,7 @@ const decodePreparePullRequestThreadResult = Schema.decodeUnknownSync( |
| 20 | 21 | const decodeRunStackedActionInput = Schema.decodeUnknownSync(GitRunStackedActionInput); |
| 21 | 22 | const decodeRunStackedActionResult = Schema.decodeUnknownSync(GitRunStackedActionResult); |
| 22 | 23 | const decodeResolvePullRequestResult = Schema.decodeUnknownSync(GitResolvePullRequestResult); |
| 24 | const decodeVcsStatusLocalResult = Schema.decodeUnknownSync(VcsStatusLocalResult); |
| 23 | 25 | |
| 24 | 26 | describe("VcsCreateWorktreeInput", () => { |
| 25 | 27 | it("accepts omitted newRefName for existing-refName worktrees", () => { |
| ... | ... | @@ -125,6 +127,70 @@ describe("GitRunStackedActionInput", () => { |
| 125 | 127 | expect(parsed.actionId).toBe("action-1"); |
| 126 | 128 | expect(parsed.action).toBe("create_pr"); |
| 127 | 129 | }); |
| 130 | |
| 131 | it("preserves leading and trailing whitespace in file paths", () => { |
| 132 | const parsed = decodeRunStackedActionInput({ |
| 133 | actionId: "action-1", |
| 134 | cwd: "/repo", |
| 135 | action: "commit", |
| 136 | filePaths: [" leading.txt", "trailing.txt "], |
| 137 | }); |
| 138 | |
| 139 | expect(parsed.filePaths).toEqual([" leading.txt", "trailing.txt "]); |
| 140 | }); |
| 141 | |
| 142 | it("rejects an empty file path", () => { |
| 143 | expect(() => |
| 144 | decodeRunStackedActionInput({ |
| 145 | actionId: "action-1", |
| 146 | cwd: "/repo", |
| 147 | action: "commit", |
| 148 | filePaths: [""], |
| 149 | }), |
| 150 | ).toThrow(); |
| 151 | }); |
| 152 | }); |
| 153 | |
| 154 | describe("VcsStatusLocalResult", () => { |
| 155 | it("preserves leading and trailing whitespace in working-tree paths", () => { |
| 156 | const parsed = decodeVcsStatusLocalResult({ |
| 157 | isRepo: true, |
| 158 | hasPrimaryRemote: true, |
| 159 | isDefaultRef: false, |
| 160 | refName: "main", |
| 161 | hasWorkingTreeChanges: true, |
| 162 | workingTree: { |
| 163 | files: [ |
| 164 | { path: " leading.txt", insertions: 1, deletions: 0 }, |
| 165 | { path: "trailing.txt ", insertions: 0, deletions: 1 }, |
| 166 | ], |
| 167 | insertions: 1, |
| 168 | deletions: 1, |
| 169 | }, |
| 170 | }); |
| 171 | |
| 172 | expect(parsed.workingTree.files.map((file) => file.path)).toEqual([ |
| 173 | " leading.txt", |
| 174 | "trailing.txt ", |
| 175 | ]); |
| 176 | }); |
| 177 | |
| 178 | it("rejects an empty working-tree path", () => { |
| 179 | expect(() => |
| 180 | decodeVcsStatusLocalResult({ |
| 181 | isRepo: true, |
| 182 | hasPrimaryRemote: true, |
| 183 | isDefaultRef: false, |
| 184 | refName: "main", |
| 185 | hasWorkingTreeChanges: true, |
| 186 | workingTree: { |
| 187 | files: [{ path: "", insertions: 0, deletions: 0 }], |
| 188 | insertions: 0, |
| 189 | deletions: 0, |
| 190 | }, |
| 191 | }), |
| 192 | ).toThrow(); |
| 193 | }); |
| 128 | 194 | }); |
| 129 | 195 | |
| 130 | 196 | describe("GitRunStackedActionResult", () => { |