@@ -513,6 +513,85 @@ describe("Select - Accessibility", () => {
513513 . find ( ".ui5-select-label-root" )
514514 . should ( "contain.text" , "SelectedOption – ExtraInfo" ) ;
515515 } ) ;
516+
517+ it ( "tests accessibilityInfo getter returns correct values" , ( ) => {
518+ cy . mount (
519+ < >
520+ < span id = "labelRef" > Reference Label</ span >
521+ { /* Basic select with selected option */ }
522+ < Select id = "basicSelect" >
523+ < Option value = "Option1" selected > Option 1</ Option >
524+ < Option value = "Option2" > Option 2</ Option >
525+ </ Select >
526+
527+ { /* Select with accessibleName */ }
528+ < Select id = "namedSelect" accessibleName = "Select Name" >
529+ < Option value = "Option1" selected > Option 1</ Option >
530+ </ Select >
531+
532+ { /* Select with accessibleNameRef */ }
533+ < Select id = "refSelect" accessibleNameRef = "labelRef" >
534+ < Option value = "Option1" selected > Option 1</ Option >
535+ </ Select >
536+
537+ { /* Select with readonly and required attributes */ }
538+ < Select id = "propsSelect" readonly required disabled >
539+ < Option value = "Option1" selected > Option 1</ Option >
540+ </ Select >
541+ </ >
542+ ) ;
543+
544+ // Test basic select
545+ cy . get ( "#basicSelect" ) . then ( ( $select ) => {
546+ const select = $select [ 0 ] as Select ;
547+ const accessInfo = select . accessibilityInfo ;
548+
549+ expect ( accessInfo . role ) . to . equal ( "combobox" ) ;
550+ expect ( accessInfo . type ) . to . equal ( "Listbox" ) ;
551+ expect ( accessInfo . readonly ) . to . be . false ;
552+ expect ( accessInfo . required ) . to . be . false ;
553+ expect ( accessInfo . description ) . to . equal ( "Option 1" ) ; // Just text
554+ expect ( accessInfo . label ) . to . be . undefined ; // No aria-label
555+ } ) ;
556+
557+ // Test select with accessibleName
558+ cy . get ( "#namedSelect" ) . then ( ( $select ) => {
559+ const select = $select [ 0 ] as Select ;
560+ const accessInfo = select . accessibilityInfo ;
561+
562+ expect ( accessInfo . description ) . to . equal ( "Option 1" ) ; // Just text
563+ expect ( accessInfo . label ) . to . equal ( "Select Name" ) ; // Aria label
564+ } ) ;
565+
566+ // Test select with accessibleNameRef
567+ cy . get ( "#refSelect" ) . then ( ( $select ) => {
568+ const select = $select [ 0 ] as Select ;
569+ const accessInfo = select . accessibilityInfo ;
570+
571+ expect ( accessInfo . description ) . to . equal ( "Option 1" ) ; // Just text
572+ expect ( accessInfo . label ) . to . equal ( "Reference Label" ) ; // Aria label from ref
573+ } ) ;
574+
575+ // Test select with readonly and required properties
576+ cy . get ( "#propsSelect" ) . then ( ( $select ) => {
577+ const select = $select [ 0 ] as Select ;
578+ const accessInfo = select . accessibilityInfo ;
579+
580+ expect ( accessInfo . readonly ) . to . be . true ;
581+ expect ( accessInfo . required ) . to . be . true ;
582+ expect ( accessInfo . disabled ) . to . be . true ;
583+ } ) ;
584+
585+ // Update the referenced label and check if the label updates
586+ cy . get ( "#labelRef" ) . invoke ( "text" , "Updated Reference" ) ;
587+ cy . get ( "#refSelect" ) . then ( ( $select ) => {
588+ const select = $select [ 0 ] as Select ;
589+ const accessInfo = select . accessibilityInfo ;
590+
591+ expect ( accessInfo . description ) . to . equal ( "Option 1" ) ; // Text remains the same
592+ expect ( accessInfo . label ) . to . equal ( "Updated Reference" ) ; // Updated aria label from ref
593+ } ) ;
594+ } ) ;
516595} ) ;
517596
518597describe ( "Select - Popover" , ( ) => {
@@ -1740,4 +1819,4 @@ describe("Select general interaction", () => {
17401819 . should ( "have.attr" , "selected" ) ;
17411820 cy . get ( "[ui5-select]" ) . should ( "have.prop" , "value" , "C" ) ;
17421821 } ) ;
1743- } ) ;
1822+ } ) ;
0 commit comments