@@ -517,23 +517,30 @@ void testListSessions() throws Exception {
517517 ctx .configureForTest ("session" , "should_list_sessions" );
518518
519519 try (CopilotClient client = ctx .createClient ()) {
520- // Create a session and send messages
521- CopilotSession session = client .createSession ().get ();
522- session .sendAndWait (new MessageOptions ().setPrompt ("Say hello" )).get (60 , TimeUnit .SECONDS );
523- session .sendAndWait (new MessageOptions ().setPrompt ("Say goodbye" )).get (60 , TimeUnit .SECONDS );
520+ // Create two sessions and send one message to each (matches snapshot format)
521+ CopilotSession session1 = client .createSession ().get ();
522+ session1 .sendAndWait (new MessageOptions ().setPrompt ("Say hello" )).get (60 , TimeUnit .SECONDS );
523+
524+ CopilotSession session2 = client .createSession ().get ();
525+ session2 .sendAndWait (new MessageOptions ().setPrompt ("Say goodbye" )).get (60 , TimeUnit .SECONDS );
526+
527+ // Small delay to ensure session files are written to disk
528+ Thread .sleep (200 );
524529
525530 // List all sessions
526531 var sessions = client .listSessions ().get (30 , TimeUnit .SECONDS );
527532
528- // Should have at least the session we created
533+ // Should have at least the sessions we created
529534 assertNotNull (sessions );
530535 assertFalse (sessions .isEmpty (), "Should have at least 1 session" );
531536
532- // Our session should be in the list
533- boolean foundSession = sessions .stream ().anyMatch (s -> s .getSessionId ().equals (session .getSessionId ()));
534- assertTrue (foundSession , "Our session should be in the list" );
537+ // Our sessions should be in the list
538+ var sessionIds = sessions .stream ().map (s -> s .getSessionId ()).toList ();
539+ assertTrue (sessionIds .contains (session1 .getSessionId ()), "Session 1 should be in the list" );
540+ assertTrue (sessionIds .contains (session2 .getSessionId ()), "Session 2 should be in the list" );
535541
536- session .close ();
542+ session1 .close ();
543+ session2 .close ();
537544 }
538545 }
539546
0 commit comments