test(18-07): framework unit coverage of money, settings secrets, tabs, richeditor and danger actions (task 2)

- money_field_test.go: compile gates (moved from the smoke file and
  extended), model column gate, save-time value check, list projection
- settings secret projection and put without a database; tabs, settings
  richeditor sanitize and the danger flag as internal unit tests
- Postgres: TestMoneyFieldSave, TestSettingsSecretPostgres and the Phase 18
  payload cases of TestPhase10OpenAPIConformance
- vitest: money.ts helpers spec, MoneyField blur-only and server-error cases
- gate arrays and the cabana README Testing section name every test
This commit is contained in:
2026-10-13 16:58:03 +02:00
parent eb60c329d8
commit 0f35c9a0ca
13 changed files with 1302 additions and 110 deletions

View File

@@ -186,6 +186,38 @@ describe('money field component (UI-SPEC F1)', () => {
expect(empty.find('[data-money-readonly] [data-empty]').text()).toBe('—')
})
it('validates on blur only: a malformed draft shows nothing while typing until the first blur', async () => {
const { wrapper } = mountField({ modelValue: null })
await type(wrapper, 'abc')
expect(wrapper.find('[data-money-error]').exists()).toBe(false)
expect(input(wrapper).attributes('aria-invalid')).toBeUndefined()
// The raw text is emitted so the server's 422 stays the gate.
expect(emitted(wrapper)).toEqual(['abc'])
await input(wrapper).trigger('blur')
expect(wrapper.find('[data-money-error]').text()).toBe('This is not an amount.')
expect(input(wrapper).attributes('aria-invalid')).toBe('true')
// Once shown, errors follow the typing.
await type(wrapper, '12,5')
expect(wrapper.find('[data-money-error]').exists()).toBe(false)
expect(input(wrapper).attributes('aria-invalid')).toBeUndefined()
expect(emitted(wrapper)).toEqual(['abc', '12.5'])
})
it('marks the input invalid when the form reports a server error for the field', () => {
const { wrapper } = mountField({ modelValue: '1.00', invalid: true })
expect(input(wrapper).attributes('aria-invalid')).toBe('true')
expect(input(wrapper).classes()).toContain('border-danger')
expect(wrapper.find('[data-money-error]').exists()).toBe(false)
})
it('accepts a loaded four-decimal value on a scale-2 field without an error on blur', async () => {
const { wrapper } = mountField({ modelValue: '12.5000', field: { scale: 2 } })
expect(input(wrapper).element.value).toBe('12.50')
await input(wrapper).trigger('blur')
expect(wrapper.find('[data-money-error]').exists()).toBe(false)
expect(emitted(wrapper)).toEqual([])
})
it('replaces the draft when the value is set from outside', async () => {
const { wrapper } = mountField({ modelValue: '1.00' })
await type(wrapper, '2')