test(frontend): add regression test for FormField $attrs event forwarding

Verify that FormField forwards $attrs event listeners (onKeyup, onFocusout)
to its inner input element. This ensures migrated templates using
@keyup.enter and @focusout continue to work correctly.
This commit is contained in:
kolaente
2026-01-10 21:25:01 +01:00
parent 182b0b63d1
commit 8f0c7d504b

View File

@@ -1,4 +1,4 @@
import {describe, it, expect} from 'vitest'
import {describe, it, expect, vi} from 'vitest'
import {mount} from '@vue/test-utils'
import FormField from './FormField.vue'
@@ -102,6 +102,29 @@ describe('FormField', () => {
expect(input.attributes('autocomplete')).toBe('email')
})
it('forwards $attrs event listeners to inner input', async () => {
const onKeyup = vi.fn()
const onFocusout = vi.fn()
const wrapper = mount(FormField, {
props: {
modelValue: 'test',
},
attrs: {
onKeyup,
onFocusout,
},
})
const input = wrapper.find('input')
await input.trigger('keyup', {key: 'Enter'})
expect(onKeyup).toHaveBeenCalledTimes(1)
await input.trigger('focusout')
expect(onFocusout).toHaveBeenCalledTimes(1)
})
it('uses provided id for input', () => {
const wrapper = mount(FormField, {
props: {id: 'my-input', label: 'My Input'},