@@ -84,6 +84,8 @@ jest.mock("../../ignore/RooIgnoreController", () => ({
8484 } ,
8585} ) )
8686
87+ const MOCK_VIEW_COLUMN = 1
88+
8789describe ( "writeToFileTool" , ( ) => {
8890 // Test data
8991 const testFilePath = "test/file.txt"
@@ -141,6 +143,7 @@ describe("writeToFileTool", () => {
141143 finalContent : "final content" ,
142144 } ) ,
143145 scrollToFirstDiff : jest . fn ( ) ,
146+ resetWithListeners : jest . fn ( ) . mockResolvedValue ( undefined ) ,
144147 }
145148 mockCline . api = {
146149 getModel : jest . fn ( ) . mockReturnValue ( { id : "claude-3" } ) ,
@@ -152,6 +155,11 @@ describe("writeToFileTool", () => {
152155 mockCline . ask = jest . fn ( ) . mockResolvedValue ( undefined )
153156 mockCline . recordToolError = jest . fn ( )
154157 mockCline . sayAndCreateMissingParamError = jest . fn ( ) . mockResolvedValue ( "Missing param error" )
158+ mockCline . providerRef = {
159+ deref : jest . fn ( ) . mockReturnValue ( {
160+ getViewColumn : jest . fn ( ) . mockReturnValue ( MOCK_VIEW_COLUMN ) ,
161+ } ) ,
162+ }
155163
156164 mockAskApproval = jest . fn ( ) . mockResolvedValue ( true )
157165 mockHandleError = jest . fn ( ) . mockResolvedValue ( undefined )
@@ -211,7 +219,7 @@ describe("writeToFileTool", () => {
211219 await executeWriteFileTool ( { } , { accessAllowed : true } )
212220
213221 expect ( mockCline . rooIgnoreController . validateAccess ) . toHaveBeenCalledWith ( testFilePath )
214- expect ( mockCline . diffViewProvider . open ) . toHaveBeenCalledWith ( testFilePath )
222+ expect ( mockCline . diffViewProvider . open ) . toHaveBeenCalledWith ( testFilePath , MOCK_VIEW_COLUMN )
215223 } )
216224 } )
217225
@@ -286,7 +294,7 @@ describe("writeToFileTool", () => {
286294 await executeWriteFileTool ( { } , { fileExists : false } )
287295
288296 expect ( mockCline . consecutiveMistakeCount ) . toBe ( 0 )
289- expect ( mockCline . diffViewProvider . open ) . toHaveBeenCalledWith ( testFilePath )
297+ expect ( mockCline . diffViewProvider . open ) . toHaveBeenCalledWith ( testFilePath , MOCK_VIEW_COLUMN )
290298 expect ( mockCline . diffViewProvider . update ) . toHaveBeenCalledWith ( testContent , true )
291299 expect ( mockAskApproval ) . toHaveBeenCalled ( )
292300 expect ( mockCline . diffViewProvider . saveChanges ) . toHaveBeenCalled ( )
@@ -327,7 +335,7 @@ describe("writeToFileTool", () => {
327335 await executeWriteFileTool ( { } , { isPartial : true } )
328336
329337 expect ( mockCline . ask ) . toHaveBeenCalled ( )
330- expect ( mockCline . diffViewProvider . open ) . toHaveBeenCalledWith ( testFilePath )
338+ expect ( mockCline . diffViewProvider . open ) . toHaveBeenCalledWith ( testFilePath , MOCK_VIEW_COLUMN )
331339 expect ( mockCline . diffViewProvider . update ) . toHaveBeenCalledWith ( testContent , false )
332340 } )
333341 } )
@@ -365,7 +373,7 @@ describe("writeToFileTool", () => {
365373 await executeWriteFileTool ( { } )
366374
367375 expect ( mockHandleError ) . toHaveBeenCalledWith ( "writing file" , expect . any ( Error ) )
368- expect ( mockCline . diffViewProvider . reset ) . toHaveBeenCalled ( )
376+ expect ( mockCline . diffViewProvider . resetWithListeners ) . toHaveBeenCalled ( )
369377 } )
370378
371379 it ( "handles partial streaming errors" , async ( ) => {
@@ -374,7 +382,7 @@ describe("writeToFileTool", () => {
374382 await executeWriteFileTool ( { } , { isPartial : true } )
375383
376384 expect ( mockHandleError ) . toHaveBeenCalledWith ( "writing file" , expect . any ( Error ) )
377- expect ( mockCline . diffViewProvider . reset ) . toHaveBeenCalled ( )
385+ expect ( mockCline . diffViewProvider . resetWithListeners ) . toHaveBeenCalled ( )
378386 } )
379387 } )
380388} )
0 commit comments