@@ -79,28 +79,8 @@ const {
79
79
flashMessageOperationCancelled,
80
80
} = textConstants ;
81
81
82
- function interceptAndAwaitApi ( {
83
- alias,
84
- method = 'POST' ,
85
- urlPattern,
86
- triggerFn,
87
- currentApiIntercepts,
88
- } ) {
89
- // If the alias is already registered, do not register it again
90
- // This prevents multiple intercepts for the same API call
91
- // which can lead to unexpected behavior in tests.
92
- if ( ! currentApiIntercepts [ alias ] ) {
93
- cy . intercept ( method , urlPattern ) . as ( alias ) ;
94
- currentApiIntercepts [ alias ] = alias ;
95
- }
96
-
97
- triggerFn ( ) ;
98
-
99
- cy . wait ( `@${ alias } ` ) ;
100
- }
101
-
102
- function goToCollectLogsTab ( { currentApiIntercepts } ) {
103
- interceptAndAwaitApi ( {
82
+ function goToCollectLogsTab ( ) {
83
+ cy . interceptApi ( {
104
84
alias : 'getCollectLogsTabInfo' ,
105
85
urlPattern : '/ops/change_tab?tab_id=diagnostics_collect_logs' ,
106
86
triggerFn : ( ) =>
@@ -109,24 +89,19 @@ function goToCollectLogsTab({ currentApiIntercepts }) {
109
89
'#tab_all_tabs_div #ops_tabs .nav-tabs li#diagnostics_collect_logs_tab'
110
90
)
111
91
. click ( ) ,
112
- currentApiIntercepts,
113
92
} ) ;
114
93
}
115
94
116
95
function selectToolbarEditButton ( ) {
117
- interceptAndAwaitApi ( {
96
+ cy . interceptApi ( {
118
97
alias : 'editEventForServer' ,
119
98
// This pattern matches both /ops/x_button/1?pressed=log_depot_edit & /ops/x_button/2?pressed=zone_log_depot_edit endpoints
120
99
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 / ,
121
100
triggerFn : ( ) => cy . toolbar ( editToolbarButton ) ,
122
- currentApiIntercepts,
123
101
} ) ;
124
102
}
125
103
126
- function resetProtocolDropdown ( {
127
- currentApiIntercepts,
128
- selectServerListItem = true ,
129
- } ) {
104
+ function resetProtocolDropdown ( { selectServerListItem = true } = { } ) {
130
105
// Select Diagnostics
131
106
cy . accordion ( diagnosticsAccordionItem ) ;
132
107
// Select "Zone:" or "Server:" accordion item
@@ -137,7 +112,7 @@ function resetProtocolDropdown({
137
112
] ) ;
138
113
139
114
// Clicking Edit button
140
- selectToolbarEditButton ( { currentApiIntercepts } ) ;
115
+ selectToolbarEditButton ( ) ;
141
116
142
117
// Resetting Protocol dropdown value
143
118
cy . getFormSelectFieldById ( protocolSelectFieldId ) . then ( ( selectField ) => {
@@ -152,15 +127,11 @@ function resetProtocolDropdown({
152
127
} ) ;
153
128
}
154
129
155
- function goToCollectLogsTabAndOpenEditForm ( registeredApiIntercepts ) {
130
+ function goToCollectLogsTabAndOpenEditForm ( ) {
156
131
// Selecting Collect Logs tab
157
- goToCollectLogsTab ( {
158
- currentApiIntercepts : registeredApiIntercepts ,
159
- } ) ;
132
+ goToCollectLogsTab ( ) ;
160
133
// Clicking Edit button
161
- selectToolbarEditButton ( {
162
- currentApiIntercepts : registeredApiIntercepts ,
163
- } ) ;
134
+ selectToolbarEditButton ( ) ;
164
135
}
165
136
166
137
function validateFormElements ( ) {
@@ -221,21 +192,14 @@ function saveButtonValidation() {
221
192
}
222
193
223
194
describe ( 'Automate Collect logs Edit form operations' , ( ) => {
224
- // Map that keeps track of registered API intercepts
225
- // This is used to avoid registering the same API intercept multiple times
226
- // during the test run, which can lead to unexpected behavior.
227
- let registeredApiIntercepts ;
228
-
229
195
beforeEach ( ( ) => {
230
- registeredApiIntercepts = { } ;
231
196
cy . login ( ) ;
232
197
// Navigate to Application settings and expand Diagnostics accordion
233
198
cy . menu ( settingsMenuOption , appSettingsMenuOption ) ;
234
- interceptAndAwaitApi ( {
199
+ cy . interceptApi ( {
235
200
alias : 'getDiagnosticsInfo' ,
236
201
urlPattern : `/ops/accordion_select?id=${ diagnosticsAccordionItemId } ` ,
237
202
triggerFn : ( ) => cy . accordion ( diagnosticsAccordionItem ) ,
238
- currentApiIntercepts : registeredApiIntercepts ,
239
203
} ) ;
240
204
} ) ;
241
205
@@ -248,7 +212,7 @@ describe('Automate Collect logs Edit form operations', () => {
248
212
serverAccordItem ,
249
213
] ) ;
250
214
// Select collect logs navbar and open edit form
251
- goToCollectLogsTabAndOpenEditForm ( registeredApiIntercepts ) ;
215
+ goToCollectLogsTabAndOpenEditForm ( ) ;
252
216
} ) ;
253
217
254
218
it ( 'Validate form elements' , ( ) => {
@@ -276,26 +240,23 @@ describe('Automate Collect logs Edit form operations', () => {
276
240
}
277
241
} )
278
242
. then ( ( ) => {
279
- resetProtocolDropdown ( {
280
- currentApiIntercepts : registeredApiIntercepts ,
281
- } ) ;
243
+ resetProtocolDropdown ( ) ;
282
244
} ) ;
283
245
} ) ;
284
246
} ) ;
285
247
286
248
describe ( 'Settings > Application Settings > Diagnostics > Manage IQ Region > Zone > Collect logs > Edit' , ( ) => {
287
249
beforeEach ( ( ) => {
288
250
// Select "Zone:" accordion item
289
- interceptAndAwaitApi ( {
251
+ cy . interceptApi ( {
290
252
alias : 'treeSelectApi' ,
291
253
urlPattern :
292
254
/ o p s \/ t r e e _ s e l e c t \? i d = .* & t e x t = .* Z o n e .* D e f a u l t .* Z o n e .* ( c u r r e n t ) .* / ,
293
255
triggerFn : ( ) =>
294
256
cy . selectAccordionItem ( [ manageIQRegionAccordItem , zoneAccordItem ] ) ,
295
- currentApiIntercepts : registeredApiIntercepts ,
296
257
} ) ;
297
258
// Select collect logs tab and open edit form
298
- goToCollectLogsTabAndOpenEditForm ( registeredApiIntercepts ) ;
259
+ goToCollectLogsTabAndOpenEditForm ( ) ;
299
260
} ) ;
300
261
301
262
it ( 'Validate form elements' , ( ) => {
@@ -323,12 +284,8 @@ describe('Automate Collect logs Edit form operations', () => {
323
284
}
324
285
} )
325
286
. then ( ( ) => {
326
- resetProtocolDropdown ( {
327
- currentApiIntercepts : registeredApiIntercepts ,
328
- selectServerListItem : false ,
329
- } ) ;
287
+ resetProtocolDropdown ( { selectServerListItem : false } ) ;
330
288
} ) ;
331
289
} ) ;
332
290
} ) ;
333
291
} ) ;
334
-
0 commit comments