|
1 | 1 | // noinspection ES6RedundantAwait |
2 | 2 |
|
3 | 3 | import {describe, expect, it, vi, beforeEach} from 'vitest'; |
4 | | -import {createTestFixture, type TestFixture} from "../acp-test-utils"; |
5 | | -import type {McpServerStdio} from "@agentclientprotocol/sdk"; |
| 4 | +import {createCodexMockTestFixture, createTestSessionState, type CodexMockTestFixture} from "../acp-test-utils"; |
6 | 5 |
|
7 | 6 | describe('MCP session configuration', { timeout: 40_000 }, () => { |
8 | 7 |
|
9 | | - let fixture: TestFixture; |
| 8 | + let fixture: CodexMockTestFixture; |
10 | 9 | beforeEach(() => { |
11 | | - fixture = createTestFixture(); |
| 10 | + fixture = createCodexMockTestFixture(); |
12 | 11 | vi.clearAllMocks(); |
13 | 12 | }); |
14 | 13 |
|
15 | 14 |
|
16 | 15 | it('should return configured mcp', async () => { |
17 | 16 | const codexAcpAgent = fixture.getCodexAcpAgent(); |
18 | | - await codexAcpAgent.initialize({protocolVersion: 1}); |
| 17 | + const sessionId = "session-id"; |
| 18 | + vi.spyOn(codexAcpAgent, "getSessionState").mockReturnValue(createTestSessionState({ |
| 19 | + sessionId, |
| 20 | + sessionMcpServers: ["test-mcp"], |
| 21 | + })); |
| 22 | + vi.spyOn(fixture.getCodexAcpClient(), "listMcpServers").mockResolvedValue({ data: [], nextCursor: null }); |
19 | 23 |
|
20 | | - fixture.getCodexAcpClient().authRequired = vi.fn().mockResolvedValue(false); |
21 | | - const mcpServer: McpServerStdio = { |
22 | | - name: "test-mcp", command: "./node_modules/.bin/mcp-hello-world", args: ["example"], env: [{name:"example", value: "example"}] |
23 | | - }; |
24 | | - |
25 | | - const newSessionResponse = await codexAcpAgent.newSession({cwd: "", mcpServers: [mcpServer]}); |
26 | 24 | fixture.clearAcpConnectionDump(); |
27 | | - await codexAcpAgent.prompt({sessionId: newSessionResponse.sessionId, prompt: [{type: "text", text: "/mcp"}]}); |
| 25 | + await codexAcpAgent.prompt({sessionId, prompt: [{type: "text", text: "/mcp"}]}); |
28 | 26 | const transportDump = fixture.getAcpConnectionDump([]); |
29 | 27 | expect(transportDump).contain("Configured MCP servers:"); |
30 | 28 | expect(transportDump).contain("- test-mcp"); |
|
0 commit comments