Skip to content

Commit d11e250

Browse files
test(write-to-file): run the edit-type decision on every platform the mutation run runs on
The two tests that name the edit type the existence probe installs were gated off on win32, and that gate belongs to their absolute-path assertion, not to the decision they name. The mocked harness already runs this branch on Windows in the directory-creation tests next door. Two tests are added, ungated, each naming the value it expects: modify for a target that exists, create for one that does not. Controls measured on this machine with the pinned interpreter: - replacing the modify literal at WriteToFileTool.ts:437 with the empty string fails installs modify as the edit type for a target that already exists (AssertionError: expected '' to be 'modify'), one test failed, five still skipped - replacing the create literal with the empty string fails installs create as the edit type for a target that does not exist yet (expected '' to be 'create'), one test failed, five still skipped - unmutated: 78 passed, 5 skipped prettier --check clean, eslint --max-warnings=0 clean with no suppression change, tsc --noEmit clean.
1 parent 89c1bd8 commit d11e250

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

‎src/core/tools/__tests__/writeToFileTool.spec.ts‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,25 @@ describe("writeToFileTool", () => {
294294
expect(mockCline.diffViewProvider.editType).toBe("create")
295295
})
296296

297+
// The two tests above are gated off on win32, and that gate belongs to their
298+
// absolute-path assertion, not to the decision they name: the mocked harness already
299+
// runs this same branch on Windows in the directory-creation tests below. These two
300+
// assert only the edit type the existence probe installs at WriteToFileTool.ts:437 -
301+
// modify for a target that exists, create for one that does not - so they run on
302+
// every platform a mutation run runs on, and each names the value it expects rather
303+
// than a weaker check that an empty-string mutant of either literal would satisfy.
304+
it("installs modify as the edit type for a target that already exists", async () => {
305+
await executeWriteFileTool({}, { fileExists: true })
306+
307+
expect(mockCline.diffViewProvider.editType).toBe("modify")
308+
})
309+
310+
it("installs create as the edit type for a target that does not exist yet", async () => {
311+
await executeWriteFileTool({}, { fileExists: false })
312+
313+
expect(mockCline.diffViewProvider.editType).toBe("create")
314+
})
315+
297316
it("uses cached editType without filesystem check", async () => {
298317
mockCline.diffViewProvider.editType = "modify"
299318

0 commit comments

Comments
 (0)