Why: Repeated progress and coupled scrolling obscured chat, and task choices lacked a reliable independent interaction path. Evidence: 285 frontend unit tests and 23 browser scenarios pass locally before the shared event-loader extraction; final combination checks follow in Dev. Impact: Coalesce cumulative progress, retain execution records, show timestamps and quiet notifications, support versioned work actions and explicit result references without automatic chat backfill. Refs: feature/workbench-flow-completion
25 lines
1.5 KiB
TypeScript
25 lines
1.5 KiB
TypeScript
import { afterEach, describe, expect, it, vi } from 'vitest'
|
|
import { api } from '../src/api'
|
|
import { auth } from '../src/auth'
|
|
|
|
afterEach(() => vi.restoreAllMocks())
|
|
|
|
describe('versioned work request bodies', () => {
|
|
it('preserves multiple selections and free input on the card action endpoint', async () => {
|
|
const request = vi.spyOn(auth, 'fetch').mockResolvedValue(new Response(JSON.stringify({ card: { id: 'task' } })))
|
|
await api.cardAction('task', 'work.submit', { resultVersion: 3, selectedIds: ['summary', 'parameters'], freeText: '请说明依据' })
|
|
const [url, options] = request.mock.calls[0]
|
|
expect(url).toBe('/api/cards/task/actions/work.submit')
|
|
expect(JSON.parse(String(options?.body))).toEqual({ resultVersion: 3, selectedIds: ['summary', 'parameters'], freeText: '请说明依据' })
|
|
})
|
|
|
|
it('sends a result identity separately from the user message and discards client display metadata', async () => {
|
|
const request = vi.spyOn(auth, 'fetch').mockResolvedValue(new Response(JSON.stringify({ message: { id: 'reply' } })))
|
|
const reference = { cardId: 'task', resultVersion: 3, title: '说明书整理', result: 'must-not-be-client-context' }
|
|
await api.sendMessage('conversation', '比较这些重点', [], 'request-1', reference)
|
|
expect(JSON.parse(String(request.mock.calls[0][1]?.body))).toEqual({
|
|
text: '比较这些重点', attachmentIds: [], requestId: 'request-1', taskRef: { cardId: 'task', resultVersion: 3 },
|
|
})
|
|
})
|
|
})
|