From f22fbf48e681af5c04db6cb574601f0300f8b102 Mon Sep 17 00:00:00 2001 From: Cornelius Roemer Date: Sun, 30 Jun 2024 01:37:09 +0200 Subject: [PATCH] fix failing test by using userEvent.click instead of fireEvent.click --- .../SearchPage/fields/AutoCompleteField.spec.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/website/src/components/SearchPage/fields/AutoCompleteField.spec.tsx b/website/src/components/SearchPage/fields/AutoCompleteField.spec.tsx index dedb680bb8..02332f4ac6 100644 --- a/website/src/components/SearchPage/fields/AutoCompleteField.spec.tsx +++ b/website/src/components/SearchPage/fields/AutoCompleteField.spec.tsx @@ -1,9 +1,10 @@ -import { render, screen, fireEvent } from '@testing-library/react'; +import { render, screen, fireEvent, act } from '@testing-library/react'; import { describe, it, expect, beforeEach, vi } from 'vitest'; import { AutoCompleteField } from './AutoCompleteField'; import { lapisClientHooks } from '../../../services/serviceHooks.ts'; import { type MetadataFilter } from '../../../types/config.ts'; +import userEvent from '@testing-library/user-event'; vi.mock('../../../services/serviceHooks.ts'); vi.mock('../../../clientLogger.ts', () => ({ @@ -167,10 +168,10 @@ describe('AutoCompleteField', () => { ); const input = screen.getByLabelText('Test Field'); - fireEvent.focus(input); + await userEvent.click(input); const options = await screen.findAllByRole('option'); - fireEvent.click(options[0]); + await userEvent.click(options[0]); expect(setAFieldValue).toHaveBeenCalledWith('testField', 'Option 1'); });