@@ -24,7 +24,7 @@ function addSchedule() {
24
24
cy . contains ( '[role="option"]' , '(GMT-10:00) Hawaii' )
25
25
. should ( 'be.visible' )
26
26
. click ( ) ;
27
- cy . get ( 'input#start_date' ) . type ( '06/30/2025' , { force : true } ) ;
27
+ cy . get ( 'input#start_date' ) . type ( '06/30/2025' ) ;
28
28
cy . get ( 'input#start_time' ) . type ( '11:23' ) ;
29
29
// Checks if Save button is enabled once all required fields are filled
30
30
cy . contains ( '#main-content .bx--btn-set button[type="submit"]' , 'Save' )
@@ -47,11 +47,41 @@ function deleteSchedule(scheduleName = 'Test name') {
47
47
) ;
48
48
}
49
49
50
+ function invokeCleanupDeletion ( ) {
51
+ // Iterate and clean up any leftover schedules created during the test
52
+ cy . get ( 'li.list-group-item' ) . each ( ( $el ) => {
53
+ const text = $el ?. text ( ) ?. trim ( ) ;
54
+ if ( text === 'Test name' ) {
55
+ deleteSchedule ( ) ;
56
+ return false ;
57
+ }
58
+ if ( text === 'Dummy name' ) {
59
+ deleteSchedule ( 'Dummy name' ) ;
60
+ return false ;
61
+ }
62
+ return true ;
63
+ } ) ;
64
+ }
65
+
66
+ function verifyFilterTypeDropdownExists ( ) {
67
+ cy . get ( 'label[for="filter_typ"]' ) . should ( 'exist' ) ;
68
+ cy . get ( 'select#filter_typ' ) . should ( 'exist' ) ;
69
+ }
70
+
71
+ function verifyTimerDropdownExists ( ) {
72
+ cy . get ( 'label[for="timer_value"]' ) . should ( 'exist' ) ;
73
+ cy . get ( 'select#timer_value' ) . should ( 'exist' ) ;
74
+ }
75
+
50
76
describe ( 'Automate Schedule form operations: Settings > Application Settings > Settings > Schedules > Configuration > Add a new schedule' , ( ) => {
51
77
beforeEach ( ( ) => {
52
78
cy . login ( ) ;
53
- cy . menu ( 'Settings' , 'Application Settings' ) ;
79
+ cy . menu ( settingsMenuOption , appSettingsMenuOption ) ;
80
+ cy . intercept ( 'POST' , '/ops/tree_select?id=xx-msc&text=Schedules' ) . as (
81
+ 'getSchedules'
82
+ ) ;
54
83
cy . get ( '[title="Schedules"]' ) . click ( ) ;
84
+ cy . wait ( '@getSchedules' ) ;
55
85
} ) ;
56
86
57
87
it ( 'Validate visibility of elements based on dropdown selections' , ( ) => {
@@ -168,22 +198,22 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
168
198
169
199
/* ===== Selecting any other option other than "Once" from "Run" dropdown shows the "Every" dropdown ===== */
170
200
171
- cy . get ( 'select#timer_typ' ) . select ( 'Hours' , { force : true } ) ;
201
+ cy . get ( 'select#timer_typ' ) . select ( 'Hours' ) ;
172
202
// Checking whether the "Every" dropdown exist
173
203
cy . get ( 'label[for="timer_value"]' ) . should ( 'exist' ) ;
174
204
cy . get ( 'select#timer_value' ) . should ( 'exist' ) ;
175
205
176
- cy . get ( 'select#timer_typ' ) . select ( 'Days' , { force : true } ) ;
206
+ cy . get ( 'select#timer_typ' ) . select ( 'Days' ) ;
177
207
// Checking whether the "Every" dropdown exist
178
208
cy . get ( 'label[for="timer_value"]' ) . should ( 'exist' ) ;
179
209
cy . get ( 'select#timer_value' ) . should ( 'exist' ) ;
180
210
181
- cy . get ( 'select#timer_typ' ) . select ( 'Weeks' , { force : true } ) ;
211
+ cy . get ( 'select#timer_typ' ) . select ( 'Weeks' ) ;
182
212
// Checking whether the "Every" dropdown exist
183
213
cy . get ( 'label[for="timer_value"]' ) . should ( 'exist' ) ;
184
214
cy . get ( 'select#timer_value' ) . should ( 'exist' ) ;
185
215
186
- cy . get ( 'select#timer_typ' ) . select ( 'Months' , { force : true } ) ;
216
+ cy . get ( 'select#timer_typ' ) . select ( 'Months' ) ;
187
217
// Checking whether the "Every" dropdown exist
188
218
cy . get ( 'label[for="timer_value"]' ) . should ( 'exist' ) ;
189
219
cy . get ( 'select#timer_value' ) . should ( 'exist' ) ;
@@ -221,8 +251,7 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
221
251
'Schedule "Dummy name" was saved'
222
252
) ;
223
253
224
- /* ===== Deleting schedule ===== */
225
- deleteSchedule ( 'Dummy name' ) ;
254
+ /* ===== Delete is already handled from afterEach hook ===== */
226
255
} ) ;
227
256
228
257
it ( 'Checking whether Cancel & Reset buttons work fine in the Edit form' , ( ) => {
@@ -246,7 +275,7 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
246
275
selectConfigMenu ( 'Edit this Schedule' ) ;
247
276
// Editing description and start date
248
277
cy . get ( 'input#description' ) . clear ( ) . type ( 'Dummy description' ) ;
249
- cy . get ( 'input#start_date' ) . clear ( ) . type ( '07/21/2025' , { force : true } ) ;
278
+ cy . get ( 'input#start_date' ) . clear ( ) . type ( '07/21/2025' ) ;
250
279
cy . contains ( '#main-content .bx--btn-set button[type="button"]' , 'Reset' )
251
280
. should ( 'be.enabled' )
252
281
. click ( ) ;
@@ -257,9 +286,8 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
257
286
cy . get ( 'input#description' ) . should ( 'have.value' , 'Test description' ) ;
258
287
cy . get ( 'input#start_date' ) . should ( 'have.value' , '06/30/2025' ) ;
259
288
260
- /* ===== Deleting schedule ===== */
289
+ // Selecting Schedules menu item to bypass a bug, can be removed once #9505 is merged
261
290
cy . get ( '[title="Schedules"]' ) . click ( ) ;
262
- deleteSchedule ( ) ;
263
291
} ) ;
264
292
265
293
it ( 'Checking whether creating a duplicate record is restricted' , ( ) => {
@@ -271,9 +299,6 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
271
299
cy . get ( '#main_div #flash_msg_div .alert-danger' ) . contains (
272
300
'Error when adding a new schedule: Validation failed: MiqSchedule: Name has already been taken'
273
301
) ;
274
-
275
- /* ===== Deleting schedule ===== */
276
- deleteSchedule ( ) ;
277
302
} ) ;
278
303
279
304
it ( 'Checking whether Disabling, Enabling & Queueing up the schedule works' , ( ) => {
@@ -299,8 +324,18 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
299
324
cy . get ( '#main_div #flash_msg_div .alert-success' ) . contains (
300
325
'The selected Schedule has been queued to run'
301
326
) ;
327
+ } ) ;
302
328
303
- /* ===== Deleting schedule ===== */
304
- deleteSchedule ( ) ;
329
+ afterEach ( ( ) => {
330
+ cy ?. url ( ) ?. then ( ( url ) => {
331
+ // Ensures navigation to Settings -> Application-Settings in the UI
332
+ if ( url ?. includes ( '/ops/explorer' ) ) {
333
+ invokeCleanupDeletion ( ) ;
334
+ } else {
335
+ // Navigate to Settings -> Application-Settings before looking out for Schedules created during test
336
+ cy . menu ( 'Settings' , 'Application Settings' ) ;
337
+ invokeCleanupDeletion ( ) ;
338
+ }
339
+ } ) ;
305
340
} ) ;
306
341
} ) ;
0 commit comments