-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathacp-e2e.test.ts
More file actions
106 lines (91 loc) · 3.98 KB
/
Copy pathacp-e2e.test.ts
File metadata and controls
106 lines (91 loc) · 3.98 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import {afterEach, expect, it} from "vitest";
import {AgentMode} from "../../../AgentMode";
import {
createAuthenticatedFixture,
createGatewayFixture,
DEFAULT_TEST_MODEL_ID,
describeE2E,
OTHER_TEST_MODEL_ID,
requireLiveApiKey,
type SpawnedAgentFixture,
} from "./acp-e2e-test-utils";
describeE2E("E2E tests", () => {
let fixture: SpawnedAgentFixture | null = null;
afterEach(async () => {
if (fixture) {
await fixture.dispose();
fixture = null;
}
});
it("returns model response", async () => {
fixture = await createAuthenticatedFixture();
const session = await fixture.createSession();
await fixture.expectPromptText(session.sessionId, "Reply with exactly integration-ok and nothing else.", (text) => {
expect(text.toLowerCase()).toContain("integration-ok");
});
});
it("returns model response when authenticated via gateway", async () => {
const apiKey = requireLiveApiKey();
fixture = await createGatewayFixture("https://api.openai.com/v1", {Authorization: `Bearer ${apiKey}`});
const session = await fixture.createSession();
await fixture.expectPromptText(session.sessionId, "Reply with exactly integration-ok and nothing else.", (text) => {
expect(text.toLowerCase()).toContain("integration-ok");
});
});
it("uses the selected session model for subsequent prompts", async () => {
fixture = await createAuthenticatedFixture();
const session = await fixture.createSession();
const models = session.models;
if (!models) {
throw new Error("Agent did not return initial model state.");
}
expect(models.availableModels.length).toBeGreaterThan(0);
expect(models.currentModelId).toBe(DEFAULT_TEST_MODEL_ID.toString());
await fixture.connection.unstable_setSessionModel({
sessionId: session.sessionId,
modelId: OTHER_TEST_MODEL_ID.toString(),
});
await fixture.expectStatus(session.sessionId, {Model: OTHER_TEST_MODEL_ID});
});
it("changes session mode via setSessionMode and reflects it in /status", async () => {
fixture = await createAuthenticatedFixture();
const session = await fixture.createSession();
const modes = session.modes;
expect(modes?.currentModeId).toBe(AgentMode.DEFAULT_AGENT_MODE.id);
expect(modes?.availableModes.map((mode) => mode.id)).toEqual(
AgentMode.all().map((mode) => mode.id),
);
const targetMode = AgentMode.AgentFullAccess;
await fixture.connection.setSessionMode({
sessionId: session.sessionId,
modeId: targetMode.id,
});
await fixture.expectStatus(session.sessionId, {
Approval: targetMode.approvalPolicy,
Sandbox: targetMode.sandboxMode,
});
});
it("respects INITIAL_AGENT_MODE when seeding the initial session mode", async () => {
const initialMode = AgentMode.ReadOnly;
fixture = await createAuthenticatedFixture(initialMode);
const session = await fixture.createSession();
expect(session.modes?.currentModeId).toBe(initialMode.id);
await fixture.expectStatus(session.sessionId, {
Approval: initialMode.approvalPolicy,
Sandbox: initialMode.sandboxMode,
});
});
it("lists a user skill from the wrapped CODEX_HOME", async () => {
fixture = await createAuthenticatedFixture();
fixture.writeSkill({
name: "integration-skill",
description: "Integration skill",
body: "This skill exists only for integration testing.",
});
const session = await fixture.createSession();
await fixture.expectPromptText(session.sessionId, "/skills", (text) => {
expect(text).toContain("Available skills:");
expect(text).toContain("- integration-skill: Integration skill");
});
});
});