@@ -3,6 +3,8 @@ import SideNavigationItem from "../../src/SideNavigationItem.js";
3
3
import SideNavigationSubItem from "../../src/SideNavigationSubItem.js" ;
4
4
import group from "@ui5/webcomponents-icons/dist/group.js" ;
5
5
import { NAVIGATION_MENU_POPOVER_HIDDEN_TEXT } from "../../src/generated/i18n/i18n-defaults.js" ;
6
+ import Title from "@ui5/webcomponents/dist/Title.js" ;
7
+ import Label from "@ui5/webcomponents/dist/Label.js" ;
6
8
7
9
describe ( "Side Navigation Rendering" , ( ) => {
8
10
it ( "Tests rendering in collapsed mode" , ( ) => {
@@ -78,6 +80,40 @@ describe("Side Navigation Rendering", () => {
78
80
. find ( ".ui5-sn-root" )
79
81
. should ( "have.attr" , "aria-label" , "Main" ) ;
80
82
} ) ;
83
+
84
+ it ( "Tests header visibility" , ( ) => {
85
+ cy . mount (
86
+ < SideNavigation id = "sn1" accessibleName = "Main" collapsed = { false } >
87
+ < div slot = "header" class = "header" >
88
+ < Title > William Brown</ Title >
89
+ < Label > UX expert</ Label >
90
+ </ div >
91
+ </ SideNavigation > ) ;
92
+
93
+ cy . get ( "#sn1" ) . should ( "have.prop" , "showHeader" , true ) ;
94
+
95
+ cy . get ( "#sn1" ) . invoke ( "prop" , "collapsed" , true ) ;
96
+
97
+ cy . get ( "#sn1" ) . should ( "have.prop" , "showHeader" , false ) ;
98
+ } ) ;
99
+
100
+ it ( "Tests tooltips" , ( ) => {
101
+ const TOOLTIP_TEXT = "From My Team tooltip" ;
102
+ cy . mount (
103
+ < SideNavigation id = "sn1" accessibleName = "Main" collapsed = { false } >
104
+ < SideNavigationItem id = "item1" text = "People" icon = "group" expanded = { true } >
105
+ < SideNavigationSubItem id = "item11" text = "From My Team" icon = "employee-approvals" tooltip = { TOOLTIP_TEXT } > </ SideNavigationSubItem >
106
+ < SideNavigationSubItem id = "item21" text = "From My Team" icon = "employee-approvals" > </ SideNavigationSubItem >
107
+ </ SideNavigationItem >
108
+ < SideNavigationItem id = "item2" text = "People" expanded icon = "group" tooltip = { TOOLTIP_TEXT } />
109
+ </ SideNavigation > ) ;
110
+
111
+ cy . get ( "#item1" ) . should ( "not.have.attr" , "tooltip" ) ;
112
+ cy . get ( "#item2" ) . should ( "have.attr" , "tooltip" , TOOLTIP_TEXT ) ;
113
+
114
+ cy . get ( "#item11" ) . should ( "have.attr" , "tooltip" , TOOLTIP_TEXT ) ;
115
+ cy . get ( "#item21" ) . should ( "not.have.attr" , "tooltip" ) ;
116
+ } ) ;
81
117
} ) ;
82
118
83
119
describe ( "Side Navigation interaction" , ( ) => {
@@ -342,7 +378,7 @@ describe("Side Navigation interaction", () => {
342
378
cy . mount (
343
379
< SideNavigation id = "sideNav" >
344
380
< SideNavigationItem id = "item" text = "1" />
345
- < SideNavigationItem id = "unselectableItemWithLink" text = "external link" unselectable = { true } href = "#test" />
381
+ < SideNavigationItem id = "unselectableItemWithLink" text = "external link" unselectable = { true } href = "#test" />
346
382
</ SideNavigation >
347
383
) ;
348
384
@@ -364,7 +400,7 @@ describe("Side Navigation interaction", () => {
364
400
cy . mount (
365
401
< SideNavigation >
366
402
< SideNavigationItem id = "focusStart" text = "focus start" />
367
- < SideNavigationItem text = "external link" unselectable = { true } href = "#test" />
403
+ < SideNavigationItem text = "external link" unselectable = { true } href = "#test" />
368
404
</ SideNavigation >
369
405
) ;
370
406
@@ -388,7 +424,7 @@ describe("Side Navigation interaction", () => {
388
424
cy . mount (
389
425
< SideNavigation >
390
426
< SideNavigationItem id = "focusStart" text = "focus start" />
391
- < SideNavigationItem id = "linkItem" text = "external link" unselectable = { true } href = "#test" />
427
+ < SideNavigationItem id = "linkItem" text = "external link" unselectable = { true } href = "#test" />
392
428
</ SideNavigation >
393
429
) ;
394
430
@@ -503,6 +539,20 @@ describe("Side Navigation interaction", () => {
503
539
cy . get ( "@selectionChangeHandler" ) . should ( "have.callCount" , expectedCallCount ) ;
504
540
} ) ;
505
541
} ) ;
542
+
543
+ it ( "tests avoiding re-selecting already selected item" , ( ) => {
544
+ const selectionChangeHandler = cy . stub ( ) . as ( "selectionChangeHandler" ) ;
545
+ cy . mount (
546
+ < SideNavigation id = "sideNav" onSelectionChange = { selectionChangeHandler } >
547
+ < SideNavigationItem id = "item" text = "1" />
548
+ </ SideNavigation >
549
+ ) ;
550
+
551
+ cy . get ( "#item" ) . realClick ( ) ;
552
+ cy . get ( "#item" ) . realClick ( ) ;
553
+
554
+ cy . get ( "@selectionChangeHandler" ) . should ( "have.been.calledOnce" ) ;
555
+ } ) ;
506
556
} ) ;
507
557
508
558
describe ( "Side Navigation Accessibility" , ( ) => {
@@ -689,7 +739,7 @@ describe("Side Navigation Accessibility", () => {
689
739
. should ( "have.attr" , "aria-haspopup" , "dialog" ) ;
690
740
} ) ;
691
741
692
- it ( "SideNavigationItem aria-role in collapsed SideNavigation" , ( ) => {
742
+ it ( "SideNavigationItem aria attributes in collapsed SideNavigation" , ( ) => {
693
743
cy . mount (
694
744
< SideNavigation id = "sideNav" collapsed = { true } >
695
745
< SideNavigationItem id = "item" text = "1" />
@@ -707,6 +757,16 @@ describe("Side Navigation Accessibility", () => {
707
757
. shadow ( )
708
758
. find ( ".ui5-sn-item" )
709
759
. should ( "have.attr" , "role" , "menuitem" ) ;
760
+
761
+ cy . get ( "#sideNav" )
762
+ . shadow ( )
763
+ . find ( ".ui5-sn-root" )
764
+ . should ( "have.prop" , "tagName" , "NAV" ) ;
765
+
766
+ cy . get ( "#sideNav" )
767
+ . shadow ( )
768
+ . find ( ".ui5-sn-flexible" )
769
+ . should ( "have.attr" , "aria-roledescription" , "Navigation List Menu Bar" ) ;
710
770
} ) ;
711
771
712
772
it ( "SideNavigationItem aria-checked in collapsed SideNavigation" , ( ) => {
@@ -827,4 +887,16 @@ describe("Focusable items", () => {
827
887
. find ( ".ui5-sn-item" )
828
888
. should ( "have.attr" , "tabindex" , "0" ) ;
829
889
} ) ;
890
+
891
+ it ( "Tests external link items" , ( ) => {
892
+ cy . mount (
893
+ < SideNavigation >
894
+ < SideNavigationItem id = "externalLinkItem" text = "External Link Unselectable" icon = "chain-link" href = "https://sap.com" unselectable target = "_blank" />
895
+ </ SideNavigation > ) ;
896
+
897
+ cy . get ( "#externalLinkItem" )
898
+ . shadow ( )
899
+ . find ( ".ui5-sn-item-external-link-icon" )
900
+ . should ( "exist" ) ;
901
+ } ) ;
830
902
} ) ;
0 commit comments