@@ -180,17 +180,22 @@ describe("useAgentLogs", () => {
180
180
act ( ( ) => publisherResult . current ?. publishMessage ( initialEvent ) ) ;
181
181
await waitFor ( ( ) => expect ( hookResult . current ) . toEqual ( initialLogs ) ) ;
182
182
183
- // Disable the hook
184
- rerender ( { agentId : MockWorkspaceAgent . id , enabled : false } ) ;
185
- await waitFor ( ( ) => expect ( hookResult . current ) . toHaveLength ( 0 ) ) ;
186
-
187
- // Re-enable the hook and send new logs
188
- rerender ( { agentId : MockWorkspaceAgent . id , enabled : true } ) ;
189
- const newLogs = generateMockLogs ( 3 , new Date ( "october 3, 2005" ) ) ;
190
- const newEvent = new MessageEvent < string > ( "message" , {
191
- data : JSON . stringify ( newLogs ) ,
192
- } ) ;
193
- act ( ( ) => publisherResult . current ?. publishMessage ( newEvent ) ) ;
194
- await waitFor ( ( ) => expect ( hookResult . current ) . toEqual ( newLogs ) ) ;
183
+ // Need to do the following steps multiple times to make sure that we
184
+ // don't break anything after the first disable
185
+ const mockDates : readonly string [ ] = [ "october 3, 2005" , "august 1, 2025" ] ;
186
+ for ( const md of mockDates ) {
187
+ // Disable the hook to clear current logs
188
+ rerender ( { agentId : MockWorkspaceAgent . id , enabled : false } ) ;
189
+ await waitFor ( ( ) => expect ( hookResult . current ) . toHaveLength ( 0 ) ) ;
190
+
191
+ // Re-enable the hook and send new logs
192
+ rerender ( { agentId : MockWorkspaceAgent . id , enabled : true } ) ;
193
+ const newLogs = generateMockLogs ( 3 , new Date ( md ) ) ;
194
+ const newEvent = new MessageEvent < string > ( "message" , {
195
+ data : JSON . stringify ( newLogs ) ,
196
+ } ) ;
197
+ act ( ( ) => publisherResult . current ?. publishMessage ( newEvent ) ) ;
198
+ await waitFor ( ( ) => expect ( hookResult . current ) . toEqual ( newLogs ) ) ;
199
+ }
195
200
} ) ;
196
201
} ) ;
0 commit comments