1
1
package io .github .epam .angular .tests .elements .complex ;
2
2
3
+ import com .epam .jdi .light .angular .elements .composite .MaterialSelectorContainer ;
3
4
import com .epam .jdi .light .elements .common .UIElement ;
4
5
import io .github .epam .TestsInit ;
5
6
import org .testng .annotations .BeforeMethod ;
6
- import org .testng .annotations .Ignore ;
7
7
import org .testng .annotations .Test ;
8
8
9
9
import static com .epam .jdi .light .elements .composite .WebPage .refresh ;
10
10
import 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 ;
14
44
import static org .hamcrest .Matchers .containsString ;
15
45
16
- // TODO Move to the new page
17
- @ Ignore
46
+
18
47
public class SideNavTests extends TestsInit {
19
48
20
49
public static final String SIDE_NAV_CONTENT = "Sidenav content" ;
@@ -28,11 +57,12 @@ public class SideNavTests extends TestsInit {
28
57
29
58
@ BeforeMethod (alwaysRun = true )
30
59
public void before () {
31
- shouldBeLoggedIn ();
32
- angularPage .shouldBeOpened ();
60
+ sideNavPage .open ();
61
+ waitCondition (() -> sideNavPage .isOpened ());
62
+ sideNavPage .checkOpened ();
33
63
}
34
64
35
- @ Test
65
+ @ Test ( description = "Verify that the basic sideNav is displayed" )
36
66
public void verifyBasicSideNavTest () {
37
67
basicSideNav .show ();
38
68
basicSideNav .is ().displayed ();
@@ -41,7 +71,7 @@ public void verifyBasicSideNavTest() {
41
71
basicSideNav .getContent ().has ().text (MAIN_CONTENT );
42
72
}
43
73
44
- @ Test
74
+ @ Test ( description = "Verify that the basicDrawer sideNav is displayed" )
45
75
public void verifyBasicDrawerTest () {
46
76
basicDrawer .show ();
47
77
basicDrawer .is ().displayed ();
@@ -50,7 +80,37 @@ public void verifyBasicDrawerTest() {
50
80
basicDrawer .getMatDrawerContent ().has ().text (MAIN_CONTENT );
51
81
}
52
82
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" )
54
114
public void verifyImplicitMainContentWithTwoSideNavTest () {
55
115
implicitMainContent .show ();
56
116
UIElement startSideNav = implicitMainContent .getSideNav ("start" );
@@ -69,7 +129,7 @@ public void verifyImplicitMainContentWithTwoSideNavTest() {
69
129
implicitMainContent .getContent ().is ().enabled ();
70
130
}
71
131
72
- @ Test
132
+ @ Test ( description = "Tests the opening and closing functionality of the component" )
73
133
public void verifyOpenCloseBehaviorTest () {
74
134
openCloseBehavior .show ();
75
135
openCloseBehavior .getContent ().is ().displayed ();
@@ -80,46 +140,51 @@ public void verifyOpenCloseBehaviorTest() {
80
140
81
141
sideNavOpened .click ();
82
142
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!" ));
84
146
}
85
147
86
- @ Test
148
+ @ Test ( description = "Verify SideNav with with configurable mode" )
87
149
public void toggleConfigurableSideNavTest () {
88
150
refresh ();
89
151
configurableMode .show ();
90
152
contentToggle .click ();
91
- configurableMode .base ().timer ().wait (() -> configurableMode .visualValidation ( ".mat-sidenav" ));
153
+ configurableMode .base ().timer ().wait (() -> configurableMode .getSideNav (). has (). attr ( STYLE , STYLE_VISIBLE ));
92
154
configurableMode .getSideNav ().has ().attr (STYLE , STYLE_VISIBLE );
93
155
94
156
sideToggle .click ();
95
- configurableMode .base ().timer ().wait (() -> configurableMode .visualValidation ( ".mat-sidenav" ));
157
+ configurableMode .base ().timer ().wait (() -> configurableMode .getSideNav (). has (). attr ( STYLE , STYLE_HIDDEN ));
96
158
configurableMode .getSideNav ().has ().attr (STYLE , STYLE_HIDDEN );
97
159
}
98
160
99
- @ Test
161
+ @ Test ( description = "Verify side radio group buttons" )
100
162
public void sideRadioGroupTest () {
101
163
refresh ();
102
164
contentToggle .click ();
103
165
configurableMode .getContent ().has ().attr (STYLE , "" );
104
166
167
+ sideNavRadioGroup .base ().timer ().wait (() -> fixedPosition .visualValidation (".mat-sidenav-content" ));
105
168
sideNavRadioGroup .click ("Side" );
106
- configurableMode .getContent ().has ().attr (STYLE , "margin-left: 258px ;" );
169
+ configurableMode .getContent ().has ().attr (STYLE , "margin-left: 299px ;" );
107
170
108
171
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 ;" );
110
173
}
111
174
112
- @ Test
175
+ @ Test ( description = "Verify content radio group buttons" )
113
176
public void contentRadioButtonsTest () {
177
+ refresh ();
114
178
contentToggle .click ();
179
+ sideNavRadioGroup .base ().timer ().wait (() -> fixedPosition .visualValidation (".mat-sidenav-content" ));
115
180
sideNavRadioGroup .click ("Side" );
116
- configurableMode .getContent ().has ().attr (STYLE , "margin-left: 258px ;" );
181
+ configurableMode .getContent ().has ().attr (STYLE , "margin-left: 299px ;" );
117
182
118
183
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 ;" );
120
185
}
121
186
122
- @ Test
187
+ @ Test ( description = "Verify toggle button" )
123
188
public void closeByToggleTest () {
124
189
refresh ();
125
190
customEscapeBackdrop .show ();
@@ -128,23 +193,23 @@ public void closeByToggleTest() {
128
193
customEscapeBackdrop .getContent ().has ().text (containsString ("toggle button" ));
129
194
}
130
195
131
- @ Test
196
+ @ Test ( description = "Verify backdrop click behavior" )
132
197
public void closeByBackdropTest () {
133
198
openSideNav .click ();
134
199
customEscapeBackdrop .core ().click ();
135
200
customEscapeBackdrop .getContent ().has ().text (containsString ("backdrop" ));
136
201
}
137
202
138
- @ Test
203
+ @ Test ( description = "Verify auto size SideNav" )
139
204
public void verifyAutoSizeSideNav () {
140
205
autoSizeSideNav .show ();
141
206
toggleAutoNav .click ();
142
207
toggleExtraText .click ();
143
208
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 ;" );
145
210
}
146
211
147
- @ Test
212
+ @ Test ( description = "Verify fixed sideNav" )
148
213
public void fixedSideNavTest () {
149
214
String testValue = "100" ;
150
215
fixedPosition .show ();
@@ -156,15 +221,15 @@ public void fixedSideNavTest() {
156
221
bottomGap .sendKeys (testValue );
157
222
fixSideNav .click ();
158
223
fixedPosition .getSideNav ().has ().attr (STYLE , "transform: none; visibility: visible; top: 100px; bottom: " +
159
- "100px;" );
224
+ "100px;" );
160
225
161
226
toggleFixedSideNav .click ();
162
227
fixedPosition .base ().timer ().wait (() -> fixedPosition .visualValidation (".mat-sidenav-content" ));
163
228
fixedPosition .getSideNav ().has ().attr (STYLE , "top: 100px; bottom: 100px; box-shadow: none; visibility: " +
164
- "hidden;" );
229
+ "hidden;" );
165
230
}
166
231
167
- @ Test
232
+ @ Test ( description = "Verify toggle responsive sideNave" )
168
233
public void toggleResponsiveSideNavTest () {
169
234
int [] testValues = {1 , 3 };
170
235
responsiveContent .show ();
0 commit comments