@@ -401,31 +401,37 @@ describe("writeToFileTool", () => {
401401 } )
402402
403403 describe ( "parameter validation" , ( ) => {
404- it ( "errors and resets on missing path parameter" , async ( ) => {
404+ it ( "returns early without error on missing path parameter" , async ( ) => {
405405 await executeWriteFileTool ( { path : undefined } )
406406
407- expect ( mockCline . consecutiveMistakeCount ) . toBe ( 1 )
408- expect ( mockCline . recordToolError ) . toHaveBeenCalledWith ( "write_to_file" )
409- expect ( mockCline . sayAndCreateMissingParamError ) . toHaveBeenCalledWith ( "write_to_file" , "path" )
410- expect ( mockCline . diffViewProvider . reset ) . toHaveBeenCalled ( )
407+ // With the new behavior, it should return early without errors
408+ expect ( mockCline . consecutiveMistakeCount ) . toBe ( 0 )
409+ expect ( mockCline . recordToolError ) . not . toHaveBeenCalled ( )
410+ expect ( mockCline . sayAndCreateMissingParamError ) . not . toHaveBeenCalled ( )
411+ expect ( mockCline . diffViewProvider . reset ) . not . toHaveBeenCalled ( )
412+ expect ( mockCline . diffViewProvider . open ) . not . toHaveBeenCalled ( )
411413 } )
412414
413- it ( "errors and resets on empty path parameter" , async ( ) => {
415+ it ( "returns early without error on empty path parameter" , async ( ) => {
414416 await executeWriteFileTool ( { path : "" } )
415417
416- expect ( mockCline . consecutiveMistakeCount ) . toBe ( 1 )
417- expect ( mockCline . recordToolError ) . toHaveBeenCalledWith ( "write_to_file" )
418- expect ( mockCline . sayAndCreateMissingParamError ) . toHaveBeenCalledWith ( "write_to_file" , "path" )
419- expect ( mockCline . diffViewProvider . reset ) . toHaveBeenCalled ( )
418+ // Empty string is falsy in the context of !relPath check, so it returns early
419+ expect ( mockCline . consecutiveMistakeCount ) . toBe ( 0 )
420+ expect ( mockCline . recordToolError ) . not . toHaveBeenCalled ( )
421+ expect ( mockCline . sayAndCreateMissingParamError ) . not . toHaveBeenCalled ( )
422+ expect ( mockCline . diffViewProvider . reset ) . not . toHaveBeenCalled ( )
423+ expect ( mockCline . diffViewProvider . open ) . not . toHaveBeenCalled ( )
420424 } )
421425
422- it ( "errors and resets on missing content parameter" , async ( ) => {
426+ it ( "returns early without error on missing content parameter" , async ( ) => {
423427 await executeWriteFileTool ( { content : undefined } )
424428
425- expect ( mockCline . consecutiveMistakeCount ) . toBe ( 1 )
426- expect ( mockCline . recordToolError ) . toHaveBeenCalledWith ( "write_to_file" )
427- expect ( mockCline . sayAndCreateMissingParamError ) . toHaveBeenCalledWith ( "write_to_file" , "content" )
428- expect ( mockCline . diffViewProvider . reset ) . toHaveBeenCalled ( )
429+ // With the new behavior, it should return early without errors
430+ expect ( mockCline . consecutiveMistakeCount ) . toBe ( 0 )
431+ expect ( mockCline . recordToolError ) . not . toHaveBeenCalled ( )
432+ expect ( mockCline . sayAndCreateMissingParamError ) . not . toHaveBeenCalled ( )
433+ expect ( mockCline . diffViewProvider . reset ) . not . toHaveBeenCalled ( )
434+ expect ( mockCline . diffViewProvider . open ) . not . toHaveBeenCalled ( )
429435 } )
430436 } )
431437} )
0 commit comments