jxcj 浏览器 E2E 发现: dacli form create 写 defaultSortConfig: {} (object),
但 web ColumnDesign/src/helper/config.ts:122 是 array. JNPF 前端 TableList.vue
调 .map() 时 object 抛 TypeError, vxe-toolbar 渲染失败, '新增'按钮看不见.
BS-52 schema 层 PASS 但视觉层 FAIL, 经典 tds2 假 PASS 复盘场景.
修复:
- create.ts:400 defaultSortConfig: {} → [] (加注释引用 web config.ts:122)
- tests/unit/defaultSortConfig.test.ts: 3 个 case 回归 (含防回退注释断言)
- /tmp/fix_defaultSortConfig.mjs: 跑 28 jxcj form 全部 patch (Fixed 28 / Skipped 0)
- 顺手修 appColumnData (同 bug)
单测 3/3 PASS
实测 jxcj_competition_info verify: 'array ✓'
Co-Authored-By: Claude <[email protected]>
53 lines
2.4 KiB
TypeScript
53 lines
2.4 KiB
TypeScript
/**
|
|
* defaultSortConfig.test.ts — 验证 create.ts 自动给 defaultSortConfig: []
|
|
*
|
|
* 回归测试 (v0.11, jxcj E2E 发现):
|
|
* web ColumnDesign/src/helper/config.ts:122 定义 defaultSortConfig: []
|
|
* dacli create.ts 之前写 {} 导致 JNPF 前端 TableList.vue .map() TypeError,
|
|
* vxe-toolbar 渲染失败, "新增"按钮看不见 (BS-52 浏览器层假 PASS).
|
|
*
|
|
* 此测试覆盖:
|
|
* 1. create.ts 源码里 defaultSortConfig 必须是 array [] (非 {} / null)
|
|
* 2. 注释里必须出现 "修复" 字样说明 web 期望 array (防再回退到 {})
|
|
*/
|
|
import { describe, it, expect } from 'vitest'
|
|
import { readFileSync } from 'node:fs'
|
|
import { resolve } from 'node:path'
|
|
import { fileURLToPath } from 'node:url'
|
|
|
|
const __dirname = fileURLToPath(new URL('.', import.meta.url))
|
|
const CREATE_TS = resolve(__dirname, '../../src/commands/form/create.ts')
|
|
|
|
function readCreate(): string {
|
|
return readFileSync(CREATE_TS, 'utf-8')
|
|
}
|
|
|
|
describe('form create columnData.defaultSortConfig (v0.11 jxcj E2E 闭环)', () => {
|
|
it('create.ts 里 defaultSortConfig 必须是 [] (array), 不是 {}', () => {
|
|
const src = readCreate()
|
|
// 找 "defaultSortConfig:" 紧跟 4 行内的值定义
|
|
const match = src.match(/defaultSortConfig:\s*(\[[^\]]*\]|\{[^}]*\})/)
|
|
expect(match, 'create.ts 找不到 defaultSortConfig 字段').toBeTruthy()
|
|
const val = match![1]
|
|
expect(val.startsWith('['), `defaultSortConfig 应是 array [] 开头, 实际是: ${val.slice(0, 40)}`).toBe(true)
|
|
expect(val.endsWith(']'), `defaultSortConfig 应是 array [] 结尾, 实际是: ${val.slice(-40)}`).toBe(true)
|
|
// 显式禁止 {}
|
|
expect(val, 'defaultSortConfig 不应是 {} object').not.toBe('{}')
|
|
})
|
|
|
|
it('create.ts 修复注释必须引用 web 源码定位 (config.ts:122)', () => {
|
|
const src = readCreate()
|
|
// 找 defaultSortConfig 上面 10 行内必须有 "config.ts:122" 引用
|
|
const idx = src.indexOf('defaultSortConfig:')
|
|
expect(idx, 'create.ts 找不到 defaultSortConfig: 字段').toBeGreaterThan(0)
|
|
const before = src.slice(Math.max(0, idx - 800), idx)
|
|
expect(before).toMatch(/config\.ts:122/)
|
|
})
|
|
|
|
it('create.ts 修复注释必须说明 web 期望 array (防止再退回 {})', () => {
|
|
const src = readCreate()
|
|
const idx = src.indexOf('defaultSortConfig:')
|
|
const before = src.slice(Math.max(0, idx - 800), idx)
|
|
expect(before.toLowerCase()).toMatch(/array/)
|
|
})
|
|
}) |