mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-01 21:44:27 +00:00
initial commit
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
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,
|
||||
)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user