Kanban:补齐看板事件、链接与批量操作闭环 (#634)
* feat(kanban): add board-scoped event stream bridge * test(kanban): align event refresh expectation * feat(kanban): add links and partial bulk bridge * test(kanban): align links bulk refresh expectation * fix(kanban): treat mutation stderr as failed
This commit is contained in:
@@ -2,9 +2,13 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
const mockRequest = vi.hoisted(() => vi.fn())
|
||||
const mockGetApiKey = vi.hoisted(() => vi.fn(() => ''))
|
||||
const mockGetBaseUrlValue = vi.hoisted(() => vi.fn(() => ''))
|
||||
|
||||
vi.mock('../../packages/client/src/api/client', () => ({
|
||||
request: mockRequest,
|
||||
getApiKey: mockGetApiKey,
|
||||
getBaseUrlValue: mockGetBaseUrlValue,
|
||||
}))
|
||||
|
||||
import {
|
||||
@@ -20,6 +24,9 @@ import {
|
||||
unblockTasks,
|
||||
assignTask,
|
||||
addComment,
|
||||
linkTasks,
|
||||
unlinkTasks,
|
||||
bulkUpdateTasks,
|
||||
getTaskLog,
|
||||
getDiagnostics,
|
||||
reclaimTask,
|
||||
@@ -28,11 +35,23 @@ import {
|
||||
dispatch,
|
||||
getStats,
|
||||
getAssignees,
|
||||
buildKanbanEventsWebSocketUrl,
|
||||
} from '../../packages/client/src/api/hermes/kanban'
|
||||
|
||||
describe('Kanban API', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
localStorage.clear()
|
||||
mockGetApiKey.mockReturnValue('')
|
||||
mockGetBaseUrlValue.mockReturnValue('')
|
||||
})
|
||||
|
||||
it('builds board-scoped kanban event websocket URLs with auth token', () => {
|
||||
mockGetBaseUrlValue.mockReturnValue('https://wui.example.test')
|
||||
mockGetApiKey.mockReturnValue('token value')
|
||||
|
||||
expect(buildKanbanEventsWebSocketUrl({ board: 'project-a' })).toBe('wss://wui.example.test/api/hermes/kanban/events?board=project-a&token=token+value')
|
||||
expect(buildKanbanEventsWebSocketUrl()).toBe('wss://wui.example.test/api/hermes/kanban/events?board=default&token=token+value')
|
||||
})
|
||||
|
||||
it('serializes board, list filters, and archived inclusion into query params', async () => {
|
||||
@@ -116,6 +135,9 @@ describe('Kanban API', () => {
|
||||
it('calls parity-gap APIs with explicit board query params', async () => {
|
||||
mockRequest
|
||||
.mockResolvedValueOnce({ ok: true, output: 'commented' })
|
||||
.mockResolvedValueOnce({ ok: true, output: 'linked' })
|
||||
.mockResolvedValueOnce({ ok: true, output: 'unlinked' })
|
||||
.mockResolvedValueOnce({ results: [{ id: 'task-1', ok: true }] })
|
||||
.mockResolvedValueOnce({ task_id: 'task-1', path: null, exists: true, size_bytes: 10, content: 'worker log', truncated: false })
|
||||
.mockResolvedValueOnce({ diagnostics: [{ task_id: 'task-1' }] })
|
||||
.mockResolvedValueOnce({ ok: true, output: 'reclaimed' })
|
||||
@@ -124,6 +146,9 @@ describe('Kanban API', () => {
|
||||
.mockResolvedValueOnce({ result: { spawned: 1 } })
|
||||
|
||||
await addComment('task-1', { body: 'needs review', author: 'han' }, { board: 'default' })
|
||||
await linkTasks({ parent_id: 'task-1', child_id: 'task-2' }, { board: 'project-a' })
|
||||
await unlinkTasks({ parent_id: 'task-1', child_id: 'task-2' }, { board: 'project-a' })
|
||||
await expect(bulkUpdateTasks({ ids: ['task-1'], status: 'done', assignee: null, summary: 'closed' }, { board: 'project-a' })).resolves.toEqual({ results: [{ id: 'task-1', ok: true }] })
|
||||
await expect(getTaskLog('task-1', { board: 'default', tail: 4000 })).resolves.toEqual({ task_id: 'task-1', path: null, exists: true, size_bytes: 10, content: 'worker log', truncated: false })
|
||||
await expect(getDiagnostics({ board: 'default', task: 'task-1', severity: 'warning' })).resolves.toEqual([{ task_id: 'task-1' }])
|
||||
await reclaimTask('task-1', { board: 'project-a', reason: 'stale' })
|
||||
@@ -133,6 +158,9 @@ describe('Kanban API', () => {
|
||||
|
||||
expect(mockRequest.mock.calls).toEqual([
|
||||
['/api/hermes/kanban/task-1/comments?board=default', { method: 'POST', body: JSON.stringify({ body: 'needs review', author: 'han' }) }],
|
||||
['/api/hermes/kanban/links?board=project-a', { method: 'POST', body: JSON.stringify({ parent_id: 'task-1', child_id: 'task-2' }) }],
|
||||
['/api/hermes/kanban/links?board=project-a&parent_id=task-1&child_id=task-2', { method: 'DELETE' }],
|
||||
['/api/hermes/kanban/tasks/bulk?board=project-a', { method: 'POST', body: JSON.stringify({ ids: ['task-1'], status: 'done', assignee: null, summary: 'closed' }) }],
|
||||
['/api/hermes/kanban/task-1/log?board=default&tail=4000'],
|
||||
['/api/hermes/kanban/diagnostics?board=default&task=task-1&severity=warning'],
|
||||
['/api/hermes/kanban/task-1/reclaim?board=project-a', { method: 'POST', body: JSON.stringify({ reason: 'stale' }) }],
|
||||
|
||||
Reference in New Issue
Block a user