11package io .github .epam .angular .tests .elements .complex ;
22
3+ import com .epam .jdi .light .angular .elements .composite .MaterialSelectorContainer ;
34import com .epam .jdi .light .elements .common .UIElement ;
45import io .github .epam .TestsInit ;
56import org .testng .annotations .BeforeMethod ;
6- import org .testng .annotations .Ignore ;
77import org .testng .annotations .Test ;
88
99import static com .epam .jdi .light .elements .composite .WebPage .refresh ;
1010import static com .jdiai .tools .StringUtils .format ;
11- import static io .github .com .StaticSite .angularPage ;
12- import static io .github .com .pages .sections .SideNavSection .*;
13- import static io .github .epam .site .steps .States .shouldBeLoggedIn ;
11+ import static com .jdiai .tools .Timer .waitCondition ;
12+ import static io .github .com .StaticSite .sideNavPage ;
13+ import static io .github .com .pages .SideNavPage .autoSizeSideNav ;
14+ import static io .github .com .pages .SideNavPage .backDropToggle ;
15+ import static io .github .com .pages .SideNavPage .basicDrawer ;
16+ import static io .github .com .pages .SideNavPage .basicSideNav ;
17+ import static io .github .com .pages .SideNavPage .bottomGap ;
18+ import static io .github .com .pages .SideNavPage .configurableMode ;
19+ import static io .github .com .pages .SideNavPage .contentRadioGroup ;
20+ import static io .github .com .pages .SideNavPage .contentToggle ;
21+ import static io .github .com .pages .SideNavPage .customEscapeBackdrop ;
22+ import static io .github .com .pages .SideNavPage .firstElement ;
23+ import static io .github .com .pages .SideNavPage .firstElementFocused ;
24+ import static io .github .com .pages .SideNavPage .fixSideNav ;
25+ import static io .github .com .pages .SideNavPage .fixedPosition ;
26+ import static io .github .com .pages .SideNavPage .implicitMainContent ;
27+ import static io .github .com .pages .SideNavPage .openCloseBehavior ;
28+ import static io .github .com .pages .SideNavPage .openSideNav ;
29+ import static io .github .com .pages .SideNavPage .responsiveContent ;
30+ import static io .github .com .pages .SideNavPage .sideNavFocusSelection ;
31+ import static io .github .com .pages .SideNavPage .sideNavOpened ;
32+ import static io .github .com .pages .SideNavPage .sideNavPosition ;
33+ import static io .github .com .pages .SideNavPage .sideNavRadioGroup ;
34+ import static io .github .com .pages .SideNavPage .sideNavToggle ;
35+ import static io .github .com .pages .SideNavPage .sideToggle ;
36+ import static io .github .com .pages .SideNavPage .sidenavBackdropContainer ;
37+ import static io .github .com .pages .SideNavPage .sidenavBackdropDrawer ;
38+ import static io .github .com .pages .SideNavPage .toggleAutoNav ;
39+ import static io .github .com .pages .SideNavPage .toggleExtraText ;
40+ import static io .github .com .pages .SideNavPage .toggleFixedSideNav ;
41+ import static io .github .com .pages .SideNavPage .toggleSideNav ;
42+ import static io .github .com .pages .SideNavPage .toolbarToggle ;
43+ import static io .github .com .pages .SideNavPage .topGap ;
1444import static org .hamcrest .Matchers .containsString ;
1545
16- // TODO Move to the new page
17- @ Ignore
46+
1847public class SideNavTests extends TestsInit {
1948
2049 public static final String SIDE_NAV_CONTENT = "Sidenav content" ;
@@ -28,11 +57,12 @@ public class SideNavTests extends TestsInit {
2857
2958 @ BeforeMethod (alwaysRun = true )
3059 public void before () {
31- shouldBeLoggedIn ();
32- angularPage .shouldBeOpened ();
60+ sideNavPage .open ();
61+ waitCondition (() -> sideNavPage .isOpened ());
62+ sideNavPage .checkOpened ();
3363 }
3464
35- @ Test
65+ @ Test ( description = "Verify that the basic sideNav is displayed" )
3666 public void verifyBasicSideNavTest () {
3767 basicSideNav .show ();
3868 basicSideNav .is ().displayed ();
@@ -41,7 +71,7 @@ public void verifyBasicSideNavTest() {
4171 basicSideNav .getContent ().has ().text (MAIN_CONTENT );
4272 }
4373
44- @ Test
74+ @ Test ( description = "Verify that the basicDrawer sideNav is displayed" )
4575 public void verifyBasicDrawerTest () {
4676 basicDrawer .show ();
4777 basicDrawer .is ().displayed ();
@@ -50,7 +80,37 @@ public void verifyBasicDrawerTest() {
5080 basicDrawer .getMatDrawerContent ().has ().text (MAIN_CONTENT );
5181 }
5282
53- @ Test
83+ @ Test (description = "Tests confirm menu position changes for 'start' or 'end' selector options." )
84+ public void verifyPositionSelectionDrawerWithExplicitBackdropSettingSideNavTest () {
85+ sidenavBackdropContainer .show ();
86+ sidenavBackdropContainer .is ().displayed ();
87+ sidenavBackdropContainer .is ().enabled ();
88+
89+ sideNavPosition .click ();
90+ (new MaterialSelectorContainer ()).select ("End" );
91+
92+ backDropToggle .click ();
93+ sidenavBackdropDrawer .is ().displayed ();
94+ sidenavBackdropDrawer .has ().cssClass ("mat-drawer-end" );
95+ }
96+
97+ @ Test (description = "Test verifies first menu item focus when 'true' is selected" )
98+ public void verifyFocusSelectionDrawerWithExplicitBackdropSettingSideNavTest () {
99+ sidenavBackdropContainer .show ();
100+ sidenavBackdropContainer .is ().displayed ();
101+ sidenavBackdropContainer .is ().enabled ();
102+
103+ sideNavFocusSelection .click ();
104+ (new MaterialSelectorContainer ()).select ("True" );
105+
106+ backDropToggle .click ();
107+
108+ firstElementFocused .base ().timer ().wait (() -> firstElementFocused .has ().cssClass ("cdk-program-focused" ));
109+ firstElementFocused .has ().cssClass ("cdk-focused" );
110+ firstElementFocused .is ().displayed ();
111+ }
112+
113+ @ Test (description = "Verify main content is properly displayed alongside two side navigation panels" )
54114 public void verifyImplicitMainContentWithTwoSideNavTest () {
55115 implicitMainContent .show ();
56116 UIElement startSideNav = implicitMainContent .getSideNav ("start" );
@@ -69,7 +129,7 @@ public void verifyImplicitMainContentWithTwoSideNavTest() {
69129 implicitMainContent .getContent ().is ().enabled ();
70130 }
71131
72- @ Test
132+ @ Test ( description = "Tests the opening and closing functionality of the component" )
73133 public void verifyOpenCloseBehaviorTest () {
74134 openCloseBehavior .show ();
75135 openCloseBehavior .getContent ().is ().displayed ();
@@ -80,46 +140,51 @@ public void verifyOpenCloseBehaviorTest() {
80140
81141 sideNavOpened .click ();
82142 openCloseBehavior .base ().timer ().wait (() -> openCloseBehavior .isEnabled ());
83- openCloseBehavior .getEvents ().has ().text ("open!\n close!" );
143+ openCloseBehavior .base ().timer ().wait (() -> openCloseBehavior .getEvents ().has ().text ("open!" ));
144+ sideNavOpened .click ();
145+ openCloseBehavior .base ().timer ().wait (() -> openCloseBehavior .getEvents ().has ().text ("open!\n close!" ));
84146 }
85147
86- @ Test
148+ @ Test ( description = "Verify SideNav with with configurable mode" )
87149 public void toggleConfigurableSideNavTest () {
88150 refresh ();
89151 configurableMode .show ();
90152 contentToggle .click ();
91- configurableMode .base ().timer ().wait (() -> configurableMode .visualValidation ( ".mat-sidenav" ));
153+ configurableMode .base ().timer ().wait (() -> configurableMode .getSideNav (). has (). attr ( STYLE , STYLE_VISIBLE ));
92154 configurableMode .getSideNav ().has ().attr (STYLE , STYLE_VISIBLE );
93155
94156 sideToggle .click ();
95- configurableMode .base ().timer ().wait (() -> configurableMode .visualValidation ( ".mat-sidenav" ));
157+ configurableMode .base ().timer ().wait (() -> configurableMode .getSideNav (). has (). attr ( STYLE , STYLE_HIDDEN ));
96158 configurableMode .getSideNav ().has ().attr (STYLE , STYLE_HIDDEN );
97159 }
98160
99- @ Test
161+ @ Test ( description = "Verify side radio group buttons" )
100162 public void sideRadioGroupTest () {
101163 refresh ();
102164 contentToggle .click ();
103165 configurableMode .getContent ().has ().attr (STYLE , "" );
104166
167+ sideNavRadioGroup .base ().timer ().wait (() -> fixedPosition .visualValidation (".mat-sidenav-content" ));
105168 sideNavRadioGroup .click ("Side" );
106- configurableMode .getContent ().has ().attr (STYLE , "margin-left: 258px ;" );
169+ configurableMode .getContent ().has ().attr (STYLE , "margin-left: 299px ;" );
107170
108171 sideNavRadioGroup .click ("Push" );
109- configurableMode .getContent ().has ().attr (STYLE , "margin-left: 258px ; margin-right: -258px ;" );
172+ configurableMode .getContent ().has ().attr (STYLE , "margin-left: 300px ; margin-right: -300px ;" );
110173 }
111174
112- @ Test
175+ @ Test ( description = "Verify content radio group buttons" )
113176 public void contentRadioButtonsTest () {
177+ refresh ();
114178 contentToggle .click ();
179+ sideNavRadioGroup .base ().timer ().wait (() -> fixedPosition .visualValidation (".mat-sidenav-content" ));
115180 sideNavRadioGroup .click ("Side" );
116- configurableMode .getContent ().has ().attr (STYLE , "margin-left: 258px ;" );
181+ configurableMode .getContent ().has ().attr (STYLE , "margin-left: 299px ;" );
117182
118183 contentRadioGroup .click ("Push" );
119- configurableMode .getContent ().has ().attr (STYLE , "margin-left: 258px ; margin-right: -258px ;" );
184+ configurableMode .getContent ().has ().attr (STYLE , "margin-left: 300px ; margin-right: -300px ;" );
120185 }
121186
122- @ Test
187+ @ Test ( description = "Verify toggle button" )
123188 public void closeByToggleTest () {
124189 refresh ();
125190 customEscapeBackdrop .show ();
@@ -128,23 +193,23 @@ public void closeByToggleTest() {
128193 customEscapeBackdrop .getContent ().has ().text (containsString ("toggle button" ));
129194 }
130195
131- @ Test
196+ @ Test ( description = "Verify backdrop click behavior" )
132197 public void closeByBackdropTest () {
133198 openSideNav .click ();
134199 customEscapeBackdrop .core ().click ();
135200 customEscapeBackdrop .getContent ().has ().text (containsString ("backdrop" ));
136201 }
137202
138- @ Test
203+ @ Test ( description = "Verify auto size SideNav" )
139204 public void verifyAutoSizeSideNav () {
140205 autoSizeSideNav .show ();
141206 toggleAutoNav .click ();
142207 toggleExtraText .click ();
143208 autoSizeSideNav .getMatDrawer ().has ().text (containsString ("Toggle extra text" ));
144- autoSizeSideNav .getMatDrawerContent ().has ().attr (STYLE , "margin-left: 294px ;" );
209+ autoSizeSideNav .getMatDrawerContent ().has ().attr (STYLE , "margin-left: 305px ;" );
145210 }
146211
147- @ Test
212+ @ Test ( description = "Verify fixed sideNav" )
148213 public void fixedSideNavTest () {
149214 String testValue = "100" ;
150215 fixedPosition .show ();
@@ -156,15 +221,15 @@ public void fixedSideNavTest() {
156221 bottomGap .sendKeys (testValue );
157222 fixSideNav .click ();
158223 fixedPosition .getSideNav ().has ().attr (STYLE , "transform: none; visibility: visible; top: 100px; bottom: " +
159- "100px;" );
224+ "100px;" );
160225
161226 toggleFixedSideNav .click ();
162227 fixedPosition .base ().timer ().wait (() -> fixedPosition .visualValidation (".mat-sidenav-content" ));
163228 fixedPosition .getSideNav ().has ().attr (STYLE , "top: 100px; bottom: 100px; box-shadow: none; visibility: " +
164- "hidden;" );
229+ "hidden;" );
165230 }
166231
167- @ Test
232+ @ Test ( description = "Verify toggle responsive sideNave" )
168233 public void toggleResponsiveSideNavTest () {
169234 int [] testValues = {1 , 3 };
170235 responsiveContent .show ();
0 commit comments