Skip to content

Commit aaac89c

Browse files
Address PR review feedback
- Remove unused 'answer' variable in Python streaming fidelity test - Add onTestFinished cleanup for newClient in Node.js streaming resume test - Remove streaming tests from Node.js session.test.ts (were still referencing deleted session/ snapshots) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 3c6e73f commit aaac89c

3 files changed

Lines changed: 5 additions & 60 deletions

File tree

nodejs/test/e2e/session.test.ts

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -296,56 +296,6 @@ describe("Sessions", async () => {
296296
expect(answer?.data.content).toContain("4");
297297
});
298298

299-
it("should receive streaming delta events when streaming is enabled", async () => {
300-
const session = await client.createSession({
301-
onPermissionRequest: approveAll,
302-
streaming: true,
303-
});
304-
305-
const deltaContents: string[] = [];
306-
let _finalMessage: string | undefined;
307-
308-
// Set up event listener before sending
309-
const unsubscribe = session.on((event) => {
310-
if (event.type === "assistant.message_delta") {
311-
const delta = (event.data as { deltaContent?: string }).deltaContent;
312-
if (delta) {
313-
deltaContents.push(delta);
314-
}
315-
} else if (event.type === "assistant.message") {
316-
_finalMessage = event.data.content;
317-
}
318-
});
319-
320-
const assistantMessage = await session.sendAndWait({ prompt: "What is 2+2?" });
321-
322-
unsubscribe();
323-
324-
// Should have received delta events
325-
expect(deltaContents.length).toBeGreaterThan(0);
326-
327-
// Accumulated deltas should equal the final message
328-
const accumulated = deltaContents.join("");
329-
expect(accumulated).toBe(assistantMessage?.data.content);
330-
331-
// Final message should contain the answer
332-
expect(assistantMessage?.data.content).toContain("4");
333-
});
334-
335-
it("should pass streaming option to session creation", async () => {
336-
// Verify that the streaming option is accepted without errors
337-
const session = await client.createSession({
338-
onPermissionRequest: approveAll,
339-
streaming: true,
340-
});
341-
342-
expect(session.sessionId).toMatch(/^[a-f0-9-]+$/);
343-
344-
// Session should still work normally
345-
const assistantMessage = await session.sendAndWait({ prompt: "What is 1+1?" });
346-
expect(assistantMessage?.data.content).toContain("2");
347-
});
348-
349299
it("should receive session events", async () => {
350300
const session = await client.createSession({ onPermissionRequest: approveAll });
351301
const receivedEvents: Array<{ type: string }> = [];

nodejs/test/e2e/streaming_fidelity.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Copyright (c) Microsoft Corporation. All rights reserved.
33
*--------------------------------------------------------------------------------------------*/
44

5-
import { describe, expect, it } from "vitest";
5+
import { describe, expect, it, onTestFinished } from "vitest";
66
import { CopilotClient, SessionEvent, approveAll } from "../../src/index.js";
77
import { createSdkTestContext, isCI } from "./harness/sdkTestContext";
88

@@ -85,6 +85,7 @@ describe("Streaming Fidelity", async () => {
8585
env,
8686
githubToken: isCI ? "fake-token-for-e2e-tests" : undefined,
8787
});
88+
onTestFinished(() => newClient.forceStop());
8889
const session2 = await newClient.resumeSession(session.sessionId, {
8990
onPermissionRequest: approveAll,
9091
streaming: true,

python/e2e/test_streaming_fidelity.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,15 @@
1212

1313

1414
class TestStreamingFidelity:
15-
async def test_should_produce_delta_events_when_streaming_is_enabled(
16-
self, ctx: E2ETestContext
17-
):
15+
async def test_should_produce_delta_events_when_streaming_is_enabled(self, ctx: E2ETestContext):
1816
session = await ctx.client.create_session(
1917
{"streaming": True, "on_permission_request": PermissionHandler.approve_all}
2018
)
2119

2220
events = []
2321
session.on(lambda event: events.append(event))
2422

25-
answer = await session.send_and_wait(
26-
{"prompt": "Count from 1 to 5, separated by commas."}
27-
)
23+
await session.send_and_wait({"prompt": "Count from 1 to 5, separated by commas."})
2824

2925
types = [e.type.value for e in events]
3026

@@ -48,9 +44,7 @@ async def test_should_produce_delta_events_when_streaming_is_enabled(
4844

4945
await session.destroy()
5046

51-
async def test_should_not_produce_deltas_when_streaming_is_disabled(
52-
self, ctx: E2ETestContext
53-
):
47+
async def test_should_not_produce_deltas_when_streaming_is_disabled(self, ctx: E2ETestContext):
5448
session = await ctx.client.create_session(
5549
{"streaming": False, "on_permission_request": PermissionHandler.approve_all}
5650
)

0 commit comments

Comments
 (0)