Files
ssw-mvp/dacli/tests/e2e/step-machine/workflow-validate.test.ts
T
admin 4d096dd97e chore(dacli): 提交 dacli CLI 工具源码并过滤敏感/噪声文件
- dacli/ 整目录被 .gitignore 忽略,本次 force-add 其业务源码(766 文件)
- 排除 node_modules/.env(含 PGPASSWORD 等敏感信息)/.DS_Store/__pycache__/*.pyc
- 新增 dacli/.gitignore 长期管理内部噪声,新增文件仍需 git add -f
- 根 .gitignore 补充 .cache/ 与诊断脚本忽略,并加 dacli 段说明
2026-08-06 19:02:39 +08:00

85 lines
2.4 KiB
TypeScript

/**
* vitest test: workflow/_validate.ts (Phase D2 E2E 自动化)
*/
import { describe, it, expect } from 'vitest'
import { validateWorkflowCreate } from '../../../src/commands/workflow/_validate.ts'
describe('workflow/_validate.ts step machine', () => {
it('成功路径: 合法 fullName + enCode + category + icon + flowXml', () => {
const r = validateWorkflowCreate({
fullName: '测试流程',
enCode: 'test.flow',
category: 'workflow_category',
icon: 'icon-ym icon-ym-flow',
showType: 0,
type: 0,
flowXml: '<?xml version="1.0"?><bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL"/>',
flowNodes: {
start: { nodeType: 'startEvent' },
end: { nodeType: 'endEvent' },
},
})
expect(r.ok).toBe(true)
})
it('flowXml 不是合法 BPMN → 拦截', () => {
const r = validateWorkflowCreate({
fullName: 'X',
enCode: 'xtest',
category: 'c',
icon: 'i',
showType: 0,
type: 0,
flowXml: 'not xml',
flowNodes: {},
})
expect(r.steps[1].errors.some((e) => e.field === 'flowXml')).toBe(true)
})
it('flowNodes 缺 start 节点 → 拦截 (BS-45)', () => {
const r = validateWorkflowCreate({
fullName: 'X',
enCode: 'xtest',
category: 'c',
icon: 'i',
showType: 0,
type: 0,
flowXml: '<bpmn:definitions/>',
flowNodes: {
end: { nodeType: 'endEvent' },
},
})
expect(r.steps[1].errors.some((e) => e.message.includes('开始节点'))).toBe(true)
})
it('flowNodes 缺 end 节点 → 拦截 (BS-45)', () => {
const r = validateWorkflowCreate({
fullName: 'X',
enCode: 'xtest',
category: 'c',
icon: 'i',
showType: 0,
type: 0,
flowXml: '<bpmn:definitions/>',
flowNodes: {
start: { nodeType: 'startEvent' },
},
})
expect(r.steps[1].errors.some((e) => e.message.includes('结束节点'))).toBe(true)
})
it('enCode 唯一性预校验 → WF054', () => {
const r = validateWorkflowCreate({
fullName: 'X',
enCode: 'dupflow',
category: 'c',
icon: 'i',
showType: 0,
type: 0,
flowXml: '<bpmn:definitions/>',
flowNodes: { start: { nodeType: 'startEvent' }, end: { nodeType: 'endEvent' } },
existingEnCodes: ['dupflow'],
})
expect(r.steps[2].errors.some((e) => e.code === 'WF054')).toBe(true)
})
})