import { beforeEach, expect, test, vi } from 'vitest'; const { requestJsonMock } = vi.hoisted(() => ({ requestJsonMock: vi.fn(), })); vi.mock('../apiClient', () => ({ fetchWithApiAuth: vi.fn(), requestJson: requestJsonMock, })); import { createCreationAgentClient } from './creationAgentClientFactory'; beforeEach(() => { requestJsonMock.mockReset(); requestJsonMock.mockResolvedValue({ session: { sessionId: 'session-1' } }); }); test('creation agent action requests are not auto-retried by default', async () => { const client = createCreationAgentClient< Record, { session: { sessionId: string } }, { session: { sessionId: string } }, { sessionId: string }, { text: string }, { session: { sessionId: string } }, { action: string }, { session: { sessionId: string } } >({ apiBase: '/api/runtime/puzzle/agent/sessions', messages: { createSession: '创建失败', getSession: '读取失败', sendMessage: '发送失败', streamIncomplete: '流式结果不完整', executeAction: '执行失败', }, }); await client.executeAction('session-1', { action: 'compile_puzzle_draft' }); expect(requestJsonMock).toHaveBeenCalledWith( '/api/runtime/puzzle/agent/sessions/session-1/actions', expect.objectContaining({ method: 'POST' }), '执行失败', expect.objectContaining({ retry: expect.objectContaining({ maxRetries: 0 }), }), ); });