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:
@@ -5,6 +5,7 @@ import FormErrorBanner from '../../src/components/form/FormErrorBanner.vue'
|
||||
import FormField from '../../src/components/form/FormField.vue'
|
||||
import { clone, extensionFormSchemaFixture, formField } from '../fixtures/typed'
|
||||
import { mockApi, resetState } from '../helpers'
|
||||
import type { FormField as FormFieldSchema } from '../../src/api/types'
|
||||
|
||||
beforeEach(() => {
|
||||
resetState()
|
||||
@@ -32,6 +33,40 @@ describe('save notices', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('plugin field rows (Phase 16.2)', () => {
|
||||
const plugin: FormFieldSchema = { name: 'content', type: 'blogeditor', element: 'acme-demo-never-defined', label: 'Content', comment: 'Edited in the plugin element' }
|
||||
|
||||
it('labels the plugin element group with a span, never a label for an input', () => {
|
||||
const wrapper = mount(FormField, { props: { field: plugin, modelValue: '', idPrefix: 'f' } })
|
||||
expect(wrapper.find('label').exists()).toBe(false)
|
||||
expect(wrapper.find('span#f-content-label').text()).toBe('Content')
|
||||
const group = wrapper.find('[data-plugin-field]')
|
||||
expect(group.attributes('aria-labelledby')).toBe('f-content-label')
|
||||
expect(group.attributes('aria-describedby')).toBe('f-content-comment')
|
||||
})
|
||||
|
||||
it('renders plugin notices as literal text linked to the group', () => {
|
||||
const wrapper = mount(FormField, {
|
||||
props: { field: plugin, modelValue: '', notices: ['EN: 1 element was removed: <script>', 'PL: Usunięto 1 atrybut: onclick'], idPrefix: 'f' },
|
||||
})
|
||||
const line = wrapper.find('#f-content-notice')
|
||||
expect(line.attributes('role')).toBe('status')
|
||||
expect(line.findAll('p').map((p) => p.text())).toEqual(['EN: 1 element was removed: <script>', 'PL: Usunięto 1 atrybut: onclick'])
|
||||
expect(line.find('script').exists()).toBe(false)
|
||||
expect(wrapper.find('[data-plugin-field]').attributes('aria-describedby')).toBe('f-content-comment f-content-notice')
|
||||
})
|
||||
|
||||
it('shows notices and errors together, notices first', () => {
|
||||
const wrapper = mount(FormField, {
|
||||
props: { field: plugin, modelValue: '', notices: ['Trimmed'], errors: ['Required'], idPrefix: 'f' },
|
||||
})
|
||||
expect(wrapper.find('[data-plugin-field]').attributes('aria-describedby')).toBe('f-content-comment f-content-error f-content-notice')
|
||||
const html = wrapper.html()
|
||||
expect(html.indexOf('id="f-content-notice"')).toBeLessThan(html.indexOf('id="f-content-error"'))
|
||||
expect(html.indexOf('id="f-content-notice"')).toBeGreaterThan(-1)
|
||||
})
|
||||
})
|
||||
|
||||
describe('form field', () => {
|
||||
it('links the label to the control and hides the required asterisk from assistive tech', () => {
|
||||
const wrapper = mount(FormField, { props: { field: formField('name'), modelValue: 'Blue', idPrefix: 'f' } })
|
||||
|
||||
Reference in New Issue
Block a user