P0-2: 修 form create buildSampleData 覆盖主子表 required 字段 (testspace TC-A 0/5 → 4/5)
- 根因 (dacli-2026-06-29-04): test/run.ts:144-168 硬关卡, 主子表 (tables.length>1) 无 --real-fields 直接 exit(1) - 实测 (testspace testjxcjp02ai): buildSampleData 已通过 jnpfKey='table' 遍历 cfg.children 生成完整 childRow, POST 返 code=200 - 修复: 去掉硬关卡, 软 warn 提示主子表 + 列出主/子表 tableName 参考, 仍允许 --real-fields 覆盖 - 同步: --real-fields help 文本去除'主子表必传'误导 - 边界: web 端 Form.vue 提交时强制校验所有 required 字段 (主子表都验), 不需在 dacli 侧重复 - 验证: testspace 创建主子表 form TC-A 5/5 PASS (无需 --real-fields); 单表 form 5/5 PASS (无回归)
This commit is contained in:
1 parent
961e5d2479
commit
070a4206ab
1 file changed
+17
-30
+17
-30
@@ -130,41 +130,28 @@ export function buildTestRunCommand(): Command {
|
||||
const formData = JSON.parse(schemaR.data.formData)
|
||||
const fields = formData.fields || []
|
||||
|
||||
// dacli-2026-06-29-04 fix: 主子表 TC-A 必传 --real-fields 硬关卡
|
||||
// 根因 (jxcj1teamv2 实战): buildSampleData 对主子表只填主表前 2 字段, 子表 required
|
||||
// 字段不会被自动覆盖 → POST create 必 FAIL (后端 VisualdevModelDataServiceImpl
|
||||
// 校验所有 required 字段, 子表 f_user_id 等空)
|
||||
// 修复: 检测到主子表 (tables.length > 1) 时, 强制用户传 --real-fields 覆盖子表
|
||||
// schema 已知 (单表也能用 --real-fields, 所以硬关卡精准到主子表)
|
||||
// 镜像: web 端 Form.vue 提交时强制校验所有 required 字段, 不分主子表
|
||||
// P0-2 fix (2026-07-15): 主子表自动 sample (testspace testjxcjp02ai 实战)
|
||||
// 旧 (dacli-2026-06-29-04): 主子表检测到 tables.length > 1 时强制 exit(1), 逼用户传 --real-fields
|
||||
// 根因: 当时 buildSampleData 对主子表只填主表前 2 字段, 不覆盖子表 children required 字段
|
||||
// 新 (实测 testjxcjp02ai): buildSampleData 已通过 jnpfKey='table' 遍历 cfg.children 生成完整 childRow,
|
||||
// POST /visualdev/OnlineDev/{formId} 返回 code=200 ("New created successfully")
|
||||
// 修复: 去掉硬关卡, 主子表也走 buildSampleData 自动 sample; 保留软 warn + 子表名参考
|
||||
// (用户想覆盖特定业务值仍可 --real-fields)
|
||||
// 边界: web 端 Form.vue 提交时强制校验所有 required 字段 (主子表都验) — 不需在 dacli 侧重复
|
||||
const tablesStr: string = schemaR.data.tables || '[]'
|
||||
let tablesArr: any[] = []
|
||||
try { tablesArr = JSON.parse(tablesStr) } catch { /* ignore */ }
|
||||
const isMainSubTable = Array.isArray(tablesArr) && tablesArr.length > 1
|
||||
if (isMainSubTable && !opts.realFields) {
|
||||
log.error(`dacli-2026-06-29-04 fix: 检测到主子表 (${tablesArr.length} 张), 必传 --real-fields 覆盖所有 required 字段`)
|
||||
log.error(` 例: --real-fields='{"f_main_field1":"v1","f_main_field2":"v2","jxcj1subtable":[{"f_sub_field1":"sv1"}]}'`)
|
||||
log.error(` 说明: buildSampleData 自动覆盖主表前 2 字段, 子表 required 字段需用户主动提供`)
|
||||
log.error(` 子表 tableName 参考:`)
|
||||
for (let i = 1; i < tablesArr.length; i++) {
|
||||
if (isMainSubTable) {
|
||||
log.warn(`⚠ 检测到主子表 (${tablesArr.length} 张), buildSampleData 自动覆盖主表 + 子表 children (P0-2 fix)`)
|
||||
log.warn(` 子表 tableName 参考:`)
|
||||
for (let i = 0; i < tablesArr.length; i++) {
|
||||
const t = tablesArr[i]
|
||||
const tName = t?.table || t?.tableName || `sub${i}`
|
||||
log.error(` - ${tName} (typeId=${t?.typeId || '?'}, relationTable=${t?.relationTable || '?'})`)
|
||||
const tName = t?.table || t?.tableName || `t${i}`
|
||||
const role = t?.typeId === '1' ? '主表' : '子表'
|
||||
log.warn(` - [${role}] ${tName} (typeId=${t?.typeId || '?'}, relationTable=${t?.relationTable || '?'})`)
|
||||
}
|
||||
if (opts.json) {
|
||||
printJson({
|
||||
ok: false,
|
||||
error: 'dacli-2026-06-29-04: 主子表 TC-A 必传 --real-fields',
|
||||
tableCount: tablesArr.length,
|
||||
subTables: tablesArr.slice(1).map((t: any) => ({
|
||||
table: t?.table,
|
||||
tableName: t?.tableName,
|
||||
relationTable: t?.relationTable,
|
||||
relationField: t?.relationField,
|
||||
})),
|
||||
})
|
||||
}
|
||||
process.exit(1)
|
||||
log.warn(` 想覆盖特定业务值: --real-fields='{"main_field":"v","subTableField":[{"sub_field":"sv"}]}'`)
|
||||
}
|
||||
|
||||
sample = await buildSampleData(fields, c, {
|
||||
@@ -549,7 +536,7 @@ export function buildTestRunCommand(): Command {
|
||||
'--output': '输出报告文件路径 (默认 stdout)',
|
||||
'--keep-data / --no-keep-data': '保留 / 删除测试数据 (默认 keep, 留数据供 TC-B 浏览器验证)',
|
||||
'--real-data / --no-real-data': '真实业务数据 / test fixture 模式 (默认 real-data)',
|
||||
'--real-fields <json>': '自定义真实业务数据 JSON (优先级最高; 主子表必传, dacli-2026-06-29-04 硬关卡)',
|
||||
'--real-fields <json>': '自定义真实业务数据 JSON (优先级最高; P0-2 fix 后主子表也走自动 sample, 无需强传)',
|
||||
'--relation-form-lookup / --no-relation-form-lookup': 'relationForm 自动 lookup 关联表真实 ID (默认 ON)',
|
||||
'--relation-form-sample <n>': '关联表拉前 N 条 (默认 1, 最大 5)',
|
||||
'--join-check / --join-rules <json>': '跨表 join 校验 (FK → 关联表)',
|
||||
|
||||
Reference in new issue
Block a user