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