fix(admin): isolate CodeMirror load for chunk-failure tests

- Route CodeEditorField through codeeditor/load so vitest can mock the chunk
- Keep registry expectations for colorpicker/codeeditor without importing the editor SFC

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-11-13 13:57:16 +01:00
parent e81cfde7b2
commit 1df2e31dea
4 changed files with 30 additions and 15 deletions

View File

@@ -14,7 +14,6 @@ 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'
@@ -48,12 +47,21 @@ describe('field renderer registry (D-05)', () => {
['checkbox', CheckboxField],
['relation', RelationField],
['colorpicker', ColorPickerField],
['codeeditor', CodeEditorField],
[RELATION_MANAGER, RelationManager],
])('renders %s with its control', (type, component) => {
expect(rendererFor(type)).toBe(component)
})
// codeeditor is registered (Phase 35) but not imported here: a static import
// of CodeEditorField would evaluate its CodeMirror chunk and break the
// mail-smoke chunk-failure mock that relies on vi.resetModules.
it('registers codeeditor as an editable control', () => {
expect(isRegistered('codeeditor')).toBe(true)
expect(needsRecord('codeeditor')).toBe(false)
expect(rendererFor('codeeditor')).not.toBe(UnsupportedField)
expect(rendererFor('codeeditor').__name).toBe('CodeEditorField')
})
it.each(['notatype', '', 'TEXT', 'constructor'])('falls back to UnsupportedField for %j', (type) => {
expect(rendererFor(type)).toBe(UnsupportedField)
expect(isRegistered(type)).toBe(false)