From ac52700240e52e1ade74965fa0757d03661f5774 Mon Sep 17 00:00:00 2001 From: Cornelius Roemer Date: Sun, 30 Jun 2024 01:30:56 +0200 Subject: [PATCH] Revert "Remove overly specific unit test that does not seem necessary" This reverts commit c056aa8fcafa30a19a21ae356b2a07ab913c4b6f. --- .../fields/AutoCompleteField.spec.tsx | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) 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: {