Import the client, server, skills, tests, and build scripts as the starting point for the rebuild, then trim the surfaces this project does not ship: Electron desktop packaging, the marketing website, and the ESP32 firmware tree. CI keeps the web build, e2e, lockfile, release, and Docker workflows. Rename the package and CLI entry points to hermes-ui, drop the prepare hook so npm ci no longer triggers a build, and drop the removed tsconfig and nodemon references. Rewrite AGENTS.md, ARCHITECTURE.md, DEVELOPMENT.md, and the READMEs so the documented package map and hard rules match this repository. reference_code/ is ignored: it is a read-only snapshot, not an input to the build.
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')
|
|
})
|
|
})
|