@@ -79,10 +79,11 @@ test.describe('Mouse Behavior', () => {
7979 await openListbox ( 'click' ) ;
8080
8181 const options = await getOptions ( ) ;
82+ const thirdOptStr = await options [ 2 ] . textContent ( ) ;
8283 await options [ 2 ] . click ( ) ;
8384
8485 await expect ( options [ 2 ] ) . toHaveAttribute ( 'aria-selected' , 'true' ) ;
85- expect ( options [ 2 ] . textContent ( ) ) . toEqual ( getValue ( ) ) ;
86+ expect ( thirdOptStr ) . toEqual ( await getValue ( ) ) ;
8687 } ) ;
8788} ) ;
8889
@@ -369,7 +370,7 @@ test.describe('Keyboard Behavior', () => {
369370 AND the Enter key is pressed
370371 THEN option value should be the selected value
371372 AND should have an aria-selected of true` , async ( { page } ) => {
372- const { getTrigger, getOptions, getValue, openListbox } = await setup (
373+ const { getTrigger, getOptions, getValue, getListbox , openListbox } = await setup (
373374 page ,
374375 'select-hero-test' ,
375376 ) ;
@@ -381,9 +382,10 @@ test.describe('Keyboard Behavior', () => {
381382 const optStr = await options [ 0 ] . textContent ( ) ;
382383 await getTrigger ( ) . press ( 'Enter' ) ;
383384
384- console . log ( optStr ) ;
385- console . log ( await getValue ( ) ) ;
386- expect ( optStr ) . toEqual ( await getValue ( ) ) ;
385+ // seems we need to await for the listbox to be hidden, otherwise the getValue does not update. ¯\_(ツ)_/¯
386+ await expect ( getListbox ( ) ) . toBeHidden ( ) ;
387+ const value = await getValue ( ) ;
388+ expect ( optStr ) . toEqual ( value ) ;
387389 } ) ;
388390
389391 test ( `GIVEN an open hero select
@@ -406,6 +408,26 @@ test.describe('Keyboard Behavior', () => {
406408 await expect ( getListbox ( ) ) . toBeHidden ( ) ;
407409 await expect ( getTrigger ( ) ) . toHaveAttribute ( 'aria-expanded' , 'false' ) ;
408410 } ) ;
411+
412+ test ( `GIVEN an open hero select
413+ WHEN an option has data-highlighted
414+ AND the Space key is pressed
415+ THEN option value should be the selected value
416+ AND should have an aria-selected of true` , async ( { page } ) => {
417+ const { getTrigger, getOptions, getValue, openListbox } = await setup (
418+ page ,
419+ 'select-hero-test' ,
420+ ) ;
421+
422+ await openListbox ( 'Space' ) ;
423+
424+ const options = await getOptions ( ) ;
425+ await expect ( options [ 0 ] ) . toHaveAttribute ( 'data-highlighted' ) ;
426+ const optStr = await options [ 0 ] . textContent ( ) ;
427+ await getTrigger ( ) . press ( 'Space' ) ;
428+
429+ expect ( optStr ) . toEqual ( await getValue ( ) ) ;
430+ } ) ;
409431 } ) ;
410432} ) ;
411433
0 commit comments