Skip to content

Commit 3ac7ae8

Browse files
Add E2E equivalents of removed createSession/resumeSession-without-permission tests
The two client.test.ts unit tests deleted in the previous commit only asserted that createSession/resumeSession surface 'Client not connected' when called pre-start. The intent behind them was to confirm that omitting onPermissionRequest doesn't itself throw. With autoStart gone, the only meaningful version of that test is an E2E one that actually spawns a runtime. Port the equivalent C# coverage (ClientE2ETests.Should_Allow_*Session_Called_Without_PermissionHandler) to client.e2e.test.ts so we have parity. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 6536140 commit 3ac7ae8

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

nodejs/test/e2e/client.e2e.test.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,44 @@ function onTestFinishedForceStop(client: CopilotClient) {
1313
}
1414

1515
describe("Client", () => {
16+
it.each([
17+
{ transport: "stdio", connection: () => undefined },
18+
{ transport: "tcp", connection: () => RuntimeConnection.forTcp() },
19+
])("allows createSession without onPermissionRequest ($transport)", async ({ connection }) => {
20+
const client = new CopilotClient({ connection: connection() });
21+
onTestFinishedForceStop(client);
22+
23+
await using const session = await client.createSession({});
24+
expect(session.sessionId).toMatch(/^[a-f0-9-]+$/);
25+
});
26+
27+
it("allows resumeSession without onPermissionRequest", async () => {
28+
const connectionToken = "client-e2e-resume-token";
29+
30+
const client = new CopilotClient({
31+
connection: RuntimeConnection.forTcp({ connectionToken }),
32+
});
33+
onTestFinishedForceStop(client);
34+
35+
await using const originalSession = await client.createSession({});
36+
37+
const port = (client as unknown as { runtimePort: number | null }).runtimePort;
38+
if (port == null) {
39+
throw new Error("Client must be using TCP transport to support multi-client resume.");
40+
}
41+
42+
const resumeClient = new CopilotClient({
43+
connection: RuntimeConnection.forUri(`localhost:${port}`, { connectionToken }),
44+
});
45+
onTestFinishedForceStop(resumeClient);
46+
47+
await using const resumedSession = await resumeClient.resumeSession(
48+
originalSession.sessionId,
49+
{}
50+
);
51+
expect(resumedSession.sessionId).toBe(originalSession.sessionId);
52+
});
53+
1654
it("should start and connect to server using stdio", async () => {
1755
const client = new CopilotClient();
1856
onTestFinishedForceStop(client);

0 commit comments

Comments
 (0)