Skip to content

Commit cf08ff7

Browse files
test(listFiles): assert consecutiveMistakeCount value on validation+error path
Addresses CodeRabbit review: the 'no reset on error' test never asserted the counter, so it would pass even if the reset behavior regressed. Renamed to reflect actual behavior (validation success resets to 0 before listFiles throws) and added the missing assertion. 40 tests pass.
1 parent 833b22f commit cf08ff7

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/core/tools/__tests__/listFilesTool.spec.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,16 +394,18 @@ describe("ListFilesTool", () => {
394394
expect(mockCallbacks.handleError).toHaveBeenCalledWith("listing files", error)
395395
})
396396

397-
it("should not reset consecutive mistake count on error", async () => {
397+
it("should reset consecutive mistake count after successful validation even when listing fails", async () => {
398398
mockTask.consecutiveMistakeCount = 2
399399
vi.mocked(listFiles).mockRejectedValue(new Error("fail"))
400400
const params = { path: "src", recursive: false }
401401

402402
await tool.execute(params, mockTask, mockCallbacks)
403403

404-
// The mistake count should NOT be reset since the error path doesn't reset it
405-
// Note: it may be reset before the error occurs since the validation passed
404+
// Validation passes (path is present), so the tool resets the count to 0 before
405+
// calling listFiles. listFiles then throws and is handled in the catch block,
406+
// which does not touch the count again — so it stays at 0, not the original 2.
406407
expect(mockCallbacks.handleError).toHaveBeenCalled()
408+
expect(mockTask.consecutiveMistakeCount).toBe(0)
407409
})
408410

409411
// ===== handlePartial tests =====

0 commit comments

Comments
 (0)