diff --git a/website/src/components/SearchPage/fields/AutoCompleteField.spec.tsx b/website/src/components/SearchPage/fields/AutoCompleteField.spec.tsx index 469b1a7ccd..dedb680bb8 100644 --- a/website/src/components/SearchPage/fields/AutoCompleteField.spec.tsx +++ b/website/src/components/SearchPage/fields/AutoCompleteField.spec.tsx @@ -145,6 +145,36 @@ describe('AutoCompleteField', () => { expect(screen.getByText('No options available')).toBeInTheDocument(); }); + it('calls setAFieldValue, when an option is selected', async () => { + mockUseAggregated.mockReturnValue({ + data: { + data: [ + { testField: 'Option 1', count: 10 }, + { testField: 'Option 2', count: 20 }, + ], + }, + isLoading: false, + error: null, + mutate: vi.fn(), + }); + render( + , + ); + + const input = screen.getByLabelText('Test Field'); + fireEvent.focus(input); + + const options = await screen.findAllByRole('option'); + fireEvent.click(options[0]); + + expect(setAFieldValue).toHaveBeenCalledWith('testField', 'Option 1'); + }); + it('clears input value on clear button click', async () => { mockUseAggregated.mockReturnValue({ data: {