Round 12 drift loop on ts2 (5 random baseline per module) surfaced:
- BS-新38: 5/8 modules fail BS-56 when --enCode='round12-foo' contains '-'.
Add autoStripEnCode() helper + apply at 7 create.ts action entries.
workflow/_validate.ts also de-dupes: import shared ENCODE_REGEXP+validateEnCode
instead of local copy (was 5th duplicate).
- BS-新39: 4/5 DI hit 'name cannot be repeated' (BS-47 EXIST002) at backend.
Root cause: di/create.ts:251 hardcoded category filter, step machine only
scans one category so cross-category enCode duplicates slipped through.
Fix: remove hardcoded filter, scan all DIs platform-wide. Better error msg.
- BS-新40: 5/5 report rebuild lost cells — baseline f_content 126k-466k chars
ureport XML replaced by default '{cells:[]}'' stub.
Fix: add --from-json-file option (mirrors di/create.ts pattern), reads full
baseline body and overrides required fields.
Tests: 28/28 PASS
- tests/integration/drift/round12-cross-module.spec.ts (Round 12 sweep)
- tests/integration/drift/round12-fix-batch1.spec.ts (batch 1 regression)
Docs: docs/drift/2026-07-15-round12-summary.md + ...-fix-batch1.md
Co-Authored-By: Claude <[email protected]>
123 lines
4.5 KiB
TypeScript
123 lines
4.5 KiB
TypeScript
/**
|
|
* ts2-menu-drift.spec.ts — Round 15 (ts2 应用) menu drift 测试 (2026-07-15)
|
|
*
|
|
* 目的: 在 ts2 重建 5 个 baseline 菜单 (低级模式, 顶级 parentId=-1), 验证 moduleId
|
|
* /category 等保留情况.
|
|
*
|
|
* 数据源:
|
|
* - baseline: 5 随机 (extend.tableDemo.mergeTable/nianjiaguanli50fca/fukuane/workFlow/kezhan)
|
|
* - rebuilt: ts2
|
|
*
|
|
* 漂移类别 (Round 15 ts2 实测):
|
|
* - BS-drift-M-1: moduleId_lost type=5/9 (报表/工作流菜单) — 2/5 命中
|
|
* (Round 5 修复仅对 type=3 VisualDev 生效)
|
|
* - BS-drift-M-2: category_drift (workFlow category=App → Web) — 1/5 命中
|
|
* - 保真: type / urlAddress / icon (5/5)
|
|
*/
|
|
|
|
import { describe, it, expect } from 'vitest'
|
|
import { readFileSync } from 'fs'
|
|
|
|
const REBUILT_MENUS = [
|
|
{
|
|
baselineEnCode: 'extend.tableDemo.mergeTable',
|
|
baselineType: 2, baselineUrl: 'extend/tableDemo/mergeTable', baselineModuleId: '',
|
|
baselineCategory: 'Web',
|
|
rebuiltEnCode: 'drift15extend_tableDemo_mergeTable',
|
|
rebuiltId: '846969846880010757',
|
|
},
|
|
{
|
|
baselineEnCode: 'nianjiaguanli50fca',
|
|
baselineType: 3, baselineUrl: 'model/nianjiaguanli50fca', baselineModuleId: '469040281883306373',
|
|
baselineCategory: 'Web',
|
|
rebuiltEnCode: 'drift15nianjiaguanli50fca',
|
|
rebuiltId: '846969922838856197',
|
|
},
|
|
{
|
|
baselineEnCode: 'fukuane',
|
|
baselineType: 9, baselineUrl: 'model/fukuane', baselineModuleId: '588010241019348677',
|
|
baselineCategory: 'Web',
|
|
rebuiltEnCode: 'drift15fukuane',
|
|
rebuiltId: '846970018427044357',
|
|
},
|
|
{
|
|
baselineEnCode: 'workFlow',
|
|
baselineType: 1, baselineUrl: '', baselineModuleId: '',
|
|
baselineCategory: 'App',
|
|
rebuiltEnCode: 'drift15workFlow',
|
|
rebuiltId: '846970108436808197',
|
|
},
|
|
{
|
|
baselineEnCode: 'kezhan',
|
|
baselineType: 5, baselineUrl: 'dataReport/kezhan', baselineModuleId: 'e214bbc87805480184a91eca635100a4',
|
|
baselineCategory: 'Web',
|
|
rebuiltEnCode: 'drift15kezhan',
|
|
rebuiltId: '846970177881899525',
|
|
},
|
|
]
|
|
|
|
function getRebuiltMenu(enc: string): any {
|
|
const d = JSON.parse(readFileSync(`/tmp/dacli-loop/ts2/menu/${enc}.json`, 'utf-8'))
|
|
// 菜单快照里 propertyJson 可能是 JSON 字符串, 解析出来拿 moduleId
|
|
if (typeof d.propertyJson === 'string' && d.propertyJson) {
|
|
try { d.propertyJson = JSON.parse(d.propertyJson) } catch {}
|
|
}
|
|
return d
|
|
}
|
|
|
|
describe('ts2-menu-drift: moduleId_lost type=5/9 — BS-drift-M-1 (Round 5 fix 局限)', () => {
|
|
/**
|
|
* 漂移模式: dacli menu create --moduleId 仅对 type=3 VisualDev 触发 BS-drift-M-1 fix;
|
|
* type=5(报表)/type=9(工作流) 静默丢弃 moduleId.
|
|
* 命中: fukuane(t9)/kezhan(t5) — 2/5.
|
|
*/
|
|
it('BS-drift-M-1: fukuane (type=9) baseline moduleId=588010241019348677 → rebuilt 空', () => {
|
|
const m = REBUILT_MENUS.find(x => x.baselineEnCode === 'fukuane')!
|
|
const d = getRebuiltMenu(m.rebuiltEnCode)
|
|
expect(m.baselineModuleId).not.toBe('')
|
|
const pj = d.propertyJson || {}
|
|
expect(pj.moduleId || d.moduleId || '').toBe('') // 漂移证据
|
|
})
|
|
|
|
it('BS-drift-M-1: kezhan (type=5) baseline moduleId=e214bbc87... → rebuilt 空', () => {
|
|
const m = REBUILT_MENUS.find(x => x.baselineEnCode === 'kezhan')!
|
|
const d = getRebuiltMenu(m.rebuiltEnCode)
|
|
expect(m.baselineModuleId).not.toBe('')
|
|
const pj = d.propertyJson || {}
|
|
expect(pj.moduleId || d.moduleId || '').toBe('')
|
|
})
|
|
})
|
|
|
|
describe('ts2-menu-drift: category_drift — BS-drift-M-2', () => {
|
|
/**
|
|
* 漂移模式: dacli menu create 默认 --category=Web, 移动端 App 入口丢失.
|
|
* 命中: workFlow (baseline category=App) — 1/5.
|
|
*/
|
|
it('BS-drift-M-2: workFlow (type=1) baseline category=App → rebuilt=Web', () => {
|
|
const m = REBUILT_MENUS.find(x => x.baselineEnCode === 'workFlow')!
|
|
const d = getRebuiltMenu(m.rebuiltEnCode)
|
|
expect(m.baselineCategory).toBe('App')
|
|
expect(d.category).toBe('Web') // 漂移证据
|
|
})
|
|
})
|
|
|
|
describe('ts2-menu-drift: 保真字段 (正向回归)', () => {
|
|
it.each(REBUILT_MENUS)(
|
|
'rebuilt $rebuiltEnCode type 与 baseline type 一致',
|
|
({ rebuiltEnCode, baselineType }) => {
|
|
const d = getRebuiltMenu(rebuiltEnCode)
|
|
expect(d.type).toBe(baselineType)
|
|
}
|
|
)
|
|
|
|
it.each(REBUILT_MENUS)(
|
|
'rebuilt $rebuiltEnCode urlAddress 与 baseline 一致 (null 等价 "")',
|
|
({ rebuiltEnCode, baselineUrl }) => {
|
|
const d = getRebuiltMenu(rebuiltEnCode)
|
|
// workFlow baseline url="" 重建为 null (JNPF 序列化语义)
|
|
const a = d.urlAddress === null ? '' : d.urlAddress
|
|
expect(a).toBe(baselineUrl)
|
|
}
|
|
)
|
|
})
|