27 lines
1.1 KiB
TypeScript
27 lines
1.1 KiB
TypeScript
import { describe, expect, it, vi } from 'vitest'
|
|
import { resolveWorkflowTarget } from '../../src/commands/test/_workflow_target.ts'
|
|
|
|
describe('test browser workflow target (Task 8b)', () => {
|
|
it('--id --taskId 都传 → 定向 operator 查询', async () => {
|
|
const webapi = {
|
|
getFlowTaskOperator: vi.fn().mockResolvedValue({ id: 'op1', userId: 'u1' }),
|
|
}
|
|
const r = await resolveWorkflowTarget(webapi, { id: 'F1', taskId: 'T1', userId: 'u1' })
|
|
expect(r.mode).toBe('targeted')
|
|
expect(r.operatorId).toBe('op1')
|
|
expect(r.status).toBe('ACTIONABLE')
|
|
})
|
|
|
|
it('--id 传但 operator 为空 → NO_ACTIONABLE_TASK', async () => {
|
|
const webapi = { getFlowTaskOperator: vi.fn().mockResolvedValue(null) }
|
|
const r = await resolveWorkflowTarget(webapi, { id: 'F1', taskId: 'T1', userId: 'u1' })
|
|
expect(r.status).toBe('NO_ACTIONABLE_TASK')
|
|
expect(r.exitCode).toBe(2)
|
|
})
|
|
|
|
it('不传 --id → 走通用 flowTodo 兼容模式', async () => {
|
|
const r = await resolveWorkflowTarget({}, { userId: 'u1' })
|
|
expect(r.mode).toBe('generic')
|
|
expect(r.status).toBe('GENERIC_PAGE')
|
|
})
|
|
}) |