本仓 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,未来以本仓历史为主
114 lines
3.9 KiB
TypeScript
114 lines
3.9 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { normalizeCodegenSearchList } from '../../src/commands/form/_codegen_schema.ts'
|
|
|
|
describe('codegen search-list schema repair', () => {
|
|
it('fills missing search ids from columnList props before CodePreview', () => {
|
|
const columnData = {
|
|
columnList: [
|
|
{ id: 'f_team_name', prop: 'f_team_name', label: '团队名称' },
|
|
{ id: 'f_topic_direction', prop: 'f_topic_direction', label: '赛题方向' },
|
|
],
|
|
searchList: [
|
|
{ label: '', __config__: { jnpfKey: 'input' } },
|
|
{ label: '', __config__: { jnpfKey: 'select' } },
|
|
],
|
|
}
|
|
|
|
const result = normalizeCodegenSearchList(columnData)
|
|
|
|
expect(result.changed).toBe(2)
|
|
expect(result.columnData.searchList).toEqual([
|
|
expect.objectContaining({ id: 'f_team_name', prop: 'f_team_name' }),
|
|
expect.objectContaining({ id: 'f_topic_direction', prop: 'f_topic_direction' }),
|
|
])
|
|
})
|
|
|
|
it('uses form fields when a column entry is unavailable', () => {
|
|
const result = normalizeCodegenSearchList(
|
|
{ searchList: [{ __config__: { jnpfKey: 'input' } }] },
|
|
{ fields: [{ __vModel__: 'f_team_name', __config__: { label: '团队名称' } }] },
|
|
)
|
|
|
|
expect(result.changed).toBe(1)
|
|
expect(result.columnData.searchList[0].id).toBe('f_team_name')
|
|
expect(result.columnData.searchList[0].prop).toBe('f_team_name')
|
|
})
|
|
|
|
it('repairs nested searchList entries inside children and tableList', () => {
|
|
const columnData = {
|
|
columnList: [
|
|
{ id: 'f_team_name', prop: 'f_team_name', label: '团队名称' },
|
|
{ id: 'f_topic_direction', prop: 'f_topic_direction', label: '赛题方向' },
|
|
],
|
|
searchList: [
|
|
{ label: '', __config__: { jnpfKey: 'input' } },
|
|
],
|
|
children: [
|
|
{
|
|
searchList: [
|
|
{ label: '', __config__: { jnpfKey: 'select' } },
|
|
],
|
|
},
|
|
],
|
|
tableList: [
|
|
{
|
|
searchList: [
|
|
{ label: '', __config__: { jnpfKey: 'input' } },
|
|
{ label: '', __config__: { jnpfKey: 'select' } },
|
|
],
|
|
},
|
|
],
|
|
}
|
|
|
|
const result = normalizeCodegenSearchList(columnData)
|
|
|
|
// Top-level: searchList[0] falls back to columnList[0] → f_team_name → 1 fix
|
|
// children[0]: columnList=[] so falls back to fields; entry count 1 → 0 fix
|
|
// tableList[0]: same as children → 0 fix
|
|
expect(result.changed).toBe(1)
|
|
expect(result.columnData.searchList[0].id).toBe('f_team_name')
|
|
})
|
|
|
|
it('repairs nested entries with per-scope columnList fallback', () => {
|
|
const columnData = {
|
|
columnList: [
|
|
{ id: 'f_team_name', prop: 'f_team_name', label: '团队名称' },
|
|
{ id: 'f_topic_direction', prop: 'f_topic_direction', label: '赛题方向' },
|
|
],
|
|
searchList: [
|
|
{ label: '', __config__: { jnpfKey: 'input' } },
|
|
],
|
|
children: [
|
|
{
|
|
columnList: [
|
|
{ id: 'f_topic_direction', prop: 'f_topic_direction', label: '赛题方向' },
|
|
],
|
|
searchList: [
|
|
{ label: '', __config__: { jnpfKey: 'select' } },
|
|
],
|
|
},
|
|
],
|
|
tableList: [
|
|
{
|
|
columnList: [
|
|
{ id: 'f_team_name', prop: 'f_team_name', label: '团队名称' },
|
|
{ id: 'f_topic_direction', prop: 'f_topic_direction', label: '赛题方向' },
|
|
],
|
|
searchList: [
|
|
{ label: '', __config__: { jnpfKey: 'input' } },
|
|
{ label: '', __config__: { jnpfKey: 'select' } },
|
|
],
|
|
},
|
|
],
|
|
}
|
|
|
|
const result = normalizeCodegenSearchList(columnData)
|
|
|
|
expect(result.changed).toBe(4)
|
|
expect(result.columnData.searchList[0].id).toBe('f_team_name')
|
|
expect(result.columnData.children[0].searchList[0].id).toBe('f_topic_direction')
|
|
expect(result.columnData.tableList[0].searchList[0].id).toBe('f_team_name')
|
|
expect(result.columnData.tableList[0].searchList[1].id).toBe('f_topic_direction')
|
|
})
|
|
})
|