test(search): cover smart-mode chip lifecycle hooks (#739)
SearchFilterBar drives chip-clearing via onModeToggle (mode switch) and onSmartSearch (new query); pin that callback contract. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -195,3 +195,39 @@ describe('SearchFilterBar – tagQ live filter', () => {
|
||||
vi.unstubAllGlobals();
|
||||
});
|
||||
});
|
||||
|
||||
describe('SearchFilterBar – smart-mode chip lifecycle hooks', () => {
|
||||
// The interpretation chips live in the result area (parent page). SearchFilterBar
|
||||
// drives chip-clearing through callbacks: onModeToggle (mode switch) and
|
||||
// onSmartSearch (new query). These tests pin that contract.
|
||||
it('invokes onModeToggle when toggling back to keyword mode (parent clears chips)', async () => {
|
||||
const onModeToggle = vi.fn();
|
||||
render(SearchFilterBar, {
|
||||
...defaultProps,
|
||||
sort: 'DATE',
|
||||
dir: 'desc',
|
||||
smartMode: true,
|
||||
onModeToggle
|
||||
});
|
||||
await page.getByRole('button', { name: /KI/ }).click();
|
||||
expect(onModeToggle).toHaveBeenCalledOnce();
|
||||
});
|
||||
|
||||
it('invokes onSmartSearch when a new query is submitted in smart mode (parent resets chips)', async () => {
|
||||
const onSmartSearch = vi.fn();
|
||||
render(SearchFilterBar, {
|
||||
...defaultProps,
|
||||
sort: 'DATE',
|
||||
dir: 'desc',
|
||||
smartMode: true,
|
||||
onSmartSearch
|
||||
});
|
||||
const input = page.getByPlaceholder('Titel, Personen, Tags durchsuchen…');
|
||||
await input.fill('Walter im Krieg');
|
||||
await input.click();
|
||||
(document.activeElement as HTMLElement).dispatchEvent(
|
||||
new KeyboardEvent('keydown', { key: 'Enter', bubbles: true })
|
||||
);
|
||||
await vi.waitFor(() => expect(onSmartSearch).toHaveBeenCalled());
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user