11import * as React from 'react' ;
22import { expect } from 'chai' ;
33import { spy } from 'sinon' ;
4- import {
5- createRenderer ,
6- fireEvent ,
7- flushMicrotasks ,
8- screen ,
9- } from '@mui/internal-test-utils' ;
4+ import { createRenderer , fireEvent , flushMicrotasks , screen } from '@mui/internal-test-utils' ;
105import TextField from '@mui/material/TextField' ;
116import Autocomplete , { autocompleteClasses as classes } from '@mui/material/Autocomplete' ;
127import FloatingPopup from '@mui/material/FloatingPopup' ;
13- import type { UserEvent } from '@testing-library/user-event' ;
148
159const options = [ 'Alpha' , 'Beta' , 'Gamma' , 'Delta' , 'Epsilon' ] ;
1610
@@ -28,7 +22,9 @@ function checkHighlightIs(listbox: HTMLElement, expected: string | null) {
2822 * FloatingPopup's async computePosition completes and visibility:hidden
2923 * is removed (making the popup accessible to getByRole).
3024 */
31- async function openAutocomplete ( user : UserEvent ) {
25+ async function openAutocomplete (
26+ user : ReturnType < ReturnType < typeof createRenderer > [ 'render' ] > [ 'user' ] ,
27+ ) {
3228 const input = screen . getByRole ( 'combobox' ) ;
3329 await user . click ( input ) ;
3430 await flushMicrotasks ( ) ;
@@ -176,7 +172,7 @@ describe('<Autocomplete slots={{ popper: FloatingPopup }} />', () => {
176172 const input = await openAutocomplete ( user ) ;
177173 await user . keyboard ( '{ArrowDown}' ) ;
178174 const firstOption = screen . getAllByRole ( 'option' ) [ 0 ] ;
179- expect ( input ) . to . have . attribute ( 'aria-activedescendant' , firstOption . getAttribute ( 'id' ) ) ;
175+ expect ( input ) . to . have . attribute ( 'aria-activedescendant' , firstOption . id ) ;
180176 } ) ;
181177
182178 it ( 'should clear input on blur when no option is selected' , async ( ) => {
@@ -365,7 +361,7 @@ describe('<Autocomplete slots={{ popper: FloatingPopup }} />', () => {
365361 const { user } = renderAutocomplete ( ) ;
366362 const input = await openAutocomplete ( user ) ;
367363 const listbox = screen . getByRole ( 'listbox' ) ;
368- expect ( input ) . to . have . attribute ( 'aria-controls' , listbox . getAttribute ( 'id' ) ) ;
364+ expect ( input ) . to . have . attribute ( 'aria-controls' , listbox . id ) ;
369365 } ) ;
370366
371367 it ( 'should have role="presentation" on the popup container' , async ( ) => {
@@ -559,7 +555,7 @@ describe('<Autocomplete slots={{ popper: FloatingPopup }} />', () => {
559555 describe ( 'slotProps.popper' , ( ) => {
560556 it ( 'should forward keepMounted to FloatingPopup' , ( ) => {
561557 renderAutocomplete ( {
562- slotProps : { popper : { keepMounted : true } as any } ,
558+ slotProps : { popper : { keepMounted : true } } ,
563559 } ) ;
564560 // Closed — floating element in DOM but with visibility:hidden (FOUC guard)
565561 const floating = document . querySelector ( '[data-popper-placement]' ) ;
@@ -568,7 +564,7 @@ describe('<Autocomplete slots={{ popper: FloatingPopup }} />', () => {
568564
569565 it ( 'should forward data attributes to the floating element' , async ( ) => {
570566 const { user } = renderAutocomplete ( {
571- slotProps : { popper : { 'data-testid' : 'custom-popup' } as any } ,
567+ slotProps : { popper : { 'data-testid' : 'custom-popup' } } ,
572568 } ) ;
573569 await openAutocomplete ( user ) ;
574570 expect ( screen . getByTestId ( 'custom-popup' ) ) . not . to . equal ( null ) ;
0 commit comments