@@ -65,28 +65,8 @@ const {
65
65
formSubheaderSnippet,
66
66
} = textConstants ;
67
67
68
- function interceptAndAwaitApi ( {
69
- alias,
70
- method = 'POST' ,
71
- urlPattern,
72
- triggerFn,
73
- currentApiIntercepts,
74
- } ) {
75
- // If the alias is already registered, do not register it again
76
- // This prevents multiple intercepts for the same API call
77
- // which can lead to unexpected behavior in tests.
78
- if ( ! currentApiIntercepts [ alias ] ) {
79
- cy . intercept ( method , urlPattern ) . as ( alias ) ;
80
- currentApiIntercepts [ alias ] = alias ;
81
- }
82
-
83
- triggerFn ( ) ;
84
-
85
- cy . wait ( `@${ alias } ` ) ;
86
- }
87
-
88
- function goToCollectLogsTab ( { currentApiIntercepts } ) {
89
- interceptAndAwaitApi ( {
68
+ function goToCollectLogsTab ( ) {
69
+ cy . interceptApi ( {
90
70
alias : 'getCollectLogsTabInfo' ,
91
71
urlPattern : '/ops/change_tab?tab_id=diagnostics_collect_logs' ,
92
72
triggerFn : ( ) =>
@@ -95,24 +75,19 @@ function goToCollectLogsTab({ currentApiIntercepts }) {
95
75
'#tab_all_tabs_div #ops_tabs .nav-tabs li#diagnostics_collect_logs_tab'
96
76
)
97
77
. click ( ) ,
98
- currentApiIntercepts,
99
78
} ) ;
100
79
}
101
80
102
81
function selectToolbarEditButton ( ) {
103
- interceptAndAwaitApi ( {
82
+ cy . interceptApi ( {
104
83
alias : 'editEventForServer' ,
105
84
// This pattern matches both /ops/x_button/1?pressed=log_depot_edit & /ops/x_button/2?pressed=zone_log_depot_edit endpoints
106
85
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 / ,
107
86
triggerFn : ( ) => cy . toolbar ( editToolbarButton ) ,
108
- currentApiIntercepts,
109
87
} ) ;
110
88
}
111
89
112
- function resetProtocolDropdown ( {
113
- currentApiIntercepts,
114
- selectServerListItem = true ,
115
- } ) {
90
+ function resetProtocolDropdown ( { selectServerListItem = true } = { } ) {
116
91
// Select Diagnostics
117
92
cy . accordion ( diagnosticsAccordionItem ) ;
118
93
// Select "Zone:" or "Server:" accordion item
@@ -123,7 +98,7 @@ function resetProtocolDropdown({
123
98
] ) ;
124
99
125
100
// Clicking Edit button
126
- selectToolbarEditButton ( { currentApiIntercepts } ) ;
101
+ selectToolbarEditButton ( ) ;
127
102
128
103
// Resetting Protocol dropdown value
129
104
cy . getFormSelectFieldById ( protocolSelectFieldId ) . then ( ( selectField ) => {
@@ -138,15 +113,11 @@ function resetProtocolDropdown({
138
113
} ) ;
139
114
}
140
115
141
- function goToCollectLogsTabAndOpenEditForm ( registeredApiIntercepts ) {
116
+ function goToCollectLogsTabAndOpenEditForm ( ) {
142
117
// Selecting Collect Logs tab
143
- goToCollectLogsTab ( {
144
- currentApiIntercepts : registeredApiIntercepts ,
145
- } ) ;
118
+ goToCollectLogsTab ( ) ;
146
119
// Clicking Edit button
147
- selectToolbarEditButton ( {
148
- currentApiIntercepts : registeredApiIntercepts ,
149
- } ) ;
120
+ selectToolbarEditButton ( ) ;
150
121
}
151
122
152
123
function validateFormElements ( ) {
@@ -205,21 +176,14 @@ function saveButtonValidation() {
205
176
}
206
177
207
178
describe ( 'Automate Collect logs Edit form operations' , ( ) => {
208
- // Map that keeps track of registered API intercepts
209
- // This is used to avoid registering the same API intercept multiple times
210
- // during the test run, which can lead to unexpected behavior.
211
- let registeredApiIntercepts ;
212
-
213
179
beforeEach ( ( ) => {
214
- registeredApiIntercepts = { } ;
215
180
cy . login ( ) ;
216
181
// Navigate to Application settings and expand Diagnostics accordion
217
182
cy . menu ( settingsMenuOption , appSettingsMenuOption ) ;
218
- interceptAndAwaitApi ( {
183
+ cy . interceptApi ( {
219
184
alias : 'getDiagnosticsInfo' ,
220
185
urlPattern : `/ops/accordion_select?id=${ diagnosticsAccordionItemId } ` ,
221
186
triggerFn : ( ) => cy . accordion ( diagnosticsAccordionItem ) ,
222
- currentApiIntercepts : registeredApiIntercepts ,
223
187
} ) ;
224
188
} ) ;
225
189
@@ -232,7 +196,7 @@ describe('Automate Collect logs Edit form operations', () => {
232
196
serverAccordItem ,
233
197
] ) ;
234
198
// Select collect logs navbar and open edit form
235
- goToCollectLogsTabAndOpenEditForm ( registeredApiIntercepts ) ;
199
+ goToCollectLogsTabAndOpenEditForm ( ) ;
236
200
} ) ;
237
201
238
202
it ( 'Validate form elements' , ( ) => {
@@ -260,26 +224,23 @@ describe('Automate Collect logs Edit form operations', () => {
260
224
}
261
225
} )
262
226
. then ( ( ) => {
263
- resetProtocolDropdown ( {
264
- currentApiIntercepts : registeredApiIntercepts ,
265
- } ) ;
227
+ resetProtocolDropdown ( ) ;
266
228
} ) ;
267
229
} ) ;
268
230
} ) ;
269
231
270
232
describe ( 'Settings > Application Settings > Diagnostics > Manage IQ Region > Zone > Collect logs > Edit' , ( ) => {
271
233
beforeEach ( ( ) => {
272
234
// Select "Zone:" accordion item
273
- interceptAndAwaitApi ( {
235
+ cy . interceptApi ( {
274
236
alias : 'treeSelectApi' ,
275
237
urlPattern :
276
238
/ 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 ) .* / ,
277
239
triggerFn : ( ) =>
278
240
cy . selectAccordionItem ( [ manageIQRegionAccordItem , zoneAccordItem ] ) ,
279
- currentApiIntercepts : registeredApiIntercepts ,
280
241
} ) ;
281
242
// Select collect logs tab and open edit form
282
- goToCollectLogsTabAndOpenEditForm ( registeredApiIntercepts ) ;
243
+ goToCollectLogsTabAndOpenEditForm ( ) ;
283
244
} ) ;
284
245
285
246
it ( 'Validate form elements' , ( ) => {
@@ -307,12 +268,8 @@ describe('Automate Collect logs Edit form operations', () => {
307
268
}
308
269
} )
309
270
. then ( ( ) => {
310
- resetProtocolDropdown ( {
311
- currentApiIntercepts : registeredApiIntercepts ,
312
- selectServerListItem : false ,
313
- } ) ;
271
+ resetProtocolDropdown ( { selectServerListItem : false } ) ;
314
272
} ) ;
315
273
} ) ;
316
274
} ) ;
317
275
} ) ;
318
-
0 commit comments