test(16.2-06): admin SPA coverage of plugin field types and View site
- fieldTypes: one load per script URL, failed and refused scripts reported, global styles enabled on every screen, empty list on failure - registry, formState, FormField and ListView: plugin renderers, locale maps, notices as literal text, unknown column types as text - AppShell: the View site link's href, target, rel and en/pl label
This commit is contained in:
@@ -15,16 +15,21 @@ import PasswordField from '../../src/components/form/fields/PasswordField.vue'
|
||||
import PermissionEditorField from '../../src/components/form/fields/PermissionEditorField.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'
|
||||
import PluginField from '../../src/components/form/fields/PluginField.vue'
|
||||
import RelationManager from '../../src/components/relation/RelationManager.vue'
|
||||
import {
|
||||
controlAttributes,
|
||||
controlClass,
|
||||
groupLabelled,
|
||||
isPluginField,
|
||||
isRegistered,
|
||||
isRegisteredField,
|
||||
needsRecord,
|
||||
ownsLabel,
|
||||
RELATION_MANAGER,
|
||||
rendererFor,
|
||||
rendererForField,
|
||||
toggleOn,
|
||||
toggleValue,
|
||||
} from '../../src/components/form/registry'
|
||||
@@ -220,3 +225,32 @@ describe('markdown and multilingual field types (Phase 14.2.1)', () => {
|
||||
},
|
||||
)
|
||||
})
|
||||
|
||||
describe('plugin field types (Phase 16.2, D-13)', () => {
|
||||
const plugin = { name: 'notes', type: 'notes', element: 'acme-demo-notes' }
|
||||
|
||||
it('renders a field that names an element with PluginField, a translatable one with MLPluginField', () => {
|
||||
expect(rendererForField(plugin)).toBe(PluginField)
|
||||
expect(rendererForField({ ...plugin, translatable: true })).toBe(MLPluginField)
|
||||
expect(rendererForField({ ...plugin, translatable: false })).toBe(PluginField)
|
||||
})
|
||||
|
||||
it('keeps the core renderer for a core type, and the unsupported box for an unknown type without an element', () => {
|
||||
expect(rendererForField({ name: 'title', type: 'text' })).toBe(TextField)
|
||||
expect(rendererForField({ name: 'body', type: 'markdown' })).toBe(MarkdownField)
|
||||
expect(rendererForField({ name: 'x', type: 'notes' })).toBe(UnsupportedField)
|
||||
expect(rendererForField({ name: 'x', type: 'notes', element: '' })).toBe(UnsupportedField)
|
||||
})
|
||||
|
||||
it('counts a plugin field as registered and editable whatever its alias', () => {
|
||||
expect(isPluginField(plugin)).toBe(true)
|
||||
expect(isPluginField({ element: '' })).toBe(false)
|
||||
expect(isPluginField({})).toBe(false)
|
||||
expect(isRegisteredField(plugin)).toBe(true)
|
||||
expect(isRegisteredField({ name: 'x', type: 'text' })).toBe(true)
|
||||
expect(isRegisteredField({ name: 'x', type: 'notes' })).toBe(false)
|
||||
// The alias is not a core type: only the element makes it a plugin field.
|
||||
expect(isRegistered('notes')).toBe(false)
|
||||
expect(groupLabelled('notes')).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user