|
3 | 3 | import {describe, expect, it, vi, beforeEach} from 'vitest'; |
4 | 4 | import type {CodexAuthRequest} from "../../CodexAuthMethod"; |
5 | 5 | import type * as acp from "@agentclientprotocol/sdk"; |
6 | | -import {createTestFixture, createCodexMockTestFixture, createTestSessionState, type TestFixture} from "../acp-test-utils"; |
| 6 | +import { |
| 7 | + createTestFixture, |
| 8 | + createCodexMockTestFixture, |
| 9 | + createTestModel, |
| 10 | + createTestSessionState, |
| 11 | + createTestThread, |
| 12 | + createTestThreadStartResponse, |
| 13 | + createTestTurn, |
| 14 | + createTestTurnCompletedNotification, |
| 15 | + type TestFixture |
| 16 | +} from "../acp-test-utils"; |
7 | 17 | import type {ServerNotification} from "../../app-server"; |
8 | 18 | import type {SessionState} from "../../CodexAcpServer"; |
9 | 19 | import {AgentMode} from "../../AgentMode"; |
@@ -143,32 +153,13 @@ describe('ACP server test', { timeout: 40_000 }, () => { |
143 | 153 | const codexAppServerClient = mockFixture.getCodexAppServerClient(); |
144 | 154 |
|
145 | 155 | const listSkillsSpy = vi.spyOn(codexAppServerClient, "listSkills").mockResolvedValue({ data: [] }); |
146 | | - const threadStartSpy = vi.spyOn(codexAppServerClient, "threadStart").mockResolvedValue({ |
147 | | - thread: { id: "thread-id" } as any, |
148 | | - model: "gpt-5", |
149 | | - modelProvider: "openai", |
150 | | - cwd: "/workspace", |
151 | | - approvalPolicy: "on-request", |
152 | | - sandbox: "workspace-write", |
153 | | - reasoningEffort: "medium", |
154 | | - } as any); |
| 156 | + const threadStartSpy = vi.spyOn(codexAppServerClient, "threadStart").mockResolvedValue( |
| 157 | + createTestThreadStartResponse({ |
| 158 | + thread: createTestThread({ id: "thread-id" }), |
| 159 | + }) |
| 160 | + ); |
155 | 161 | vi.spyOn(codexAppServerClient, "listModels").mockResolvedValue({ |
156 | | - data: [{ |
157 | | - id: "gpt-5", |
158 | | - model: "gpt-5", |
159 | | - upgrade: null, |
160 | | - upgradeInfo: null, |
161 | | - availabilityNux: null, |
162 | | - displayName: "gpt-5", |
163 | | - description: "test model", |
164 | | - hidden: false, |
165 | | - supportedReasoningEfforts: [{ reasoningEffort: "medium", description: "balanced" }], |
166 | | - defaultReasoningEffort: "medium", |
167 | | - inputModalities: ["text"], |
168 | | - supportsPersonality: false, |
169 | | - additionalSpeedTiers: [], |
170 | | - isDefault: true |
171 | | - }], |
| 162 | + data: [createTestModel({ displayName: "gpt-5" })], |
172 | 163 | nextCursor: null |
173 | 164 | }); |
174 | 165 |
|
@@ -233,24 +224,19 @@ describe('ACP server test', { timeout: 40_000 }, () => { |
233 | 224 | const codexAppServerClient = mockFixture.getCodexAppServerClient(); |
234 | 225 |
|
235 | 226 | vi.spyOn(codexAcpAgent, "checkAuthorization").mockResolvedValue(undefined); |
236 | | - vi.spyOn(codexAppServerClient, "threadStart").mockResolvedValue({ |
237 | | - thread: { id: "thread-id" } as any, |
238 | | - model: "gpt-5", |
239 | | - reasoningEffort: "medium", |
240 | | - } as any); |
| 227 | + vi.spyOn(codexAppServerClient, "threadStart").mockResolvedValue( |
| 228 | + createTestThreadStartResponse({ |
| 229 | + thread: createTestThread({ id: "thread-id" }), |
| 230 | + }) |
| 231 | + ); |
241 | 232 | vi.spyOn(codexAppServerClient, "listModels").mockResolvedValue({ |
242 | | - data: [{ |
243 | | - id: "gpt-5", |
244 | | - name: "GPT-5", |
245 | | - inputModalities: ["text"], |
246 | | - supportedReasoningEfforts: [], |
247 | | - }], |
248 | | - hasMore: false, |
249 | | - } as any); |
| 233 | + data: [createTestModel({ supportedReasoningEfforts: [] })], |
| 234 | + nextCursor: null, |
| 235 | + }); |
250 | 236 | vi.spyOn(codexAppServerClient, "accountRead").mockResolvedValue({ |
251 | 237 | requiresOpenaiAuth: false, |
252 | 238 | account: null, |
253 | | - } as any); |
| 239 | + }); |
254 | 240 | vi.spyOn(codexAppServerClient, "listSkills").mockResolvedValue({ data: [] }); |
255 | 241 | const mcpServer = { |
256 | 242 | name: "broken-mcp", |
@@ -287,12 +273,14 @@ describe('ACP server test', { timeout: 40_000 }, () => { |
287 | 273 |
|
288 | 274 | const listSkillsSpy = vi.spyOn(codexAppServerClient, "listSkills").mockResolvedValue({ data: [] }); |
289 | 275 | const turnStartSpy = vi.spyOn(codexAppServerClient, "turnStart").mockResolvedValue({ |
290 | | - turn: { id: "turn-id", items: [], status: "inProgress", error: null } |
291 | | - } as any); |
292 | | - vi.spyOn(codexAppServerClient, "awaitTurnCompleted").mockResolvedValue({ |
293 | | - threadId: "session-id", |
294 | | - turn: { id: "turn-id", items: [], status: "completed", error: null } |
295 | | - } as any); |
| 276 | + turn: createTestTurn() |
| 277 | + }); |
| 278 | + vi.spyOn(codexAppServerClient, "awaitTurnCompleted").mockResolvedValue( |
| 279 | + createTestTurnCompletedNotification({ |
| 280 | + threadId: "session-id", |
| 281 | + turn: createTestTurn({ status: "completed" }) |
| 282 | + }) |
| 283 | + ); |
296 | 284 |
|
297 | 285 | vi.spyOn(codexAcpAgent, "getSessionState").mockReturnValue(createTestSessionState({ |
298 | 286 | sessionId: "session-id", |
|
0 commit comments