1+ import Bar from "../../src/Bar.js" ;
2+ import Button from "../../src/Button.js" ;
3+
4+ describe ( "Bar Accessibility" , ( ) => {
5+ it ( "Should use accessibleName property as aria-label" , ( ) => {
6+ cy . mount (
7+ < Bar accessibleName = "Navigation Bar" >
8+ < Button slot = "startContent" > Back</ Button >
9+ < div > Page Title</ div >
10+ < Button slot = "endContent" > Settings</ Button >
11+ </ Bar >
12+ ) ;
13+
14+ cy . get ( "[ui5-bar]" )
15+ . shadow ( )
16+ . find ( ".ui5-bar-root" )
17+ . should ( "have.attr" , "aria-label" , "Navigation Bar" ) ;
18+ } ) ;
19+
20+ it ( "Should fallback to design property when accessibleName is not provided" , ( ) => {
21+ cy . mount (
22+ < Bar design = "Header" >
23+ < Button slot = "startContent" > Menu</ Button >
24+ < div > Application Header</ div >
25+ < Button slot = "endContent" > Profile</ Button >
26+ </ Bar >
27+ ) ;
28+
29+ cy . get ( "[ui5-bar]" )
30+ . shadow ( )
31+ . find ( ".ui5-bar-root" )
32+ . should ( "have.attr" , "aria-label" , "Header" ) ;
33+ } ) ;
34+
35+ it ( "Should use accessibleName over design property when both are provided" , ( ) => {
36+ cy . mount (
37+ < Bar design = "Footer" accessibleName = "Custom Footer Label" >
38+ < Button slot = "startContent" > Help</ Button >
39+ < div > Footer Content</ div >
40+ < Button slot = "endContent" > Contact</ Button >
41+ </ Bar >
42+ ) ;
43+
44+ cy . get ( "[ui5-bar]" )
45+ . shadow ( )
46+ . find ( ".ui5-bar-root" )
47+ . should ( "have.attr" , "aria-label" , "Custom Footer Label" ) ;
48+ } ) ;
49+
50+ it ( "Should use accessibleNameRef over accessibleName when both are provided" , ( ) => {
51+ cy . mount (
52+ < div >
53+ < div id = "external-label" > External Navigation Label</ div >
54+ < Bar accessibleName = "Internal Label" accessibleNameRef = "external-label" >
55+ < Button slot = "startContent" > Back</ Button >
56+ < div > Content</ div >
57+ < Button slot = "endContent" > Forward</ Button >
58+ </ Bar >
59+ </ div >
60+ ) ;
61+
62+ cy . get ( "[ui5-bar]" )
63+ . shadow ( )
64+ . find ( ".ui5-bar-root" )
65+ . should ( "have.attr" , "aria-label" , "External Navigation Label" ) ;
66+ } ) ;
67+ } ) ;
0 commit comments