本仓 2026-08-12 从 ssw main (192.168.1.18:13300/ssw/ssw-mvp) 的 dacli/ subpath 抽取,作为独立仓托管到 gitea:3000/ssw/dacli.git。 - 工作树为 ssw main dacli subpath 最新版 (110 commit, 08-12) - 历史未带 ssw main 整体历史(避免大仓污染) - 此为新仓基线 commit,未来以本仓历史为主
85 lines
2.4 KiB
TypeScript
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)
|
|
})
|
|
}) |