Skip to content

Commit 6536140

Browse files
Fix Phase I/E/L test failures surfaced by CI
- commands/multi-client/ui_elicitation: shorthand 'copilotClientOptions: { tcpConnectionToken }' wasn't matched by the earlier batch rewrite, so client1 was still spawned in stdio mode while client2 tried to connect by URI. Switch the harness call to TCP + RuntimeConnection.forTcp({ connectionToken: tcpConnectionToken }). - session_fs.e2e.test.ts: add the missing RuntimeConnection import. - hooks_extended.e2e.test.ts: SessionStart and UserPromptSubmitted timestamp assertions still used toBeGreaterThan(0) but BaseHookInput.timestamp is now Date. Switch to toBeInstanceOf(Date). - client.test.ts: delete the two obsolete 'allows *Session without onPermissionRequest' unit tests. They asserted on the 'Client not connected' error that only occurred when autoStart was false; with Phase C removing autoStart, the client now auto-starts on the first session call and those tests would need a real spawned runtime. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 09dada7 commit 6536140

6 files changed

Lines changed: 15 additions & 18 deletions

File tree

nodejs/test/client.test.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,6 @@ import { defaultJoinSessionPermissionHandler } from "../src/types.js";
77
// This file is for unit tests. Where relevant, prefer to add e2e tests in e2e/*.test.ts instead
88

99
describe("CopilotClient", () => {
10-
it("allows createSession without onPermissionRequest", async () => {
11-
const client = new CopilotClient({});
12-
13-
await expect(client.createSession({})).rejects.toThrow(/Client not connected/);
14-
});
15-
16-
it("allows resumeSession without onPermissionRequest", async () => {
17-
const client = new CopilotClient({});
18-
19-
await expect(client.resumeSession("session-1", {})).rejects.toThrow(/Client not connected/);
20-
});
21-
2210
it("does not respond to v3 permission requests when handler returns no-result", async () => {
2311
const session = new CopilotSession("session-1", {} as any);
2412
session.registerPermissionHandler(() => ({ kind: "no-result" }));

nodejs/test/e2e/commands.e2e.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ describe("Commands", async () => {
1111
// Use TCP mode so a second client can connect to the same CLI process
1212
const tcpConnectionToken = "commands-test-token";
1313
const ctx = await createSdkTestContext({
14-
copilotClientOptions: { tcpConnectionToken },
14+
useStdio: false,
15+
copilotClientOptions: {
16+
connection: RuntimeConnection.forTcp({ connectionToken: tcpConnectionToken }),
17+
},
1518
});
1619
const client1 = ctx.copilotClient;
1720

nodejs/test/e2e/hooks_extended.e2e.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe("Extended session hooks", async () => {
3737

3838
expect(sessionStartInputs.length).toBeGreaterThan(0);
3939
expect(sessionStartInputs[0].source).toBe("new");
40-
expect(sessionStartInputs[0].timestamp).toBeGreaterThan(0);
40+
expect(sessionStartInputs[0].timestamp).toBeInstanceOf(Date);
4141
expect(sessionStartInputs[0].cwd).toBeDefined();
4242

4343
await session.disconnect();
@@ -62,7 +62,7 @@ describe("Extended session hooks", async () => {
6262

6363
expect(userPromptInputs.length).toBeGreaterThan(0);
6464
expect(userPromptInputs[0].prompt).toContain("Say hello");
65-
expect(userPromptInputs[0].timestamp).toBeGreaterThan(0);
65+
expect(userPromptInputs[0].timestamp).toBeInstanceOf(Date);
6666
expect(userPromptInputs[0].cwd).toBeDefined();
6767

6868
await session.disconnect();

nodejs/test/e2e/multi-client.e2e.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ describe("Multi-client broadcast", async () => {
1212
// Use TCP mode so a second client can connect to the same CLI process
1313
const tcpConnectionToken = "multi-client-test-token";
1414
const ctx = await createSdkTestContext({
15-
copilotClientOptions: { tcpConnectionToken },
15+
useStdio: false,
16+
copilotClientOptions: {
17+
connection: RuntimeConnection.forTcp({ connectionToken: tcpConnectionToken }),
18+
},
1619
});
1720
const client1 = ctx.copilotClient;
1821

nodejs/test/e2e/session_fs.e2e.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { tmpdir } from "os";
99
import { join } from "path";
1010
import { describe, expect, it, onTestFinished } from "vitest";
1111
import { CopilotClient } from "../../src/client.js";
12-
import { createSessionFsAdapter } from "../../src/index.js";
12+
import { createSessionFsAdapter, RuntimeConnection } from "../../src/index.js";
1313
import type { SessionFsReaddirWithTypesEntry } from "../../src/generated/rpc.js";
1414
import {
1515
approveAll,

nodejs/test/e2e/ui_elicitation.e2e.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ describe("UI Elicitation Multi-Client Capabilities", async () => {
5555
// Use TCP mode so a second client can connect to the same CLI process
5656
const tcpConnectionToken = "ui-elicitation-test-token";
5757
const ctx = await createSdkTestContext({
58-
copilotClientOptions: { tcpConnectionToken },
58+
useStdio: false,
59+
copilotClientOptions: {
60+
connection: RuntimeConnection.forTcp({ connectionToken: tcpConnectionToken }),
61+
},
5962
});
6063
const client1 = ctx.copilotClient;
6164

0 commit comments

Comments
 (0)