From f06e272225cebcbe1f972ad9fa1849656eabfb36 Mon Sep 17 00:00:00 2001 From: kolaente Date: Sat, 10 Jan 2026 21:29:14 +0100 Subject: [PATCH] test(frontend): add test for @keyup.enter forwarding in FormField Verify that @keyup.enter modifier is properly forwarded to the inner input element and only triggers for Enter key, not other keys. --- .../src/components/input/FormField.test.ts | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/frontend/src/components/input/FormField.test.ts b/frontend/src/components/input/FormField.test.ts index 649bda27a..8fe5f64ca 100644 --- a/frontend/src/components/input/FormField.test.ts +++ b/frontend/src/components/input/FormField.test.ts @@ -125,6 +125,28 @@ describe('FormField', () => { expect(onFocusout).toHaveBeenCalledTimes(1) }) + it('forwards @keyup.enter to inner input', async () => { + const onSubmit = vi.fn() + + const wrapper = mount({ + components: {FormField}, + template: ``, + setup() { + return {onSubmit} + }, + }) + + const input = wrapper.find('input') + + // Enter key should trigger the handler + await input.trigger('keyup', {key: 'Enter'}) + expect(onSubmit).toHaveBeenCalledTimes(1) + + // Other keys should not trigger the handler + await input.trigger('keyup', {key: 'a'}) + expect(onSubmit).toHaveBeenCalledTimes(1) + }) + it('uses provided id for input', () => { const wrapper = mount(FormField, { props: {id: 'my-input', label: 'My Input'},