From b01761d800fcad1e55a7e292570eb84e11308ab4 Mon Sep 17 00:00:00 2001 From: Marcel Date: Fri, 17 Apr 2026 12:14:35 +0200 Subject: [PATCH] test(tag-input): add regression guard for allowCreation=false + Enter on suggestion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Confirms that Enter on a suggestion item adds the tag even when allowCreation is false — the activeIndex guard in handleKeydown runs before the allowCreation check. Co-Authored-By: Claude Sonnet 4.6 --- frontend/src/lib/components/TagInput.svelte.spec.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/frontend/src/lib/components/TagInput.svelte.spec.ts b/frontend/src/lib/components/TagInput.svelte.spec.ts index a0c37b6d..8605a236 100644 --- a/frontend/src/lib/components/TagInput.svelte.spec.ts +++ b/frontend/src/lib/components/TagInput.svelte.spec.ts @@ -255,6 +255,18 @@ describe('TagInput – autocomplete', () => { await waitForFetch(); await expect.element(page.getByRole('listbox')).toBeInTheDocument(); }); + + it('selects a suggestion via Enter when allowCreation=false', async () => { + mockFetchWithTags(['Familie']); + render(TagInput, { tags: [], allowCreation: false }); + const input = page.getByRole('textbox'); + await input.fill('Fa'); + await waitForFetch(); + await userEvent.keyboard('{ArrowDown}'); // index 0 → Familie + await userEvent.keyboard('{Enter}'); + await expect.element(page.getByText('Familie')).toBeInTheDocument(); + await expect.element(input).toHaveValue(''); + }); }); // ─── Tree-aware ordering ──────────────────────────────────────────────────────