-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathgithub_telemetry.e2e.test.ts
More file actions
57 lines (48 loc) · 2.43 KB
/
Copy pathgithub_telemetry.e2e.test.ts
File metadata and controls
57 lines (48 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------------------------------------------*/
import { describe, expect, it } from "vitest";
import { approveAll, GitHubTelemetryNotification } from "../../src/index.js";
import { createSdkTestContext } from "./harness/sdkTestContext.js";
import { waitForCondition } from "./harness/sdkTestHelper.js";
// Experimental: exercises the end-to-end GitHub (hydro) telemetry forwarding
// path. The runtime forwards per-session telemetry to opted-in connections via
// the `gitHubTelemetry.event` JSON-RPC *notification*; the SDK opts in
// automatically whenever an `onGitHubTelemetry` handler is registered. Creating
// a session emits an early `session.start` hydro event, so no model round-trip
// (and therefore no recorded CAPI exchange) is needed to observe forwarding.
describe("GitHub telemetry forwarding", async () => {
const received: GitHubTelemetryNotification[] = [];
const { copilotClient: client } = await createSdkTestContext({
copilotClientOptions: {
onGitHubTelemetry: (notification) => {
received.push(notification);
},
},
});
it(
"forwards gitHubTelemetry.event notifications from a live session",
{ timeout: 60_000 },
async () => {
received.length = 0;
const session = await client.createSession({
onPermissionRequest: approveAll,
});
// The CLI forwards telemetry over the JSON-RPC connection
// asynchronously, so wait until at least one event arrives or we
// time out.
await waitForCondition(() => received.length > 0, {
timeoutMs: 30_000,
timeoutMessage: "Timed out waiting for a gitHubTelemetry.event notification.",
});
expect(received.length).toBeGreaterThan(0);
const notification = received[0];
expect(typeof notification.sessionId).toBe("string");
expect(notification.sessionId.length).toBeGreaterThan(0);
expect(typeof notification.restricted).toBe("boolean");
expect(notification.event).toBeDefined();
expect(typeof notification.event.kind).toBe("string");
await session.disconnect();
}
);
});