Skip to content

Commit 4ca8b97

Browse files
test(write-to-file): assert the failed report by identity so the merged lint rule passes
The abortSubstringSelector that arrived on main in the fifteen commits this merge carries applies to every spec lane, and it rejects a bare abort substring inside a toThrow argument. The row that pins the rollback when the error report itself throws asserted rejects.toThrow("aborted"), the exact string the stubbed handleError rejected with, so it went red the moment main landed underneath it. A substring match would also pass on a raw SDK error that merely contains the word, which is what the rule is for. The row now asserts identity with the exact rejection the failing report produced, which is the stronger claim, and no suppression was added: the suppressed count for this file did not move and src/eslint-suppressions.json is byte-identical to the tree. Measured at this head with eslint 9.39.5 run from src with --prune-suppressions --max-warnings=0: exit 0 on the touched file. The four suites over this unit files pass with vitest 4.1.12: 201 passed, 5 skipped, 4 test files.
1 parent fbbf7bc commit 4ca8b97

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,9 +1033,14 @@ describe("writeToFileTool", () => {
10331033
// say() throws once the task is aborted, and handleError reports through it. The
10341034
// rollback and reset still have to run, or the diff view keeps unapproved content.
10351035
mockCline.diffViewProvider.saveChanges.mockRejectedValue(new Error("save failed"))
1036-
mockHandleError.mockRejectedValueOnce(new Error("aborted"))
1037-
1038-
await expect(executeWriteFileTool({})).rejects.toThrow("aborted")
1036+
// Asserted by identity to the exact rejection the failing report produced, not by a bare
1037+
// abort substring: a substring also matches a raw SDK error, which is what the
1038+
// abortSubstringSelector that arrived on main now rejects in every spec lane.
1039+
const reportFailure = new Error("aborted")
1040+
mockHandleError.mockRejectedValueOnce(reportFailure)
1041+
1042+
const surfaced = await executeWriteFileTool({}).catch((error: unknown) => error)
1043+
expect(surfaced).toBe(reportFailure)
10391044

10401045
expect(mockCline.diffViewProvider.revertChanges).toHaveBeenCalled()
10411046
expect(mockCline.diffViewProvider.reset).toHaveBeenCalled()

0 commit comments

Comments
 (0)