-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathacp-e2e-session-persistence.test.ts
More file actions
49 lines (42 loc) · 2.02 KB
/
Copy pathacp-e2e-session-persistence.test.ts
File metadata and controls
49 lines (42 loc) · 2.02 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
import {afterEach, expect, it} from "vitest";
import {legacySetSessionModel, type LegacyLoadSessionResponse} from "../../../AcpExtensions";
import {
createAuthenticatedFixture,
describeE2E,
OTHER_TEST_MODEL_ID,
type SpawnedAgentFixture,
} from "./acp-e2e-test-utils";
describeE2E("E2E session persistence tests", () => {
let beforeRestartFixture: SpawnedAgentFixture | null = null;
let afterRestartFixture: SpawnedAgentFixture | null = null;
afterEach(async () => {
await afterRestartFixture?.dispose();
await beforeRestartFixture?.dispose();
afterRestartFixture = null;
beforeRestartFixture = null;
});
// Temporarily disabled as flaky
it.skip("persists a session across ACP process restart", async () => {
beforeRestartFixture = await createAuthenticatedFixture();
const sessionId = (await beforeRestartFixture.createSession()).sessionId;
await legacySetSessionModel(beforeRestartFixture.connection, {sessionId, modelId: OTHER_TEST_MODEL_ID.toString()});
const memorizedToken = "token-for-tests-123";
await beforeRestartFixture.expectPromptText(
sessionId,
`Remember this token - "${memorizedToken}". Reply with exactly before-restart-ok and nothing else.`,
(text) => expect(text.toLowerCase()).toContain("before-restart-ok"),
);
afterRestartFixture = await beforeRestartFixture.restart();
const loadSessionResponse = await afterRestartFixture.connection.loadSession({
sessionId,
cwd: afterRestartFixture.workspaceDir,
mcpServers: [],
}) as LegacyLoadSessionResponse;
expect(loadSessionResponse.models?.currentModelId).toBe(OTHER_TEST_MODEL_ID.toString());
await afterRestartFixture.expectPromptText(
sessionId,
"What token did I ask you to remember earlier? Reply with just the token and nothing else.",
(text) => expect(text.toLowerCase()).toContain(memorizedToken),
);
});
});