Skip to content

Commit 6b821b2

Browse files
committed
test(registry): assert read content in the token-failure regression tests
CodeRabbit review (2026-09-14): the two version-token-failure tests only asserted the pushed path, so a regression that discards file content would still pass. Both tests now assert the content as well — and the legacy test additionally points the readWithSlice mock at the legacy content, since the legacy path slices the raw read through it and the mock's default would otherwise mask what was actually read.
1 parent 988f1e2 commit 6b821b2

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1580,9 +1580,11 @@ describe("ReadFileTool", () => {
15801580
// Cast: the mock task only implements the members ReadFileTool.execute touches.
15811581
await readFileTool.execute({ path: "existing.ts" }, mockTask as unknown as Task, callbacks)
15821582

1583-
// The read itself succeeded: no failure flag and the result carries the file.
1583+
// The read itself succeeded: no failure flag and the result carries the file
1584+
// and its content (not just the path).
15841585
expect(mockTask.didToolFailInCurrentTurn).toBe(false)
15851586
expect(callbacks.pushToolResult).toHaveBeenCalledWith(expect.stringContaining("existing.ts"))
1587+
expect(callbacks.pushToolResult).toHaveBeenCalledWith(expect.stringContaining("content"))
15861588

15871589
// The failed token lookup never observes: the registry stays empty.
15881590
expect(mockTask.observationRegistry!.size).toBe(0)
@@ -1609,6 +1611,15 @@ describe("ReadFileTool", () => {
16091611
mockedFsStat.mockRejectedValueOnce(new Error("EACCES"))
16101612
mockedIsBinaryFile.mockResolvedValue(false)
16111613
mockedFsReadFile.mockResolvedValue("legacy content")
1614+
// The legacy path slices the raw content through readWithSlice, so the slice
1615+
// mock must carry the legacy content for the result assertion below.
1616+
mockedReadWithSlice.mockReturnValue({
1617+
content: "1 | legacy content",
1618+
returnedLines: 1,
1619+
totalLines: 1,
1620+
wasTruncated: false,
1621+
includedRanges: [[1, 1]],
1622+
})
16121623

16131624
// Typed legacy (pre-refactor) params: the multi-file format with the
16141625
// _legacyFormat discriminant (see LegacyReadFileParams).
@@ -1620,9 +1631,11 @@ describe("ReadFileTool", () => {
16201631
// Cast: the mock task only implements the members ReadFileTool.execute touches.
16211632
await readFileTool.execute(legacyParams, mockTask as unknown as Task, callbacks)
16221633

1623-
// The legacy read succeeded: no failure flag and the result carries the file.
1634+
// The legacy read succeeded: no failure flag and the result carries the file
1635+
// and its content (not just the path).
16241636
expect(mockTask.didToolFailInCurrentTurn).toBe(false)
16251637
expect(callbacks.pushToolResult).toHaveBeenCalledWith(expect.stringContaining("legacy.ts"))
1638+
expect(callbacks.pushToolResult).toHaveBeenCalledWith(expect.stringContaining("legacy content"))
16261639

16271640
// The failed token lookup never observes: the registry stays empty.
16281641
expect(mockTask.observationRegistry!.size).toBe(0)

0 commit comments

Comments
 (0)