import React, { useRef } from 'react'; import { render, screen, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { GrapesProvider } from '../GrapesProvider'; import { LOCALES } from '../GrapesProvider/exampleLocales'; import { AutocompleteNoOptions } from '../AutocompleteNoOptions'; import { FormField } from '../FormField'; import { Autocomplete } from './'; import { DropdownItem } from '../DropdownItem'; describe('Autocomplete component', () => { type Option = (typeof availableOptions)[number]; const availableOptions = [ { key: '1', label: 'Marketing' }, { key: '2', label: 'Legal' }, { key: '3', label: 'Office' }, { key: '4', label: 'Platform' }, { key: '5', label: 'Finance' }, { key: '6', label: 'Recruitment' }, { key: '7', label: 'Growth' }, { key: '8', label: 'Management' }, ]; it('allows user to select and search for an option', async () => { const Wrapper = () => { const [options, setOptions] = React.useState(availableOptions); const [selectedOption, setSelectedOption] = React.useState