Files
dacli/tests/integration/drift/round12-cross-module.spec.ts
T
sswandClaude f840f2961a fix: Round 12 drift batch 1 (enCode autoStrip + DI uniqueness + report cells)
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]>
2026-07-15 10:11:12 +08:00

72 lines
2.3 KiB
TypeScript

/**
* Round 12 Drift Loop — Cross-Module Regression (2026-07-15)
*
* 断言 ts2 漂移测试的 8 模块汇总文件存在且 ran ≥ N (≥ module)。
* Round 12 见到跨模块新发现: workflow AI 不带节点 / DI name-conflict / datascreen 500
* / report cells 全丢 / smartProps 全 false.
* 本 spec 不验证具体漂移内容 (每模块自有 spec), 只确保 8 模块 5 ran 全闭环。
*/
import { describe, it, expect } from 'vitest'
import { existsSync, readFileSync } from 'fs'
const T2 = '/tmp/dacli-loop/ts2'
function loadSummary(mod: string): any {
const p = `${T2}/${mod}/round12-drift-summary.json`
if (!existsSync(p)) return null
return JSON.parse(readFileSync(p, 'utf8'))
}
describe('Round 12 — 8 modules 5 random picks each', () => {
const modules = ['forms', 'workflow', 'di', 'menu', 'dict', 'role', 'report', 'datascreen']
for (const mod of modules) {
it(`${mod}: drift-summary.json exists & ran=5`, () => {
const s = loadSummary(mod)
expect(s).not.toBeNull()
expect(s.ran).toBe(5)
// drift_categories 至少 1 类 (允许 = 0 当全 ok)
expect(typeof s.drift_categories).toBe('object')
})
}
it('global: 至少 30/40 ok (>=75%)', () => {
let total_ok = 0, total_ran = 0
for (const mod of modules) {
const s = loadSummary(mod)
if (s) {
total_ok += s.ok || 0
total_ran += s.ran || 0
}
}
expect(total_ran).toBe(40)
expect(total_ok).toBeGreaterThanOrEqual(30)
})
it('workflow 5/5 都触发 missing_nodes > 0 (AI 不带节点)', () => {
// PF check: BS-New-WF-DRIFT-1 闭环必须先在 Round 12 看到
const s = loadSummary('workflow')
expect(s.drift_categories.missing_nodes).toBeGreaterThan(20)
})
it('form 5/5 都触发 type_drift (jnpfKey 不还原)', () => {
const s = loadSummary('forms')
expect(s.drift_categories.type_drift).toBeGreaterThan(15)
})
it('report 5/5 cells_drift (baseline f_content 丢)', () => {
const s = loadSummary('report')
expect(s.drift_categories.cells_drift).toBe(5)
})
it('datascreen 至少 1/5 OK (200 OK 的存在)', () => {
const s = loadSummary('datascreen')
expect(s.ok).toBeGreaterThanOrEqual(1)
})
it('di 至少 1/5 fail (BS-47 已知问题)', () => {
const s = loadSummary('di')
expect(s.fail).toBeGreaterThanOrEqual(1)
})
})