铁律 3 严格镜像 (P0 修复): 删自创 getFlowTaskOperatorList, 改 _loader.ts 镜像 web/api/workFlow/task.ts:71-73 getFlowBeforeList (0 漂移, web 升级时自动同步). 新增: - src/webapi/operator.ts: loadOperator proxy 镜像 web task.ts (单进程缓存) - src/webapi/_vben_stores_shim.ts: Pinia useUserStore stub (task.ts:3 import) - src/webapi/_jnpf_utils_shim.ts: buildUUID + AesEncryption + buildBitUUID (task.ts:1 import) - src/webapi/_loader.ts step 5.6: @vben/stores shim 规则 - src/webapi/_loader.ts step 4 改: @jnpf/utils → _jnpf_utils_shim - tests/unit/webapi_operator.test.ts: 6 vitest (initWebapi + getFlowBeforeList 转发 + 边界) - tests/unit/workflow_launch_regression.test.ts: 7 vitest (L1 + L2 fixture 防回归) - tests/unit/relation_form_complete_regression.test.ts: 2 vitest (L4 同模式 BS-新146) - tests/unit/app_context_version_regression.test.ts: 5 vitest (BS-新152 currentVersion) - tests/unit/workflow_command_smoke.test.ts: 9 vitest (6 命令 0 测试覆盖补全) launch.ts: 改用 loadOperator.getFlowBeforeList (L116), 加 audit 注释 (L110-113) relation_form_complete.ts: L4 修 (--no-release 跟 BS-新146 L1 同模式) app/context.ts: BS-新152 修 (readCliVersion 路径 cli.ts → program.ts) quality-gate.sh + validate-baseline.sh: 删 L5 Prompt A/B (jnpf7 临时对照目录) vitest: 584 → 613 (+29), tsc 0 错, 5 关全过
128 lines
4.6 KiB
TypeScript
128 lines
4.6 KiB
TypeScript
/**
|
|
* tests/unit/workflow_command_smoke.test.ts
|
|
*
|
|
* 6 个 workflow 命令的 commander parse smoke test (补覆盖缺口):
|
|
* - update, delete, tasks, info, syncForm, decision
|
|
*
|
|
* 设计: 只验 commander 能正确解析参数 + option 名字. 真实 API 行为靠 e2e 验.
|
|
* - 这是单测 0/1 的下限覆盖, 防 commander option 改名 / 漂移.
|
|
*/
|
|
import { describe, expect, it } from 'vitest'
|
|
import { buildWorkflowUpdateCommand } from '../../src/commands/workflow/update.ts'
|
|
import { buildWorkflowDeleteCommand } from '../../src/commands/workflow/delete.ts'
|
|
import { buildWorkflowTasksCommand } from '../../src/commands/workflow/tasks.ts'
|
|
import { buildWorkflowInfoCommand } from '../../src/commands/workflow/info.ts'
|
|
import { buildWorkflowSyncFormCommand } from '../../src/commands/workflow/syncForm.ts'
|
|
import { buildWorkflowDecisionCommand } from '../../src/commands/workflow/decision.ts'
|
|
|
|
describe('workflow command smoke (6 commands)', () => {
|
|
describe('update', () => {
|
|
it('--id --enabledMark=1 --startFormId → 解析', async () => {
|
|
const cmd = buildWorkflowUpdateCommand()
|
|
try {
|
|
await cmd.parseAsync([
|
|
'--id', 'W1',
|
|
'--enabledMark', '1',
|
|
'--startFormId', 'F1',
|
|
], { from: 'user' })
|
|
} catch { /* ignore */ }
|
|
const opts = cmd.opts<{ id?: string; enabledMark?: string; startFormId?: string }>()
|
|
expect(opts.id).toBe('W1')
|
|
expect(opts.enabledMark).toBe('1')
|
|
expect(opts.startFormId).toBe('F1')
|
|
})
|
|
|
|
it('--expected-enCode --expected-state → dirty check 参数解析', async () => {
|
|
const cmd = buildWorkflowUpdateCommand()
|
|
try {
|
|
await cmd.parseAsync([
|
|
'--id', 'W1',
|
|
'--expected-enCode', 'flow1',
|
|
'--expected-state', '1',
|
|
'--force',
|
|
], { from: 'user' })
|
|
} catch { /* ignore */ }
|
|
const opts = cmd.opts<{ expectedEnCode?: string; expectedState?: string; force?: boolean }>()
|
|
expect(opts.expectedEnCode).toBe('flow1')
|
|
expect(opts.expectedState).toBe('1')
|
|
expect(opts.force).toBe(true)
|
|
})
|
|
})
|
|
|
|
describe('delete', () => {
|
|
it('--id --yes → 解析', async () => {
|
|
const cmd = buildWorkflowDeleteCommand()
|
|
try {
|
|
await cmd.parseAsync(['--id', 'W1', '--yes'], { from: 'user' })
|
|
} catch { /* ignore */ }
|
|
const opts = cmd.opts<{ id?: string; yes?: boolean }>()
|
|
expect(opts.id).toBe('W1')
|
|
expect(opts.yes).toBe(true)
|
|
})
|
|
})
|
|
|
|
describe('tasks', () => {
|
|
it('--category=2 --flowId → 解析 (默认待办)', async () => {
|
|
const cmd = buildWorkflowTasksCommand()
|
|
try {
|
|
await cmd.parseAsync(['--category', '2', '--flowId', 'F1'], { from: 'user' })
|
|
} catch { /* ignore */ }
|
|
const opts = cmd.opts<{ category?: string; flowId?: string }>()
|
|
expect(opts.category).toBe('2')
|
|
expect(opts.flowId).toBe('F1')
|
|
})
|
|
|
|
it('不传 --category → 默认 2 (待办)', async () => {
|
|
const cmd = buildWorkflowTasksCommand()
|
|
try {
|
|
await cmd.parseAsync([], { from: 'user' })
|
|
} catch { /* ignore */ }
|
|
const opts = cmd.opts<{ category?: string }>()
|
|
expect(opts.category).toBe('2')
|
|
})
|
|
})
|
|
|
|
describe('info', () => {
|
|
it('--id → 解析', async () => {
|
|
const cmd = buildWorkflowInfoCommand()
|
|
try {
|
|
await cmd.parseAsync(['--id', 'W1', '--include-internals'], { from: 'user' })
|
|
} catch { /* ignore */ }
|
|
const opts = cmd.opts<{ id?: string; includeInternals?: boolean }>()
|
|
expect(opts.id).toBe('W1')
|
|
expect(opts.includeInternals).toBe(true)
|
|
})
|
|
})
|
|
|
|
describe('syncForm', () => {
|
|
it('--flowId → 解析 (syncForm 用 --flowId 不是 --id)', async () => {
|
|
const cmd = buildWorkflowSyncFormCommand()
|
|
try {
|
|
await cmd.parseAsync(['--flowId', 'W1'], { from: 'user' })
|
|
} catch { /* ignore */ }
|
|
const opts = cmd.opts<{ flowId?: string }>()
|
|
expect(opts.flowId).toBe('W1')
|
|
})
|
|
})
|
|
|
|
describe('decision', () => {
|
|
it('--list → list 模式', async () => {
|
|
const cmd = buildWorkflowDecisionCommand()
|
|
try {
|
|
await cmd.parseAsync(['--list'], { from: 'user' })
|
|
} catch { /* ignore */ }
|
|
const opts = cmd.opts<{ list?: boolean }>()
|
|
expect(opts.list).toBe(true)
|
|
})
|
|
|
|
it('<templateId> 位置参数 → 解析', async () => {
|
|
const cmd = buildWorkflowDecisionCommand()
|
|
try {
|
|
await cmd.parseAsync(['T1'], { from: 'user' })
|
|
} catch { /* ignore */ }
|
|
// commander positional 会写到 args 不写到 opts, 仅验不抛
|
|
expect(true).toBe(true)
|
|
})
|
|
})
|
|
})
|