- form create: extract applyFinalSmartProps/shouldRunFinalSmartProps so
--ai-only paths also re-run smart props after the final buildFormData.
Adds unit test for the gate predicate.
- form update: mergeFormFieldUpdates deep-merges __config__ and matches
vmodel/__vModel__, preventing schema loss on partial diffs.
- form info: new --bindings projection flattens field configs to
{field, jnpfKey, dataType, dictionaryType, modelId, required} for
callers without jq piercing the JNPF nested formData JSON.
- form codegen: normalizeCodegenSearchList now walks children/tableList
payloads; new _codegen_schema helper repairs searchList id/prop across
nested scopes, avoiding SearchTypeModel.id NPE in JNPF CodeGenerateFactoryV3.
- di list: enrichDataInterfaceListWithEnCode backfills the enCode field
selector omits; walks every category folder so callers can filter on
enCode reliably.
- test run: pickChoiceValue routes select/radio/checkbox through
loadDict.getDictionaryDataSelector (cached) before falling back to
options[0].value, removing the brittle dependency on option order.
Tests: 56/56 PASS across 9 unit specs.
81 lines
1.9 KiB
TypeScript
81 lines
1.9 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { projectFormBindings } from '../../src/commands/form/info.ts'
|
|
|
|
describe('form info --bindings projection', () => {
|
|
it('flattens select fields with dictionary metadata', () => {
|
|
const bindings = projectFormBindings({
|
|
formData: {
|
|
fields: [
|
|
{
|
|
__vModel__: 'f_topic_direction',
|
|
__config__: {
|
|
jnpfKey: 'select',
|
|
label: '赛题方向',
|
|
dataType: 'dictionary',
|
|
dictionaryType: 'dict-1',
|
|
},
|
|
},
|
|
{
|
|
__vModel__: 'f_team_name',
|
|
__config__: {
|
|
jnpfKey: 'input',
|
|
label: '团队名称',
|
|
required: true,
|
|
},
|
|
},
|
|
],
|
|
},
|
|
})
|
|
expect(bindings).toEqual([
|
|
{
|
|
field: 'f_topic_direction',
|
|
jnpfKey: 'select',
|
|
label: '赛题方向',
|
|
dataType: 'dictionary',
|
|
dictionaryType: 'dict-1',
|
|
required: false,
|
|
modelId: null,
|
|
},
|
|
{
|
|
field: 'f_team_name',
|
|
jnpfKey: 'input',
|
|
label: '团队名称',
|
|
dataType: null,
|
|
dictionaryType: null,
|
|
required: true,
|
|
modelId: null,
|
|
},
|
|
])
|
|
})
|
|
|
|
it('skips entries without __vModel__', () => {
|
|
const bindings = projectFormBindings({
|
|
formData: {
|
|
fields: [
|
|
{ __config__: { jnpfKey: 'input' } },
|
|
],
|
|
},
|
|
})
|
|
expect(bindings).toEqual([])
|
|
})
|
|
|
|
it('keeps entries with __vModel__ but missing __config__', () => {
|
|
const bindings = projectFormBindings({
|
|
formData: {
|
|
fields: [{ __vModel__: 'f_a' }],
|
|
},
|
|
})
|
|
expect(bindings).toEqual([
|
|
{
|
|
field: 'f_a',
|
|
jnpfKey: undefined,
|
|
label: undefined,
|
|
dataType: null,
|
|
dictionaryType: null,
|
|
required: false,
|
|
modelId: null,
|
|
},
|
|
])
|
|
})
|
|
})
|