mirror of
https://github.com/EKKOLearnAI/hermes-web-ui.git
synced 2026-07-08 17:50:25 +00:00
f5a292663b
* feat: add workflow builder page * Add workflow schema and editor controls * feat: add workflow builder persistence * feat: add workflow socket and agent skills * feat: complete workflow run execution * test: fix workflow ci coverage failures --------- Co-authored-by: Codex <codex@openai.com>
52 lines
1.5 KiB
TypeScript
52 lines
1.5 KiB
TypeScript
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
|
|
const ioMock = vi.hoisted(() => vi.fn())
|
|
const sockets = vi.hoisted(() => [] as Array<{ connected: boolean; disconnect: ReturnType<typeof vi.fn> }>)
|
|
|
|
vi.mock('socket.io-client', () => ({
|
|
io: ioMock,
|
|
}))
|
|
|
|
vi.mock('@/api/client', () => ({
|
|
getActiveProfileName: vi.fn(() => 'default'),
|
|
getApiKey: vi.fn(() => 'test-key'),
|
|
getBaseUrlValue: vi.fn(() => 'http://localhost:3000'),
|
|
}))
|
|
|
|
describe('workflow socket client', () => {
|
|
beforeEach(() => {
|
|
vi.resetModules()
|
|
ioMock.mockReset()
|
|
sockets.splice(0)
|
|
ioMock.mockImplementation(() => {
|
|
const socket = {
|
|
connected: false,
|
|
disconnect: vi.fn(),
|
|
}
|
|
sockets.push(socket)
|
|
return socket
|
|
})
|
|
})
|
|
|
|
it('reuses the pending socket for the same profile', async () => {
|
|
const { connectWorkflowSocket } = await import('@/api/hermes/workflow-socket')
|
|
|
|
const first = connectWorkflowSocket('default')
|
|
const second = connectWorkflowSocket('default')
|
|
|
|
expect(second).toBe(first)
|
|
expect(ioMock).toHaveBeenCalledTimes(1)
|
|
expect(sockets[0].disconnect).not.toHaveBeenCalled()
|
|
})
|
|
|
|
it('recreates the socket when the profile changes', async () => {
|
|
const { connectWorkflowSocket } = await import('@/api/hermes/workflow-socket')
|
|
|
|
connectWorkflowSocket('default')
|
|
connectWorkflowSocket('travel')
|
|
|
|
expect(ioMock).toHaveBeenCalledTimes(2)
|
|
expect(sockets[0].disconnect).toHaveBeenCalledTimes(1)
|
|
})
|
|
})
|