@@ -3,6 +3,8 @@ import SideNavigationItem from "../../src/SideNavigationItem.js";
33import SideNavigationSubItem from "../../src/SideNavigationSubItem.js" ;
44import group from "@ui5/webcomponents-icons/dist/group.js" ;
55import { 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" ;
68
79describe ( "Side Navigation Rendering" , ( ) => {
810 it ( "Tests rendering in collapsed mode" , ( ) => {
@@ -78,6 +80,40 @@ describe("Side Navigation Rendering", () => {
7880 . find ( ".ui5-sn-root" )
7981 . should ( "have.attr" , "aria-label" , "Main" ) ;
8082 } ) ;
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+ } ) ;
81117} ) ;
82118
83119describe ( "Side Navigation interaction" , ( ) => {
@@ -342,7 +378,7 @@ describe("Side Navigation interaction", () => {
342378 cy . mount (
343379 < SideNavigation id = "sideNav" >
344380 < 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" />
346382 </ SideNavigation >
347383 ) ;
348384
@@ -364,7 +400,7 @@ describe("Side Navigation interaction", () => {
364400 cy . mount (
365401 < SideNavigation >
366402 < SideNavigationItem id = "focusStart" text = "focus start" />
367- < SideNavigationItem text = "external link" unselectable = { true } href = "#test" />
403+ < SideNavigationItem text = "external link" unselectable = { true } href = "#test" />
368404 </ SideNavigation >
369405 ) ;
370406
@@ -388,7 +424,7 @@ describe("Side Navigation interaction", () => {
388424 cy . mount (
389425 < SideNavigation >
390426 < 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" />
392428 </ SideNavigation >
393429 ) ;
394430
@@ -503,6 +539,20 @@ describe("Side Navigation interaction", () => {
503539 cy . get ( "@selectionChangeHandler" ) . should ( "have.callCount" , expectedCallCount ) ;
504540 } ) ;
505541 } ) ;
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+ } ) ;
506556} ) ;
507557
508558describe ( "Side Navigation Accessibility" , ( ) => {
@@ -689,7 +739,7 @@ describe("Side Navigation Accessibility", () => {
689739 . should ( "have.attr" , "aria-haspopup" , "dialog" ) ;
690740 } ) ;
691741
692- it ( "SideNavigationItem aria-role in collapsed SideNavigation" , ( ) => {
742+ it ( "SideNavigationItem aria attributes in collapsed SideNavigation" , ( ) => {
693743 cy . mount (
694744 < SideNavigation id = "sideNav" collapsed = { true } >
695745 < SideNavigationItem id = "item" text = "1" />
@@ -707,6 +757,16 @@ describe("Side Navigation Accessibility", () => {
707757 . shadow ( )
708758 . find ( ".ui5-sn-item" )
709759 . 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" ) ;
710770 } ) ;
711771
712772 it ( "SideNavigationItem aria-checked in collapsed SideNavigation" , ( ) => {
@@ -827,4 +887,16 @@ describe("Focusable items", () => {
827887 . find ( ".ui5-sn-item" )
828888 . should ( "have.attr" , "tabindex" , "0" ) ;
829889 } ) ;
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+ } ) ;
830902} ) ;
0 commit comments