mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-19 14:16:29 +00:00
46 lines
975 B
TypeScript
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,
|
|
)
|
|
})
|
|
})
|