@@ -31,9 +31,6 @@ const textConstants = {
31
31
dropdownBlankValue : 'BLANK_VALUE' ,
32
32
sambaDropdownValue : 'FileDepotSmb' ,
33
33
34
- // Button types
35
- submitButtonType : 'submit' ,
36
-
37
34
// Component route url
38
35
componentRouteUrl : '/ops/explorer' ,
39
36
@@ -42,7 +39,7 @@ const textConstants = {
42
39
43
40
// Flash message text snippets
44
41
flashMessageSettingsSaved : 'saved' ,
45
- flashMessageOperationCanceled : 'cancel' ,
42
+ flashMessageOperationCancelled : 'cancel' ,
46
43
} ;
47
44
48
45
const {
@@ -62,8 +59,7 @@ const {
62
59
componentRouteUrl,
63
60
flashTypeSuccess,
64
61
flashMessageSettingsSaved,
65
- flashMessageOperationCanceled,
66
- submitButtonType,
62
+ flashMessageOperationCancelled,
67
63
protocolSelectFieldId,
68
64
formHeader,
69
65
formSubheaderSnippet,
@@ -89,7 +85,7 @@ function interceptAndAwaitApi({
89
85
cy . wait ( `@${ alias } ` ) ;
90
86
}
91
87
92
- function invokeAndAwaitCollectLogsTabInfo ( { currentApiIntercepts } ) {
88
+ function goToCollectLogsTab ( { currentApiIntercepts } ) {
93
89
interceptAndAwaitApi ( {
94
90
alias : 'getCollectLogsTabInfo' ,
95
91
urlPattern : '/ops/change_tab?tab_id=diagnostics_collect_logs' ,
@@ -103,10 +99,11 @@ function invokeAndAwaitCollectLogsTabInfo({ currentApiIntercepts }) {
103
99
} ) ;
104
100
}
105
101
106
- function invokeAndAwaitEditEventForServer ( { currentApiIntercepts } ) {
102
+ function selectToolbarEditButton ( ) {
107
103
interceptAndAwaitApi ( {
108
104
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
105
+ // This pattern matches both /ops/x_button/1?pressed=log_depot_edit & /ops/x_button/2?pressed=zone_log_depot_edit endpoints
106
+ 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
107
triggerFn : ( ) => cy . toolbar ( editToolbarButton ) ,
111
108
currentApiIntercepts,
112
109
} ) ;
@@ -126,28 +123,28 @@ function resetProtocolDropdown({
126
123
] ) ;
127
124
128
125
// Clicking Edit button
129
- invokeAndAwaitEditEventForServer ( { currentApiIntercepts } ) ;
126
+ selectToolbarEditButton ( { currentApiIntercepts } ) ;
130
127
131
128
// Resetting Protocol dropdown value
132
- cy . getFormSelectFieldById ( protocolSelectFieldId ) . then ( ( $select ) => {
133
- const currentValue = $select . val ( ) ;
129
+ cy . getFormSelectFieldById ( protocolSelectFieldId ) . then ( ( selectField ) => {
130
+ const currentValue = selectField . val ( ) ;
134
131
// If the value is not default one(BLANK_VALUE), then setting it to blank
135
132
if ( currentValue !== dropdownBlankValue ) {
136
- cy . wrap ( $select ) . select ( dropdownBlankValue ) ;
137
- cy . getFormFooterButtonByType ( saveButton , submitButtonType ) . click ( ) ;
133
+ cy . wrap ( selectField ) . select ( dropdownBlankValue ) ;
134
+ cy . getFormFooterButtonByType ( saveButton , 'submit' ) . click ( ) ;
138
135
// Validating confirmation flash message
139
136
cy . expect_flash ( flashTypeSuccess , flashMessageSettingsSaved ) ;
140
137
}
141
138
} ) ;
142
139
}
143
140
144
- function goToCollectLogsNavbarAndOpenEditForm ( registeredApiIntercepts ) {
145
- // Selecting Collect Logs nav bar
146
- invokeAndAwaitCollectLogsTabInfo ( {
141
+ function goToCollectLogsTabAndOpenEditForm ( registeredApiIntercepts ) {
142
+ // Selecting Collect Logs tab
143
+ goToCollectLogsTab ( {
147
144
currentApiIntercepts : registeredApiIntercepts ,
148
145
} ) ;
149
146
// Clicking Edit button
150
- invokeAndAwaitEditEventForServer ( {
147
+ selectToolbarEditButton ( {
151
148
currentApiIntercepts : registeredApiIntercepts ,
152
149
} ) ;
153
150
}
@@ -168,7 +165,7 @@ function validateFormElements() {
168
165
. should ( 'be.visible' )
169
166
. and ( 'be.enabled' ) ;
170
167
// Assert save button is visible and disabled
171
- cy . getFormFooterButtonByType ( saveButton , submitButtonType )
168
+ cy . getFormFooterButtonByType ( saveButton , 'submit' )
172
169
. should ( 'be.visible' )
173
170
. and ( 'be.disabled' ) ;
174
171
// Assert reset button is visible and disabled
@@ -181,7 +178,7 @@ function cancelButtonValidation() {
181
178
// Click cancel button in the form
182
179
cy . getFormFooterButtonByType ( cancelButton ) . click ( ) ;
183
180
// Validating confirmation flash message
184
- cy . expect_flash ( flashTypeSuccess , flashMessageOperationCanceled ) ;
181
+ cy . expect_flash ( flashTypeSuccess , flashMessageOperationCancelled ) ;
185
182
}
186
183
187
184
function resetButtonValidation ( ) {
@@ -200,7 +197,7 @@ function saveButtonValidation() {
200
197
// Selecting Samba option from dropdown
201
198
cy . getFormSelectFieldById ( protocolSelectFieldId ) . select ( sambaDropdownValue ) ;
202
199
// Confirm Save button is enabled once dropdown value is changed and then click on Save
203
- cy . getFormFooterButtonByType ( saveButton , submitButtonType )
200
+ cy . getFormFooterButtonByType ( saveButton , 'submit' )
204
201
. should ( 'be.enabled' )
205
202
. click ( ) ;
206
203
// Validating confirmation flash message
@@ -216,7 +213,7 @@ describe('Automate Collect logs Edit form operations', () => {
216
213
beforeEach ( ( ) => {
217
214
registeredApiIntercepts = { } ;
218
215
cy . login ( ) ;
219
- // Navigate to Application settings and Select Diagnostics
216
+ // Navigate to Application settings and expand Diagnostics accordion
220
217
cy . menu ( settingsMenuOption , appSettingsMenuOption ) ;
221
218
interceptAndAwaitApi ( {
222
219
alias : 'getDiagnosticsInfo' ,
@@ -235,19 +232,18 @@ describe('Automate Collect logs Edit form operations', () => {
235
232
serverAccordItem ,
236
233
] ) ;
237
234
// Select collect logs navbar and open edit form
238
- goToCollectLogsNavbarAndOpenEditForm ( registeredApiIntercepts ) ;
235
+ goToCollectLogsTabAndOpenEditForm ( registeredApiIntercepts ) ;
239
236
} ) ;
240
237
241
238
it ( 'Validate form elements' , ( ) => {
242
239
validateFormElements ( ) ;
243
240
} ) ;
244
241
245
- it ( 'Validate Cancel button' , ( ) => {
246
- cancelButtonValidation ( ) ;
247
- } ) ;
248
-
249
- it ( 'Validate Reset button' , ( ) => {
242
+ it ( 'Validate Reset & Cancel buttons' , ( ) => {
243
+ // Reset button validation
250
244
resetButtonValidation ( ) ;
245
+ // Cancel button validation
246
+ cancelButtonValidation ( ) ;
251
247
} ) ;
252
248
253
249
it ( 'Validate Save button' , ( ) => {
@@ -282,20 +278,19 @@ describe('Automate Collect logs Edit form operations', () => {
282
278
cy . selectAccordionItem ( [ manageIQRegionAccordItem , zoneAccordItem ] ) ,
283
279
currentApiIntercepts : registeredApiIntercepts ,
284
280
} ) ;
285
- // Select collect logs navbar and open edit form
286
- goToCollectLogsNavbarAndOpenEditForm ( registeredApiIntercepts ) ;
281
+ // Select collect logs tab and open edit form
282
+ goToCollectLogsTabAndOpenEditForm ( registeredApiIntercepts ) ;
287
283
} ) ;
288
284
289
285
it ( 'Validate form elements' , ( ) => {
290
286
validateFormElements ( ) ;
291
287
} ) ;
292
288
293
- it ( 'Validate Cancel button' , ( ) => {
294
- cancelButtonValidation ( ) ;
295
- } ) ;
296
-
297
- it ( 'Validate Reset button' , ( ) => {
289
+ it ( 'Validate Reset & Cancel buttons' , ( ) => {
290
+ // Reset button validation
298
291
resetButtonValidation ( ) ;
292
+ // Cancel button validation
293
+ cancelButtonValidation ( ) ;
299
294
} ) ;
300
295
301
296
it ( 'Validate Save button' , ( ) => {
0 commit comments