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:
@@ -16,12 +16,16 @@ const mockKanbanApi = vi.hoisted(() => ({
|
||||
unblockTasks: vi.fn(),
|
||||
assignTask: vi.fn(),
|
||||
addComment: vi.fn(),
|
||||
linkTasks: vi.fn(),
|
||||
unlinkTasks: vi.fn(),
|
||||
bulkUpdateTasks: vi.fn(),
|
||||
getTaskLog: vi.fn(),
|
||||
getDiagnostics: vi.fn(),
|
||||
reclaimTask: vi.fn(),
|
||||
reassignTask: vi.fn(),
|
||||
specifyTask: vi.fn(),
|
||||
dispatch: vi.fn(),
|
||||
openKanbanEventStream: vi.fn(),
|
||||
}))
|
||||
|
||||
vi.mock('@/api/hermes/kanban', () => mockKanbanApi)
|
||||
@@ -49,6 +53,7 @@ describe('Kanban store', () => {
|
||||
{ slug: 'project-a', name: 'Project A', archived: false, counts: { todo: 1 }, total: 1 },
|
||||
])
|
||||
mockKanbanApi.getCapabilities.mockResolvedValue({ source: 'hermes-cli', supports: { boardsList: true }, missing: [] })
|
||||
mockKanbanApi.openKanbanEventStream.mockReturnValue({ close: vi.fn(), onmessage: null, onclose: null, onerror: null })
|
||||
})
|
||||
|
||||
it('persists selected board, including default, and falls back to default for missing boards', async () => {
|
||||
@@ -137,6 +142,75 @@ describe('Kanban store', () => {
|
||||
expect(mockKanbanApi.dispatch).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('passes selected board to link and partial bulk parity actions', async () => {
|
||||
mockKanbanApi.getCapabilities.mockResolvedValue({
|
||||
source: 'hermes-cli',
|
||||
supports: { links: true, bulk: false },
|
||||
missing: ['bulk'],
|
||||
capabilities: [
|
||||
{ key: 'links', status: 'supported', requiresBoard: true },
|
||||
{ key: 'bulk', status: 'partial', requiresBoard: true },
|
||||
],
|
||||
})
|
||||
mockKanbanApi.linkTasks.mockResolvedValue({ ok: true })
|
||||
mockKanbanApi.unlinkTasks.mockResolvedValue({ ok: true })
|
||||
mockKanbanApi.bulkUpdateTasks.mockResolvedValue({ results: [{ id: 'task-1', ok: true }] })
|
||||
mockKanbanApi.listTasks.mockResolvedValue([])
|
||||
mockKanbanApi.getStats.mockResolvedValue({ total: 0, by_status: {}, by_assignee: {} })
|
||||
mockKanbanApi.getAssignees.mockResolvedValue([])
|
||||
|
||||
const store = useKanbanStore()
|
||||
store.setSelectedBoard('project-a')
|
||||
await store.fetchCapabilities()
|
||||
|
||||
await store.linkTasks('task-1', 'task-2')
|
||||
await store.unlinkTasks('task-1', 'task-2')
|
||||
await expect(store.bulkUpdateTasks({ ids: ['task-1'], status: 'done', assignee: null, summary: 'closed' })).resolves.toEqual({ results: [{ id: 'task-1', ok: true }] })
|
||||
|
||||
expect(mockKanbanApi.linkTasks).toHaveBeenCalledWith({ parent_id: 'task-1', child_id: 'task-2' }, { board: 'project-a' })
|
||||
expect(mockKanbanApi.unlinkTasks).toHaveBeenCalledWith({ parent_id: 'task-1', child_id: 'task-2' }, { board: 'project-a' })
|
||||
expect(mockKanbanApi.bulkUpdateTasks).toHaveBeenCalledWith({ ids: ['task-1'], status: 'done', assignee: null, summary: 'closed' }, { board: 'project-a' })
|
||||
expect(mockKanbanApi.listTasks).toHaveBeenCalledWith({ board: 'project-a', status: undefined, assignee: undefined, includeArchived: true })
|
||||
})
|
||||
|
||||
it('opens board-scoped event streams, refreshes on events, and reconnects on board switch', async () => {
|
||||
vi.useFakeTimers()
|
||||
const socketA = { close: vi.fn(), onmessage: null as ((event: { data: string }) => void) | null, onclose: null, onerror: null }
|
||||
const socketB = { close: vi.fn(), onmessage: null as ((event: { data: string }) => void) | null, onclose: null, onerror: null }
|
||||
mockKanbanApi.openKanbanEventStream
|
||||
.mockReturnValueOnce(socketA)
|
||||
.mockReturnValueOnce(socketB)
|
||||
mockKanbanApi.getCapabilities.mockResolvedValue({
|
||||
source: 'hermes-cli',
|
||||
supports: {},
|
||||
missing: [],
|
||||
capabilities: [{ key: 'events', status: 'partial', requiresBoard: true }],
|
||||
})
|
||||
mockKanbanApi.listTasks.mockResolvedValue([])
|
||||
mockKanbanApi.getStats.mockResolvedValue({ total: 0, by_status: {}, by_assignee: {} })
|
||||
mockKanbanApi.getAssignees.mockResolvedValue([])
|
||||
|
||||
const store = useKanbanStore()
|
||||
store.setSelectedBoard('project-a')
|
||||
await store.fetchCapabilities()
|
||||
|
||||
expect(store.startEventStream()).toBe(true)
|
||||
expect(mockKanbanApi.openKanbanEventStream).toHaveBeenCalledWith({ board: 'project-a' })
|
||||
|
||||
socketA.onmessage?.({ data: JSON.stringify({ type: 'event', line: 'changed' }) })
|
||||
await vi.advanceTimersByTimeAsync(100)
|
||||
expect(mockKanbanApi.listTasks).toHaveBeenCalledWith({ board: 'project-a', status: undefined, assignee: undefined, includeArchived: true })
|
||||
expect(mockKanbanApi.getStats).toHaveBeenCalledWith({ board: 'project-a' })
|
||||
expect(mockKanbanApi.getAssignees).toHaveBeenCalledWith({ board: 'project-a' })
|
||||
|
||||
store.setSelectedBoard('default')
|
||||
expect(socketA.close).toHaveBeenCalled()
|
||||
expect(mockKanbanApi.openKanbanEventStream).toHaveBeenLastCalledWith({ board: 'default' })
|
||||
store.stopEventStream()
|
||||
expect(socketB.close).toHaveBeenCalled()
|
||||
vi.useRealTimers()
|
||||
})
|
||||
|
||||
it('passes selected board to parity actions and refreshes affected board state', async () => {
|
||||
mockKanbanApi.getCapabilities.mockResolvedValue({
|
||||
source: 'hermes-cli',
|
||||
|
||||
Reference in New Issue
Block a user