Skip to content

Commit 487b56e

Browse files
committed
Add context tests across all SDK clients
- Node.js: Unskip context field test (runtime PR now merged) - Python: Add context assertions to existing list_sessions test - Go: Add context assertions to existing ListSessions test - .NET: Add new test for listing sessions with context
1 parent 6079c73 commit 487b56e

File tree

4 files changed

+41
-2
lines changed

4 files changed

+41
-2
lines changed

dotnet/test/SessionTests.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,30 @@ public async Task SendAndWait_Blocks_Until_Session_Idle_And_Returns_Final_Assist
369369
Assert.Contains("assistant.message", events);
370370
}
371371

372+
[Fact]
373+
public async Task Should_List_Sessions_With_Context()
374+
{
375+
var session = await Client.CreateSessionAsync();
376+
await session.SendAndWaitAsync(new MessageOptions { Prompt = "Say hello" });
377+
378+
await Task.Delay(200);
379+
380+
var sessions = await Client.ListSessionsAsync();
381+
Assert.NotEmpty(sessions);
382+
383+
var ourSession = sessions.Find(s => s.SessionId == session.SessionId);
384+
Assert.NotNull(ourSession);
385+
386+
// Verify context field
387+
foreach (var s in sessions)
388+
{
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+
}
393+
}
394+
}
395+
372396
[Fact]
373397
public async Task SendAndWait_Throws_On_Timeout()
374398
{

go/internal/e2e/session_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,15 @@ func TestSession(t *testing.T) {
812812
}
813813
// isRemote is a boolean, so it's always set
814814
}
815+
816+
// Verify context field is present on sessions
817+
for _, s := range sessions {
818+
if s.Context != nil {
819+
if s.Context.Cwd == "" {
820+
t.Error("Expected context.Cwd to be non-empty when context is present")
821+
}
822+
}
823+
}
815824
})
816825

817826
t.Run("should delete session", func(t *testing.T) {

nodejs/test/e2e/session.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ describe("Sessions", async () => {
2222
await expect(() => session.getMessages()).rejects.toThrow(/Session not found/);
2323
});
2424

25-
// TODO: Enable once github/copilot-agent-runtime#3006 is merged
26-
it.skip("should list sessions with context field", async () => {
25+
it("should list sessions with context field", async () => {
2726
// Create a new session
2827
const session = await client.createSession();
2928
expect(session.sessionId).toMatch(/^[a-f0-9-]+$/);

python/e2e/test_session.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,13 @@ async def test_should_list_sessions(self, ctx: E2ETestContext):
220220
assert isinstance(session_data.modifiedTime, str)
221221
assert isinstance(session_data.isRemote, bool)
222222

223+
# Verify context field is present
224+
for session_data in sessions:
225+
assert hasattr(session_data, "context")
226+
if session_data.context is not None:
227+
assert hasattr(session_data.context, "cwd")
228+
assert isinstance(session_data.context.cwd, str)
229+
223230
async def test_should_delete_session(self, ctx: E2ETestContext):
224231
import asyncio
225232

0 commit comments

Comments
 (0)