fix(admin): restore suite after colorpicker and codeeditor registration

- Expect colorpicker/codeeditor as registered controls; use notatype for unsupported cases
- Seed DatePicker placeholder from the model value so the calendar opens on that month
- Make CodeEditor chunk-failure mock reject the dynamic import

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-11-13 13:53:44 +01:00
parent 5f62cd6b92
commit e81cfde7b2
6 changed files with 32 additions and 16 deletions

View File

@@ -164,7 +164,9 @@ describe('field renderer', () => {
})
it('renders the unsupported box for an unknown type', () => {
const wrapper = mount(FieldRenderer, { props: { field: formField('color'), modelValue: '#fff', controlId: 'c' } })
const wrapper = mount(FieldRenderer, {
props: { field: { ...formField('color'), type: 'notatype' }, modelValue: '#fff', controlId: 'c' },
})
expect(wrapper.find('[data-unsupported-field]').exists()).toBe(true)
})
})

View File

@@ -55,7 +55,9 @@ describe('form state helpers', () => {
active: false,
unknown_key: 'x',
})
expect(body).toEqual({ name: 'Blue', tags: [3], active: false })
// colorpicker is a registered control (Phase 35); owner is read-only and
// members is a relation manager (not sent here).
expect(body).toEqual({ name: 'Blue', color: '#fff', tags: [3], active: false })
})
it('never sends widget or partial fields, even with a value under their name', () => {

View File

@@ -442,12 +442,12 @@ describe('CodeEditorField chunk failure', () => {
it('shows the load_failed note and a monospace textarea that still emits', async () => {
vi.resetModules()
vi.unmock('../../src/components/form/codeeditor/editor')
vi.doMock('../../src/components/form/codeeditor/editor', () => ({
createCodeEditor: () => {
throw new Error('chunk failed')
},
}))
vi.doUnmock('../../src/components/form/codeeditor/editor')
// Reject the dynamic import itself so a prior suite that already
// evaluated the real editor chunk cannot keep createCodeEditor working.
vi.doMock('../../src/components/form/codeeditor/editor', () => {
throw new Error('chunk failed')
})
;(await import('../../src/app/i18n')).setBundle({ ...mailPreviewBundle, ...codeeditorBundle }, 'en')
const Field = (await import('../../src/components/form/fields/CodeEditorField.vue')).default
const wrapper = mount(Field, {

View File

@@ -13,6 +13,8 @@ import MLTextareaField from '../../src/components/form/fields/MLTextareaField.vu
import MLTextField from '../../src/components/form/fields/MLTextField.vue'
import PasswordField from '../../src/components/form/fields/PasswordField.vue'
import PermissionEditorField from '../../src/components/form/fields/PermissionEditorField.vue'
import ColorPickerField from '../../src/components/form/fields/ColorPickerField.vue'
import CodeEditorField from '../../src/components/form/fields/CodeEditorField.vue'
import UnsupportedField from '../../src/components/form/fields/UnsupportedField.vue'
import WidgetField from '../../src/components/form/fields/WidgetField.vue'
import MLPluginField from '../../src/components/form/fields/MLPluginField.vue'
@@ -45,19 +47,21 @@ describe('field renderer registry (D-05)', () => {
['switch', SwitchField],
['checkbox', CheckboxField],
['relation', RelationField],
['colorpicker', ColorPickerField],
['codeeditor', CodeEditorField],
[RELATION_MANAGER, RelationManager],
])('renders %s with its control', (type, component) => {
expect(rendererFor(type)).toBe(component)
})
it.each(['colorpicker', 'codeeditor', '', 'TEXT', 'constructor'])('falls back to UnsupportedField for %j', (type) => {
it.each(['notatype', '', 'TEXT', 'constructor'])('falls back to UnsupportedField for %j', (type) => {
expect(rendererFor(type)).toBe(UnsupportedField)
expect(isRegistered(type)).toBe(false)
})
it('edits values of every control type except the record-bound relation manager', () => {
expect(RELATION_MANAGER).toBe('relation-manager')
for (const type of ['text', 'textarea', 'number', 'dropdown', 'switch', 'checkbox', 'relation']) {
for (const type of ['text', 'textarea', 'number', 'dropdown', 'switch', 'checkbox', 'relation', 'colorpicker', 'codeeditor']) {
expect(isRegistered(type), type).toBe(true)
expect(needsRecord(type), type).toBe(false)
}