@@ -14,6 +14,13 @@ vi.mock("../../prompts/responses", () => ({
1414 } ,
1515} ) )
1616
17+ vi . mock ( "../updateTodoListTool" , ( ) => ( {
18+ parseMarkdownChecklist : vi . fn ( ( md : string ) => [
19+ { id : "1" , content : "Test todo 1" , status : "pending" } ,
20+ { id : "2" , content : "Test todo 2" , status : "pending" } ,
21+ ] ) ,
22+ } ) )
23+
1724// Define a minimal type for the resolved value
1825type MockClineInstance = { taskId : string }
1926
@@ -72,6 +79,7 @@ describe("newTaskTool", () => {
7279 params : {
7380 mode : "code" ,
7481 message : "Review this: \\\\@file1.txt and also \\\\\\\\@file2.txt" , // Input with \\@ and \\\\@
82+ todos : "[ ] Test todo 1\n[ ] Test todo 2" ,
7583 } ,
7684 partial : false ,
7785 }
@@ -93,6 +101,12 @@ describe("newTaskTool", () => {
93101 "Review this: \\@file1.txt and also \\\\\\@file2.txt" , // Unit Test Expectation: \\@ -> \@, \\\\@ -> \\\\@
94102 undefined ,
95103 mockCline ,
104+ {
105+ initialTodos : [
106+ { id : "1" , content : "Test todo 1" , status : "pending" } ,
107+ { id : "2" , content : "Test todo 2" , status : "pending" } ,
108+ ] ,
109+ } ,
96110 )
97111
98112 // Verify side effects
@@ -109,6 +123,7 @@ describe("newTaskTool", () => {
109123 params : {
110124 mode : "code" ,
111125 message : "This is already unescaped: \\@file1.txt" ,
126+ todos : "[ ] Test todo" ,
112127 } ,
113128 partial : false ,
114129 }
@@ -126,6 +141,12 @@ describe("newTaskTool", () => {
126141 "This is already unescaped: \\@file1.txt" , // Expected: \@ remains \@
127142 undefined ,
128143 mockCline ,
144+ {
145+ initialTodos : [
146+ { id : "1" , content : "Test todo 1" , status : "pending" } ,
147+ { id : "2" , content : "Test todo 2" , status : "pending" } ,
148+ ] ,
149+ } ,
129150 )
130151 } )
131152
@@ -136,6 +157,7 @@ describe("newTaskTool", () => {
136157 params : {
137158 mode : "code" ,
138159 message : "A normal mention @file1.txt" ,
160+ todos : "[ ] Test todo" ,
139161 } ,
140162 partial : false ,
141163 }
@@ -153,6 +175,12 @@ describe("newTaskTool", () => {
153175 "A normal mention @file1.txt" , // Expected: @ remains @
154176 undefined ,
155177 mockCline ,
178+ {
179+ initialTodos : [
180+ { id : "1" , content : "Test todo 1" , status : "pending" } ,
181+ { id : "2" , content : "Test todo 2" , status : "pending" } ,
182+ ] ,
183+ } ,
156184 )
157185 } )
158186
@@ -163,6 +191,7 @@ describe("newTaskTool", () => {
163191 params : {
164192 mode : "code" ,
165193 message : "Mix: @file0.txt, \\@file1.txt, \\\\@file2.txt, \\\\\\\\@file3.txt" ,
194+ todos : "[ ] Test todo" ,
166195 } ,
167196 partial : false ,
168197 }
@@ -180,8 +209,41 @@ describe("newTaskTool", () => {
180209 "Mix: @file0.txt, \\@file1.txt, \\@file2.txt, \\\\\\@file3.txt" , // Unit Test Expectation: @->@, \@->\@, \\@->\@, \\\\@->\\\\@
181210 undefined ,
182211 mockCline ,
212+ {
213+ initialTodos : [
214+ { id : "1" , content : "Test todo 1" , status : "pending" } ,
215+ { id : "2" , content : "Test todo 2" , status : "pending" } ,
216+ ] ,
217+ } ,
183218 )
184219 } )
185220
221+ it ( "should handle missing todos parameter" , async ( ) => {
222+ const block : ToolUse = {
223+ type : "tool_use" ,
224+ name : "new_task" ,
225+ params : {
226+ mode : "code" ,
227+ message : "Test message" ,
228+ // todos is missing
229+ } ,
230+ partial : false ,
231+ }
232+
233+ await newTaskTool (
234+ mockCline as any ,
235+ block ,
236+ mockAskApproval ,
237+ mockHandleError ,
238+ mockPushToolResult ,
239+ mockRemoveClosingTag ,
240+ )
241+
242+ // Should call sayAndCreateMissingParamError for todos
243+ expect ( mockSayAndCreateMissingParamError ) . toHaveBeenCalledWith ( "new_task" , "todos" )
244+ expect ( mockCline . consecutiveMistakeCount ) . toBe ( 1 )
245+ expect ( mockCline . recordToolError ) . toHaveBeenCalledWith ( "new_task" )
246+ } )
247+
186248 // Add more tests for error handling (missing params, invalid mode, approval denied) if needed
187249} )
0 commit comments