1
1
/* eslint-disable no-undef */
2
+ import { flashClassMap } from "../../../../support/assertions/assertion_constants" ;
2
3
3
4
const textConstants = {
5
+ // Component route url
6
+ componentRouteUrl : '/ops/explorer' ,
7
+
4
8
// Menu options
5
9
settingsMenuOption : 'Settings' ,
6
10
appSettingsMenuOption : 'Application Settings' ,
@@ -31,42 +35,48 @@ const textConstants = {
31
35
dropdownBlankValue : 'BLANK_VALUE' ,
32
36
sambaDropdownValue : 'FileDepotSmb' ,
33
37
34
- // Button types
35
- submitButtonType : 'submit' ,
36
-
37
- // Component route url
38
- componentRouteUrl : '/ops/explorer' ,
39
-
40
- // Flash message types
41
- flashTypeSuccess : 'success' ,
42
-
43
38
// Flash message text snippets
44
39
flashMessageSettingsSaved : 'saved' ,
45
- flashMessageOperationCanceled : 'cancel' ,
40
+ flashMessageOperationCancelled : 'cancel' ,
46
41
} ;
47
42
48
43
const {
49
- diagnosticsAccordionItem,
50
- dropdownBlankValue,
51
- editToolbarButton,
52
- sambaDropdownValue,
53
- saveButton,
54
- cancelButton,
55
- resetButton,
44
+ // Component route url
45
+ componentRouteUrl,
46
+
47
+ // Menu options
56
48
settingsMenuOption,
57
49
appSettingsMenuOption,
50
+
51
+ // List items
52
+ diagnosticsAccordionItem,
58
53
diagnosticsAccordionItemId,
59
54
manageIQRegionAccordItem,
60
55
zoneAccordItem,
61
56
serverAccordItem,
62
- componentRouteUrl,
63
- flashTypeSuccess,
64
- flashMessageSettingsSaved,
65
- flashMessageOperationCanceled,
66
- submitButtonType,
67
- protocolSelectFieldId,
57
+
58
+ // Field values
68
59
formHeader,
69
60
formSubheaderSnippet,
61
+
62
+ // Config options
63
+ editToolbarButton,
64
+
65
+ // Buttons
66
+ saveButton,
67
+ cancelButton,
68
+ resetButton,
69
+
70
+ // Common element IDs
71
+ protocolSelectFieldId,
72
+
73
+ // Dropdown values
74
+ dropdownBlankValue,
75
+ sambaDropdownValue,
76
+
77
+ // Flash message text snippets
78
+ flashMessageSettingsSaved,
79
+ flashMessageOperationCancelled,
70
80
} = textConstants ;
71
81
72
82
function interceptAndAwaitApi ( {
@@ -89,7 +99,7 @@ function interceptAndAwaitApi({
89
99
cy . wait ( `@${ alias } ` ) ;
90
100
}
91
101
92
- function invokeAndAwaitCollectLogsTabInfo ( { currentApiIntercepts } ) {
102
+ function goToCollectLogsTab ( { currentApiIntercepts } ) {
93
103
interceptAndAwaitApi ( {
94
104
alias : 'getCollectLogsTabInfo' ,
95
105
urlPattern : '/ops/change_tab?tab_id=diagnostics_collect_logs' ,
@@ -103,10 +113,11 @@ function invokeAndAwaitCollectLogsTabInfo({ currentApiIntercepts }) {
103
113
} ) ;
104
114
}
105
115
106
- function invokeAndAwaitEditEventForServer ( { currentApiIntercepts } ) {
116
+ function selectToolbarEditButton ( ) {
107
117
interceptAndAwaitApi ( {
108
118
alias : 'editEventForServer' ,
109
- urlPattern : / \/ o p s \/ x _ b u t t o n \/ [ ^ / ] + \? p r e s s e d = .* l o g _ d e p o t _ e d i t / , // matches both /ops/x_button/1?pressed=log_depot_edit & /ops/x_button/2?pressed=zone_log_depot_edit endpoints
119
+ // This pattern matches both /ops/x_button/1?pressed=log_depot_edit & /ops/x_button/2?pressed=zone_log_depot_edit endpoints
120
+ urlPattern : / \/ o p s \/ x _ b u t t o n \/ [ ^ / ] + \? p r e s s e d = .* l o g _ d e p o t _ e d i t / ,
110
121
triggerFn : ( ) => cy . toolbar ( editToolbarButton ) ,
111
122
currentApiIntercepts,
112
123
} ) ;
@@ -126,28 +137,28 @@ function resetProtocolDropdown({
126
137
] ) ;
127
138
128
139
// Clicking Edit button
129
- invokeAndAwaitEditEventForServer ( { currentApiIntercepts } ) ;
140
+ selectToolbarEditButton ( { currentApiIntercepts } ) ;
130
141
131
142
// Resetting Protocol dropdown value
132
- cy . getFormSelectFieldById ( protocolSelectFieldId ) . then ( ( $select ) => {
133
- const currentValue = $select . val ( ) ;
143
+ cy . getFormSelectFieldById ( protocolSelectFieldId ) . then ( ( selectField ) => {
144
+ const currentValue = selectField . val ( ) ;
134
145
// If the value is not default one(BLANK_VALUE), then setting it to blank
135
146
if ( currentValue !== dropdownBlankValue ) {
136
- cy . wrap ( $select ) . select ( dropdownBlankValue ) ;
137
- cy . getFormFooterButtonByType ( saveButton , submitButtonType ) . click ( ) ;
147
+ cy . wrap ( selectField ) . select ( dropdownBlankValue ) ;
148
+ cy . getFormFooterButtonByType ( saveButton , 'submit' ) . click ( ) ;
138
149
// Validating confirmation flash message
139
- cy . expect_flash ( flashTypeSuccess , flashMessageSettingsSaved ) ;
150
+ cy . expect_flash ( flashClassMap . success , flashMessageSettingsSaved ) ;
140
151
}
141
152
} ) ;
142
153
}
143
154
144
- function goToCollectLogsNavbarAndOpenEditForm ( registeredApiIntercepts ) {
145
- // Selecting Collect Logs nav bar
146
- invokeAndAwaitCollectLogsTabInfo ( {
155
+ function goToCollectLogsTabAndOpenEditForm ( registeredApiIntercepts ) {
156
+ // Selecting Collect Logs tab
157
+ goToCollectLogsTab ( {
147
158
currentApiIntercepts : registeredApiIntercepts ,
148
159
} ) ;
149
160
// Clicking Edit button
150
- invokeAndAwaitEditEventForServer ( {
161
+ selectToolbarEditButton ( {
151
162
currentApiIntercepts : registeredApiIntercepts ,
152
163
} ) ;
153
164
}
@@ -170,7 +181,7 @@ function validateFormElements() {
170
181
. should ( 'be.visible' )
171
182
. and ( 'be.enabled' ) ;
172
183
// Assert save button is visible and disabled
173
- cy . getFormFooterButtonByType ( saveButton , submitButtonType )
184
+ cy . getFormFooterButtonByType ( saveButton , 'submit' )
174
185
. should ( 'be.visible' )
175
186
. and ( 'be.disabled' ) ;
176
187
// Assert reset button is visible and disabled
@@ -183,7 +194,7 @@ function cancelButtonValidation() {
183
194
// Click cancel button in the form
184
195
cy . getFormFooterButtonByType ( cancelButton ) . click ( ) ;
185
196
// Validating confirmation flash message
186
- cy . expect_flash ( flashTypeSuccess , flashMessageOperationCanceled ) ;
197
+ cy . expect_flash ( flashClassMap . success , flashMessageOperationCancelled ) ;
187
198
}
188
199
189
200
function resetButtonValidation ( ) {
@@ -202,11 +213,11 @@ function saveButtonValidation() {
202
213
// Selecting Samba option from dropdown
203
214
cy . getFormSelectFieldById ( protocolSelectFieldId ) . select ( sambaDropdownValue ) ;
204
215
// Confirm Save button is enabled once dropdown value is changed and then click on Save
205
- cy . getFormFooterButtonByType ( saveButton , submitButtonType )
216
+ cy . getFormFooterButtonByType ( saveButton , 'submit' )
206
217
. should ( 'be.enabled' )
207
218
. click ( ) ;
208
219
// Validating confirmation flash message
209
- cy . expect_flash ( flashTypeSuccess , flashMessageSettingsSaved ) ;
220
+ cy . expect_flash ( flashClassMap . success , flashMessageSettingsSaved ) ;
210
221
}
211
222
212
223
describe ( 'Automate Collect logs Edit form operations' , ( ) => {
@@ -218,7 +229,7 @@ describe('Automate Collect logs Edit form operations', () => {
218
229
beforeEach ( ( ) => {
219
230
registeredApiIntercepts = { } ;
220
231
cy . login ( ) ;
221
- // Navigate to Application settings and Select Diagnostics
232
+ // Navigate to Application settings and expand Diagnostics accordion
222
233
cy . menu ( settingsMenuOption , appSettingsMenuOption ) ;
223
234
interceptAndAwaitApi ( {
224
235
alias : 'getDiagnosticsInfo' ,
@@ -237,19 +248,18 @@ describe('Automate Collect logs Edit form operations', () => {
237
248
serverAccordItem ,
238
249
] ) ;
239
250
// Select collect logs navbar and open edit form
240
- goToCollectLogsNavbarAndOpenEditForm ( registeredApiIntercepts ) ;
251
+ goToCollectLogsTabAndOpenEditForm ( registeredApiIntercepts ) ;
241
252
} ) ;
242
253
243
254
it ( 'Validate form elements' , ( ) => {
244
255
validateFormElements ( ) ;
245
256
} ) ;
246
257
247
- it ( 'Validate Cancel button' , ( ) => {
248
- cancelButtonValidation ( ) ;
249
- } ) ;
250
-
251
- it ( 'Validate Reset button' , ( ) => {
258
+ it ( 'Validate Reset & Cancel buttons' , ( ) => {
259
+ // Reset button validation
252
260
resetButtonValidation ( ) ;
261
+ // Cancel button validation
262
+ cancelButtonValidation ( ) ;
253
263
} ) ;
254
264
255
265
it ( 'Validate Save button' , ( ) => {
@@ -284,20 +294,19 @@ describe('Automate Collect logs Edit form operations', () => {
284
294
cy . selectAccordionItem ( [ manageIQRegionAccordItem , zoneAccordItem ] ) ,
285
295
currentApiIntercepts : registeredApiIntercepts ,
286
296
} ) ;
287
- // Select collect logs navbar and open edit form
288
- goToCollectLogsNavbarAndOpenEditForm ( registeredApiIntercepts ) ;
297
+ // Select collect logs tab and open edit form
298
+ goToCollectLogsTabAndOpenEditForm ( registeredApiIntercepts ) ;
289
299
} ) ;
290
300
291
301
it ( 'Validate form elements' , ( ) => {
292
302
validateFormElements ( ) ;
293
303
} ) ;
294
304
295
- it ( 'Validate Cancel button' , ( ) => {
296
- cancelButtonValidation ( ) ;
297
- } ) ;
298
-
299
- it ( 'Validate Reset button' , ( ) => {
305
+ it ( 'Validate Reset & Cancel buttons' , ( ) => {
306
+ // Reset button validation
300
307
resetButtonValidation ( ) ;
308
+ // Cancel button validation
309
+ cancelButtonValidation ( ) ;
301
310
} ) ;
302
311
303
312
it ( 'Validate Save button' , ( ) => {
0 commit comments