Skip to content

Commit 0db82c1

Browse files
committed
Fix context tests: persist session before listing
- Node.js: Send message and add delay before listing sessions - .NET: Increase delay, check context only on our session
1 parent db80664 commit 0db82c1

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

dotnet/test/SessionTests.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -375,21 +375,18 @@ public async Task Should_List_Sessions_With_Context()
375375
var session = await Client.CreateSessionAsync();
376376
await session.SendAndWaitAsync(new MessageOptions { Prompt = "Say hello" });
377377

378-
await Task.Delay(200);
378+
await Task.Delay(500);
379379

380380
var sessions = await Client.ListSessionsAsync();
381381
Assert.NotEmpty(sessions);
382382

383383
var ourSession = sessions.Find(s => s.SessionId == session.SessionId);
384384
Assert.NotNull(ourSession);
385385

386-
// Verify context field
387-
foreach (var s in sessions)
386+
// Context may be present on sessions that have been persisted with workspace.yaml
387+
if (ourSession.Context != null)
388388
{
389-
if (s.Context != null)
390-
{
391-
Assert.False(string.IsNullOrEmpty(s.Context.Cwd), "Expected context.Cwd to be non-empty when context is present");
392-
}
389+
Assert.False(string.IsNullOrEmpty(ourSession.Context.Cwd), "Expected context.Cwd to be non-empty when context is present");
393390
}
394391
}
395392

nodejs/test/e2e/session.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,13 @@ describe("Sessions", async () => {
2323
});
2424

2525
it("should list sessions with context field", async () => {
26-
// Create a new session
26+
// Create a new session and send a message to persist it
2727
const session = await client.createSession();
2828
expect(session.sessionId).toMatch(/^[a-f0-9-]+$/);
29+
await session.sendAndWait({ prompt: "Say hello" });
30+
31+
// Small delay to ensure session file is written to disk
32+
await new Promise((resolve) => setTimeout(resolve, 200));
2933

3034
// List sessions and find the one we just created
3135
const sessions = await client.listSessions();

0 commit comments

Comments
 (0)