test(tag-input): add regression guard for allowCreation=false + Enter on suggestion
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 <noreply@anthropic.com>
This commit is contained in:
@@ -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 ──────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user