@@ -529,6 +529,82 @@ describe('<pf-select>', function() {
529529 } ) ;
530530 } ) ;
531531
532+ describe ( 'in a deep shadow root' , function ( ) {
533+ let element : PfSelect ;
534+ const focus = ( ) => element . focus ( ) ;
535+ const updateComplete = ( ) => element . updateComplete ;
536+ beforeEach ( async function ( ) {
537+ const fixture = await createFixture ( html `
538+ < shadow-root >
539+ < template shadowrootmode ="open ">
540+ < shadow-root >
541+ < template shadowrootmode ="open ">
542+ < pf-select variant ="single "
543+ accessible-label ="Choose a number "
544+ placeholder ="Choose a number ">
545+ < pf-option value ="1 "> 1</ pf-option >
546+ < pf-option value ="2 "> 2</ pf-option >
547+ < pf-option value ="3 "> 3</ pf-option >
548+ < pf-option value ="4 "> 4</ pf-option >
549+ < pf-option value ="5 "> 5</ pf-option >
550+ < pf-option value ="6 "> 6</ pf-option >
551+ < pf-option value ="7 "> 7</ pf-option >
552+ < pf-option value ="8 "> 8</ pf-option >
553+ </ pf-select >
554+ </ template >
555+ </ shadow-root >
556+ </ template >
557+ </ shadow-root > ` ) ;
558+
559+ function attachShadowRoots ( root ?: Document | ShadowRoot ) {
560+ root ?. querySelectorAll < HTMLTemplateElement > ( 'template[shadowrootmode]' ) . forEach ( template => {
561+ const mode = template . getAttribute ( 'shadowrootmode' ) as 'open' | 'closed' ;
562+ const shadowRoot = template . parentElement ?. attachShadow ?.( { mode } ) ;
563+ shadowRoot ?. appendChild ( template . content ) ;
564+ template . remove ( ) ;
565+ attachShadowRoots ( shadowRoot ) ;
566+ } ) ;
567+ }
568+ attachShadowRoots ( document ) ;
569+
570+ const select = fixture . shadowRoot ?. firstElementChild ?. shadowRoot ?. querySelector ( 'pf-select' ) ;
571+ if ( select ) {
572+ element = select ;
573+ await element ?. updateComplete ;
574+ } else {
575+ throw new Error ( 'no element!' ) ;
576+ }
577+ } ) ;
578+ describe ( 'expanding' , function ( ) {
579+ beforeEach ( focus ) ;
580+ beforeEach ( press ( 'Enter' ) ) ;
581+ describe ( 'pressing ArrowDown' , function ( ) {
582+ beforeEach ( press ( 'ArrowDown' ) ) ;
583+ beforeEach ( updateComplete ) ;
584+ it ( 'remains expanded' , function ( ) {
585+ expect ( element . expanded ) . to . be . true ;
586+ } ) ;
587+ describe ( 'pressing ArrowDown' , function ( ) {
588+ beforeEach ( press ( 'ArrowDown' ) ) ;
589+ beforeEach ( updateComplete ) ;
590+ it ( 'remains expanded' , function ( ) {
591+ expect ( element . expanded ) . to . be . true ;
592+ } ) ;
593+ describe ( 'pressing Space' , function ( ) {
594+ beforeEach ( press ( ' ' ) ) ;
595+ beforeEach ( updateComplete ) ;
596+ it ( 'closes' , function ( ) {
597+ expect ( element . expanded ) . to . be . false ;
598+ } ) ;
599+ it ( 'sets value' , function ( ) {
600+ expect ( element . value ) . to . equal ( '2' ) ;
601+ } ) ;
602+ } ) ;
603+ } ) ;
604+ } ) ;
605+ } ) ;
606+ } ) ;
607+
532608 // try again when we implement activedescendant
533609 describe . skip ( 'variant="typeahead"' , function ( ) {
534610 beforeEach ( async function ( ) {
0 commit comments