@@ -35,16 +35,10 @@ function addSchedule() {
35
35
function deleteSchedule ( scheduleName = 'Test name' ) {
36
36
// Selecting the schedule
37
37
cy . contains ( 'li.list-group-item' , scheduleName ) . click ( ) ;
38
- cy . on ( 'window:confirm' , ( text ) => {
39
- expect ( text ) . to . eq (
40
- 'Warning: This Schedule and ALL of its components will be permanently removed!'
41
- ) ;
42
- return true ;
43
- } ) ;
44
- selectConfigMenu ( 'Delete this Schedule from the Database' ) ;
45
- cy . get ( '#main_div #flash_msg_div .alert-success' ) . contains (
46
- `Schedule "${ scheduleName } ": Delete successful`
47
- ) ;
38
+ // Listening for the browser confirm alert and confirming
39
+ cy . listen_for_browser_confirm_alert ( ) ;
40
+ selectConfigMenu ( deleteScheduleConfigOption ) ;
41
+ cy . expect_flash ( 'success' ) ;
48
42
}
49
43
50
44
function invokeCleanupDeletion ( ) {
@@ -224,17 +218,13 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
224
218
cy . contains ( '#main-content .bx--btn-set button[type="button"]' , 'Cancel' )
225
219
. should ( 'be.enabled' )
226
220
. click ( ) ;
227
- cy . get ( '#main_div #flash_msg_div .alert-success' ) . contains (
228
- 'Add was cancelled by the user'
229
- ) ;
221
+ cy . expect_flash ( 'success' ) ;
230
222
} ) ;
231
223
232
224
it ( 'Checking whether add, edit & delete schedule works' , ( ) => {
233
225
/* ===== Adding a schedule ===== */
234
226
addSchedule ( ) ;
235
- cy . get ( '#main_div #flash_msg_div .alert-success' ) . contains (
236
- 'Schedule "Test name" was saved'
237
- ) ;
227
+ cy . expect_flash ( 'success' ) ;
238
228
239
229
/* ===== Editing a schedule ===== */
240
230
// Selecting the created schedule
@@ -247,9 +237,7 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
247
237
cy . contains ( '#main-content .bx--btn-set button[type="submit"]' , 'Save' )
248
238
. should ( 'be.enabled' )
249
239
. click ( ) ;
250
- cy . get ( '#main_div #flash_msg_div .alert-success' ) . contains (
251
- 'Schedule "Dummy name" was saved'
252
- ) ;
240
+ cy . expect_flash ( 'success' ) ;
253
241
254
242
/* ===== Delete is already handled from afterEach hook ===== */
255
243
} ) ;
@@ -265,9 +253,7 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
265
253
cy . contains ( '#main-content .bx--btn-set button[type="button"]' , 'Cancel' )
266
254
. should ( 'be.enabled' )
267
255
. click ( ) ;
268
- cy . get ( '#main_div #flash_msg_div .alert-success' ) . contains (
269
- 'Edit of "Test name" was cancelled by the user'
270
- ) ;
256
+ cy . expect_flash ( 'success' ) ;
271
257
272
258
/* ===== Checking whether Reset button works ===== */
273
259
// Selecting the created schedule
@@ -279,9 +265,7 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
279
265
cy . contains ( '#main-content .bx--btn-set button[type="button"]' , 'Reset' )
280
266
. should ( 'be.enabled' )
281
267
. click ( ) ;
282
- cy . get ( '#main_div #flash_msg_div .alert-warning' ) . contains (
283
- 'All changes have been reset'
284
- ) ;
268
+ cy . expect_flash ( 'warning' ) ;
285
269
// Confirming the edited fields contain the old values after resetting
286
270
cy . get ( 'input#description' ) . should ( 'have.value' , 'Test description' ) ;
287
271
cy . get ( 'input#start_date' ) . should ( 'have.value' , '06/30/2025' ) ;
@@ -296,9 +280,7 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
296
280
297
281
/* ===== Trying to add the same schedule again ===== */
298
282
addSchedule ( ) ;
299
- cy . get ( '#main_div #flash_msg_div .alert-danger' ) . contains (
300
- 'Error when adding a new schedule: Validation failed: MiqSchedule: Name has already been taken'
301
- ) ;
283
+ cy . expect_flash ( 'error' ) ;
302
284
} ) ;
303
285
304
286
it ( 'Checking whether Disabling, Enabling & Queueing up the schedule works' , ( ) => {
@@ -308,22 +290,16 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
308
290
cy . contains ( 'li.list-group-item' , 'Test name' ) . click ( ) ;
309
291
310
292
/* ===== Disabling the schedule ===== */
311
- selectConfigMenu ( 'Disable this Schedule' ) ;
312
- cy . get ( '#main_div #flash_msg_div .alert-info' ) . contains (
313
- 'The selected Schedules were disabled'
314
- ) ;
293
+ selectConfigMenu ( disableScheduleConfigOption ) ;
294
+ cy . expect_flash ( 'info' ) ;
315
295
316
296
/* ===== Enabling the schedule ===== */
317
- selectConfigMenu ( 'Enable this Schedule' ) ;
318
- cy . get ( '#main_div #flash_msg_div .alert-info' ) . contains (
319
- 'The selected Schedules were enabled'
320
- ) ;
297
+ selectConfigMenu ( enableScheduleConfigOption ) ;
298
+ cy . expect_flash ( 'info' ) ;
321
299
322
300
/* ===== Queueing-up the schedule ===== */
323
- selectConfigMenu ( 'Queue up this Schedule to run now' ) ;
324
- cy . get ( '#main_div #flash_msg_div .alert-success' ) . contains (
325
- 'The selected Schedule has been queued to run'
326
- ) ;
301
+ selectConfigMenu ( queueScheduleConfigOption ) ;
302
+ cy . expect_flash ( 'success' ) ;
327
303
} ) ;
328
304
329
305
afterEach ( ( ) => {
0 commit comments