Files
shumai/src/agent/activities/agent.test.ts
T
2026-05-19 16:05:09 +08:00

46 lines
975 B
TypeScript

import { describe, it, expect, vi, beforeEach } from 'vitest'
import { setupTestDbHooks } from '@/db-test-hooks'
import { aiChatActivity } from './agent'
import { agentExecutor } from '../executor'
vi.mock('../executor', () => ({
agentExecutor: {
chatWithAgent: vi.fn(),
},
}))
describe('Agent Activities', () => {
setupTestDbHooks()
beforeEach(() => {
vi.clearAllMocks()
})
it('should call aiChatActivity', async () => {
vi.mocked(agentExecutor.chatWithAgent).mockResolvedValue({
text: 'AI response',
usage: { inputTokens: 1, outputTokens: 1, model: 'gpt-4' },
sessionId: 'mock-session-id',
})
await aiChatActivity({
teamId: 't1',
agentId: 'b1',
message: 'Hi',
imageUrls: [],
projectId: 'p1',
folderId: 'f1',
})
expect(agentExecutor.chatWithAgent).toHaveBeenCalledWith(
't1',
'b1',
'Hi',
[],
'',
undefined,
undefined,
)
})
})