Skip to content

Commit a1d9d24

Browse files
test(write-to-file): stream the preview before asserting the denial cleanup
One review row on #2434 read against head 725b8a3: - writeToFileTool.spec.ts:1133 (Trivial, Maintainability & Code Quality): hasPathStabilized ForTask() records the path on the first delta and only stabilises on the second matching one, so the rooignore-denial test was checking discardUnapprovedStream and reset against a diff view that was never opened. Send a second matching delta first, assert open() and update() ran, and pin the streamed preview before the denial cleanup in call order. Gates run in this worktree against this commit: - pnpm --dir src exec vitest run core/tools/__tests__/writeToFileTool.spec.ts -> 1 test file passed, 79 tests passed, 5 skipped. - pnpm --dir src exec eslint --max-warnings=0 core/tools/__tests__/writeToFileTool.spec.ts -> clean. - pnpm --dir src exec prettier --write/--check on the same file -> clean. - src/eslint-suppressions.json untouched. Not run here: knip, compile, e2e-mock, platform-unit-test matrices, mutation-diff, codecov. No mutant was executed against this suite locally by this lane.
1 parent 725b8a3 commit a1d9d24

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,12 +1130,23 @@ describe("writeToFileTool", () => {
11301130
// content into it. This branch reported the denial and released the stream state, but
11311131
// never touched the diff view: the unapproved content sat in a saveable editor, and the
11321132
// provider kept this call's editType/relPath for whatever write came next.
1133+
// The first delta only records the path in hasPathStabilizedForTask(); it takes a second matching
1134+
// delta before open()/update() run. Without a streamed preview this test would check cleanup calls
1135+
// against a diff view that was never opened, so stream it first and pin its order before the denial.
11331136
await executeWriteFileTool({}, { isPartial: true })
1137+
await executeWriteFileTool({}, { isPartial: true })
1138+
1139+
expect(mockCline.diffViewProvider.open).toHaveBeenCalled()
1140+
expect(mockCline.diffViewProvider.update).toHaveBeenCalled()
11341141

11351142
await executeWriteFileTool({}, { accessAllowed: false })
11361143

11371144
expect(mockCline.say).toHaveBeenCalledWith("rooignore_error", testFilePath)
11381145
expect(mockCline.diffViewProvider.discardUnapprovedStream).toHaveBeenCalledTimes(1)
1146+
// The streamed preview above is what the denial cleanup has to run after.
1147+
expect(mockCline.diffViewProvider.open.mock.invocationCallOrder[0]).toBeLessThan(
1148+
mockCline.diffViewProvider.discardUnapprovedStream.mock.invocationCallOrder[0],
1149+
)
11391150
expect(mockCline.diffViewProvider.discardUnapprovedStream.mock.invocationCallOrder[0]).toBeLessThan(
11401151
mockCline.diffViewProvider.reset.mock.invocationCallOrder[0],
11411152
)

0 commit comments

Comments
 (0)