@@ -107,21 +107,31 @@ describe('ChatView', () => {
107107 }
108108
109109 describe ( 'Streaming State' , ( ) => {
110- it ( 'should show cancel button while streaming' , ( ) => {
110+ it ( 'should show cancel button while streaming and trigger cancel on click' , async ( ) => {
111111 mockState . clineMessages = [
112112 {
113- type : 'say' ,
113+ type : 'say' ,
114+ say : 'task' ,
115+ ts : Date . now ( ) ,
116+ } ,
117+ {
118+ type : 'say' ,
119+ say : 'text' ,
114120 partial : true ,
115121 ts : Date . now ( ) ,
116122 }
117123 ]
118124 renderChatView ( )
119125
120- const buttons = screen . queryAllByRole ( 'button' )
121- expect ( buttons . length ) . toBeGreaterThan ( 0 )
126+ const cancelButton = screen . getByText ( 'Cancel' )
127+ await userEvent . click ( cancelButton )
128+
129+ expect ( vscode . postMessage ) . toHaveBeenCalledWith ( {
130+ type : 'cancelTask'
131+ } )
122132 } )
123133
124- it ( 'should show terminate button when task is paused' , ( ) => {
134+ it ( 'should show terminate button when task is paused and trigger terminate on click' , async ( ) => {
125135 mockState . clineMessages = [
126136 {
127137 type : 'ask' ,
@@ -131,22 +141,31 @@ describe('ChatView', () => {
131141 ]
132142 renderChatView ( )
133143
134- const buttons = screen . queryAllByRole ( 'button' )
135- expect ( buttons . length ) . toBeGreaterThan ( 0 )
144+ const terminateButton = screen . getByText ( 'Terminate' )
145+ await userEvent . click ( terminateButton )
146+
147+ expect ( vscode . postMessage ) . toHaveBeenCalledWith ( {
148+ type : 'clearTask'
149+ } )
136150 } )
137151
138- it ( 'should show retry button when API error occurs' , ( ) => {
152+ it ( 'should show retry button when API error occurs and trigger retry on click' , async ( ) => {
139153 mockState . clineMessages = [
140154 {
141- type : 'say ' ,
142- say : 'error ' ,
155+ type : 'ask ' ,
156+ ask : 'api_req_failed ' ,
143157 ts : Date . now ( ) ,
144158 }
145159 ]
146160 renderChatView ( )
147161
148- const buttons = screen . queryAllByRole ( 'button' )
149- expect ( buttons . length ) . toBeGreaterThan ( 0 )
162+ const retryButton = screen . getByText ( 'Retry' )
163+ await userEvent . click ( retryButton )
164+
165+ expect ( vscode . postMessage ) . toHaveBeenCalledWith ( {
166+ type : 'askResponse' ,
167+ askResponse : 'yesButtonClicked'
168+ } )
150169 } )
151170 } )
152171} )
0 commit comments