test(19.6.1-03): SPA trigger, record lock and footer wrap tests

- trigger.test.ts: triggerState and applyTriggers
- FormView: disable, absent-controller and hide-tab backstops, the live
  announcement
- PermissionEditorField and formState: record-locked rows, notes and the
  payload omission, record lock over request lock, read-only screens
- PreviewView: hide removes, disable shows no note
- browser record-actions-wrap at 1024px; vitest.browser.config.ts gains
  the Tailwind plugin so the footer is laid out with the admin's CSS
This commit is contained in:
Jakub Zych
2026-10-22 12:18:34 +02:00
parent 085179b676
commit 4c61a180d0
7 changed files with 555 additions and 3 deletions

View File

@@ -367,3 +367,37 @@ describe('plugin field values (Phase 16.2)', () => {
})
})
})
describe('record permission locks in the save body (D-21, UI-SPEC C7)', () => {
const radio = (): FormField => ({ ...rosterFormSchemaFixture.data.fields.find((field) => field.name === 'permissions')! })
const checkbox = (): FormField => ({ ...radio(), mode: 'checkbox' })
const stored = { 'posts.edit': 1, 'posts.publish': -1, 'reports.export': 1, 'misc.beta': 1 }
it('backstop: a record-locked code is left out of a checkbox editor payload', () => {
const locks = { permissions: [{ code: 'posts.edit', value: 1, note: 'Granted to this role by a plugin. It cannot be removed here.' }] }
expect(editablePayload([checkbox()], { permissions: stored }, 'update', locks)).toEqual({ permissions: { 'reports.export': 1, 'misc.beta': 1 } })
// Without locks the same value is sent.
expect(editablePayload([checkbox()], { permissions: stored }, 'update')).toEqual({ permissions: { 'posts.edit': 1, 'reports.export': 1, 'misc.beta': 1 } })
})
it('a record-locked code is left out of a radio editor payload, whatever its value', () => {
const locks = {
permissions: [
{ code: 'posts.publish', value: -1, note: 'You cannot change your own permissions.' },
{ code: 'misc.beta', value: 0, note: 'You cannot change your own permissions.' },
],
}
expect(editablePayload([radio()], { permissions: stored }, 'update', locks)).toEqual({ permissions: { 'posts.edit': 1, 'reports.export': 1 } })
})
it('every code locked still sends the field, as an empty object', () => {
const codes = ['posts.edit', 'posts.publish', 'reports.export', 'misc.beta']
const locks = { permissions: codes.map((code) => ({ code, value: 0, note: 'Locked' })) }
expect(editablePayload([radio()], { permissions: stored }, 'update', locks)).toEqual({ permissions: {} })
})
it('locks of another field change nothing', () => {
const locks = { other_permissions: [{ code: 'posts.edit', value: 1, note: 'Locked' }] }
expect(editablePayload([radio()], { permissions: stored }, 'update', locks)).toEqual({ permissions: { 'posts.edit': 1, 'posts.publish': -1, 'reports.export': 1, 'misc.beta': 1 } })
})
})