mirror of
https://github.com/EKKOLearnAI/hermes-web-ui.git
synced 2026-05-25 21:40:13 +00:00
3f88553765
* feat: add single-page live session monitor and chat pinning * fix: restore full test green after main merge * fix: use Array.from instead of Set spread for ts-node compatibility [...new Set()] requires downlevelIteration which isn't enabled in ts-node dev mode, causing sonic-boom crash on startup. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: ekko <fqsy1416@gmail.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
40 lines
1.5 KiB
TypeScript
40 lines
1.5 KiB
TypeScript
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
|
|
const mockRequest = vi.hoisted(() => vi.fn())
|
|
|
|
vi.mock('@/api/client', () => ({
|
|
request: mockRequest,
|
|
}))
|
|
|
|
import { fetchConversationDetail, fetchConversationSummaries } from '@/api/hermes/conversations'
|
|
|
|
describe('conversations api', () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks()
|
|
})
|
|
|
|
it('builds summaries URLs with optional params', async () => {
|
|
mockRequest.mockResolvedValue({ sessions: [] })
|
|
|
|
await fetchConversationSummaries()
|
|
await fetchConversationSummaries({ humanOnly: false, source: 'cli', limit: 25 })
|
|
|
|
expect(mockRequest).toHaveBeenNthCalledWith(1, '/api/hermes/sessions/conversations')
|
|
expect(mockRequest).toHaveBeenNthCalledWith(2, '/api/hermes/sessions/conversations?humanOnly=false&source=cli&limit=25')
|
|
})
|
|
|
|
it('encodes detail URLs and forwards optional params', async () => {
|
|
mockRequest.mockResolvedValue({ session_id: 'conv', messages: [], visible_count: 0, thread_session_count: 1 })
|
|
|
|
await fetchConversationDetail('folder/with spaces', { humanOnly: false, source: 'discord' })
|
|
|
|
expect(mockRequest).toHaveBeenCalledWith('/api/hermes/sessions/conversations/folder%2Fwith%20spaces/messages?humanOnly=false&source=discord')
|
|
})
|
|
|
|
it('propagates conversation detail errors so the monitor can render an error state', async () => {
|
|
mockRequest.mockRejectedValue(new Error('boom'))
|
|
|
|
await expect(fetchConversationDetail('conv-1', { humanOnly: true })).rejects.toThrow('boom')
|
|
})
|
|
})
|