@@ -18,7 +18,67 @@ function Sample() {
1818
1919 < SideNavigationGroup text = "Group 1" expanded = { true } >
2020 < SideNavigationItem text = "Item 1" href = "#item1" icon = { home } > </ SideNavigationItem >
21- < SideNavigationItem text = "Item 2" href = "#item2" icon = { home } > </ SideNavigationItem >
21+ < SideNavigationItem text = "Item 2" href = "#item2" icon = { home } > </ SideNavigationItem >
22+ < SideNavigationItem text = "Item 3" href = "#item3" icon = { home } > </ SideNavigationItem >
23+ </ SideNavigationGroup >
24+
25+ < SideNavigationItem
26+ slot = "fixedItems"
27+ text = "Legal"
28+ href = "https://www.sap.com/about/legal/impressum.html"
29+ target = "_blank"
30+ icon = { home } >
31+ </ SideNavigationItem >
32+ </ SideNavigation >
33+
34+ < div >
35+ Content
36+ </ div >
37+ </ NavigationLayout > ;
38+ }
39+
40+ function SampleWithCollapsedMode ( ) {
41+ return < NavigationLayout id = "nl1" mode = "Collapsed" >
42+ < ShellBar slot = "header" primaryTitle = "UI5 Web Components" >
43+ < Button icon = { menu } slot = "startButton" id = "startButton" > </ Button >
44+ </ ShellBar >
45+
46+ < SideNavigation id = "sn1" slot = "sideContent" >
47+ < SideNavigationItem text = "Home" href = "#home" icon = { home } > </ SideNavigationItem >
48+
49+ < SideNavigationGroup text = "Group 1" expanded = { true } >
50+ < SideNavigationItem text = "Item 1" href = "#item1" icon = { home } > </ SideNavigationItem >
51+ < SideNavigationItem text = "Item 2" href = "#item2" icon = { home } > </ SideNavigationItem >
52+ < SideNavigationItem text = "Item 3" href = "#item3" icon = { home } > </ SideNavigationItem >
53+ </ SideNavigationGroup >
54+
55+ < SideNavigationItem
56+ slot = "fixedItems"
57+ text = "Legal"
58+ href = "https://www.sap.com/about/legal/impressum.html"
59+ target = "_blank"
60+ icon = { home } >
61+ </ SideNavigationItem >
62+ </ SideNavigation >
63+
64+ < div >
65+ Content
66+ </ div >
67+ </ NavigationLayout > ;
68+ }
69+
70+ function SampleWithExpandedMode ( ) {
71+ return < NavigationLayout id = "nl1" mode = "Expanded" >
72+ < ShellBar slot = "header" primaryTitle = "UI5 Web Components" >
73+ < Button icon = { menu } slot = "startButton" id = "startButton" > </ Button >
74+ </ ShellBar >
75+
76+ < SideNavigation id = "sn1" slot = "sideContent" >
77+ < SideNavigationItem text = "Home" href = "#home" icon = { home } > </ SideNavigationItem >
78+
79+ < SideNavigationGroup text = "Group 1" expanded = { true } >
80+ < SideNavigationItem text = "Item 1" href = "#item1" icon = { home } > </ SideNavigationItem >
81+ < SideNavigationItem text = "Item 2" href = "#item2" icon = { home } > </ SideNavigationItem >
2282 < SideNavigationItem text = "Item 3" href = "#item3" icon = { home } > </ SideNavigationItem >
2383 </ SideNavigationGroup >
2484
@@ -38,11 +98,10 @@ function Sample() {
3898}
3999
40100describe ( "Rendering and interaction" , ( ) => {
41- beforeEach ( ( ) => {
42- cy . mount ( < Sample /> ) ;
43- } ) ;
44101
45102 it ( "tests initial rendering" , ( ) => {
103+ cy . mount ( < Sample /> ) ;
104+
46105 cy . get ( "[ui5-navigation-layout]" )
47106 . shadow ( )
48107 . find ( ".ui5-nl-root" )
@@ -69,36 +128,46 @@ describe("Rendering and interaction", () => {
69128 . should ( "exist" ) ;
70129 } ) ;
71130
72- // it("tests collapsing", () => {
73- // cy.get("[ui5-side-navigation]")
74- // .should("have.prop", "collapsed", false);
131+ it ( "tests collapsing" , ( ) => {
132+ cy . mount ( < Sample /> ) ;
133+
134+ cy . get ( "[ui5-side-navigation]" )
135+ . should ( "have.prop" , "collapsed" , false ) ;
136+
137+ cy . get ( "[ui5-navigation-layout]" )
138+ . invoke ( "prop" , "mode" , "Collapsed" ) ;
139+
140+ cy . get ( "[ui5-side-navigation]" )
141+ . should ( "have.prop" , "collapsed" , true ) ;
75142
76- // cy.get("[ui5-navigation-layout]")
77- // .invoke("prop", "mode", "Collapsed ");
143+ cy . get ( "[ui5-navigation-layout]" )
144+ . invoke ( "prop" , "mode" , "Expanded " ) ;
78145
79- // cy.get("[ui5-side-navigation]")
80- // .should("have.prop", "collapsed", true);
146+ cy . get ( "[ui5-side-navigation]" )
147+ . should ( "have.prop" , "collapsed" , false ) ;
148+ } ) ;
81149
82- // cy.get("[ui5-navigation-layout]")
83- // .invoke("prop", "mode", "Expanded" );
150+ it ( "tests that initial mode=Collapsed overrides default expand/collapse behavior" , ( ) => {
151+ cy . mount ( < SampleWithCollapsedMode /> ) ;
84152
85- // cy.get("[ui5-side-navigation]")
86- // .should("have.prop", "collapsed", false );
87- // });
153+ cy . get ( "[ui5-side-navigation]" )
154+ . should ( "have.prop" , "collapsed" , true ) ;
155+ } ) ;
88156} ) ;
89157
90- describe ( "Navigation Layout on Phone " , ( ) => {
158+ describe ( "Navigation Layout on Small screens (599px or less) " , ( ) => {
91159 beforeEach ( ( ) => {
92- cy . ui5SimulateDevice ( "phone" ) ;
93- cy . mount ( < Sample /> ) ;
160+ cy . viewport ( 500 , 1080 ) ;
94161 } ) ;
95162
96163 it ( "tests initial rendering" , ( ) => {
164+ cy . mount ( < Sample /> ) ;
165+
97166 cy . get ( "[ui5-navigation-layout]" )
98167 . should ( "have.prop" , "sideCollapsed" , true ) ;
99168
100169 cy . get ( "[ui5-side-navigation]" )
101- . should ( "have.prop" , "collapsed" , false ) ;
170+ . should ( "have.prop" , "collapsed" , true ) ;
102171
103172 cy . get ( "[ui5-navigation-layout]" )
104173 . shadow ( )
@@ -107,6 +176,8 @@ describe("Navigation Layout on Phone", () => {
107176 } ) ;
108177
109178 it ( "tests collapsing" , ( ) => {
179+ cy . mount ( < Sample /> ) ;
180+
110181 cy . get ( "[ui5-navigation-layout]" )
111182 . invoke ( "prop" , "mode" , "Expanded" ) ;
112183
@@ -123,4 +194,13 @@ describe("Navigation Layout on Phone", () => {
123194 . find ( ".ui5-nl-aside" )
124195 . should ( "not.be.visible" ) ;
125196 } ) ;
197+
198+ it ( "tests that initial mode=Expanded overrides default expand/collapse behavior" , ( ) => {
199+ cy . mount ( < SampleWithExpandedMode /> ) ;
200+
201+ cy . get ( "[ui5-navigation-layout]" )
202+ . shadow ( )
203+ . find ( ".ui5-nl-aside" )
204+ . should ( "be.visible" ) ;
205+ } ) ;
126206} ) ;
0 commit comments