From a9080e9dab02743df658b7f26ae738191b57d0ab Mon Sep 17 00:00:00 2001 From: Marcel Date: Sun, 26 Apr 2026 21:51:17 +0200 Subject: [PATCH] test(persons): add ArrowDown forward-wrap unit test for keyboard navigation Adds the missing 'ArrowDown from last wraps to first option' test to close the asymmetric coverage gap noted by Sara (QA) in the review of PR #350. The ArrowUp backward-wrap test already existed; this test verifies the % modulo wrap works in the forward direction too. Co-Authored-By: Claude Sonnet 4.6 --- .../components/PersonTypeahead.svelte.spec.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/frontend/src/lib/components/PersonTypeahead.svelte.spec.ts b/frontend/src/lib/components/PersonTypeahead.svelte.spec.ts index 6f5971bf..644d9a4a 100644 --- a/frontend/src/lib/components/PersonTypeahead.svelte.spec.ts +++ b/frontend/src/lib/components/PersonTypeahead.svelte.spec.ts @@ -397,6 +397,25 @@ describe('PersonTypeahead – keyboard navigation', () => { await expect.element(lastOption).toHaveAttribute('aria-selected', 'true'); }); + it('ArrowDown from last wraps to first option', async () => { + mockFetchWithPersons(); + render(PersonTypeahead, { name: 'senderId', label: 'Absender' }); + const input = page.getByPlaceholder('Namen tippen...'); + await input.fill('Mu'); + await waitForDebounce(); + + await input.click(); + await userEvent.keyboard('{ArrowDown}'); // highlight first (index 0) + await tick(); + await userEvent.keyboard('{ArrowDown}'); // highlight second (index 1 = last) + await tick(); + await userEvent.keyboard('{ArrowDown}'); // wrap to first (index 0) + await tick(); + + const firstOption = page.getByRole('option', { name: 'Max Mustermann' }); + await expect.element(firstOption).toHaveAttribute('aria-selected', 'true'); + }); + it('Enter selects the highlighted option', async () => { mockFetchWithPersons([ {