-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy patherror_resilience.test.ts
More file actions
45 lines (35 loc) · 1.7 KB
/
error_resilience.test.ts
File metadata and controls
45 lines (35 loc) · 1.7 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
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------------------------------------------*/
import { describe, expect, it } from "vitest";
import { approveAll } from "../../src/index.js";
import { createSdkTestContext } from "./harness/sdkTestContext";
describe("Error Resilience", async () => {
const { copilotClient: client } = await createSdkTestContext();
it("should throw when sending to destroyed session", async () => {
const session = await client.createSession({ onPermissionRequest: approveAll });
await session.destroy();
await expect(session.sendAndWait({ prompt: "Hello" })).rejects.toThrow();
});
it("should throw when getting messages from destroyed session", async () => {
const session = await client.createSession({ onPermissionRequest: approveAll });
await session.destroy();
await expect(session.getMessages()).rejects.toThrow();
});
it("should handle double abort without error", async () => {
const session = await client.createSession({ onPermissionRequest: approveAll });
// First abort should be fine
await session.abort();
// Second abort should not throw
await session.abort();
// Session should still be destroyable
await session.destroy();
});
it("should throw when resuming non-existent session", async () => {
await expect(
client.resumeSession("non-existent-session-id-12345", {
onPermissionRequest: approveAll,
})
).rejects.toThrow();
});
});