@@ -70,7 +70,7 @@ function selectConfigMenu(menuOption) {
70
70
return cy . toolbar ( CONFIG_TOOLBAR_BUTTON , menuOption ) ;
71
71
}
72
72
73
- function addSchedule ( ) {
73
+ function addSchedule ( { afterScheduleCreated = ( ) => { } } = { } ) {
74
74
// Open add schedule form
75
75
selectConfigMenu ( ADD_SCHEDULE_CONFIG_OPTION ) ;
76
76
// Checks if Save button is disabled initially
@@ -106,6 +106,7 @@ function addSchedule() {
106
106
. getFormFooterButtonByType ( SAVE_BUTTON_TEXT , 'submit' )
107
107
. should ( 'be.enabled' ) // Checks if Save button is enabled once all required fields are filled
108
108
. click ( ) ,
109
+ onApiResponse : ( ) => afterScheduleCreated ( INITIAL_SCHEDULE_NAME ) ,
109
110
} ) ;
110
111
}
111
112
@@ -333,12 +334,17 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
333
334
334
335
it ( 'Checking whether add, edit & delete schedule works' , ( ) => {
335
336
/* ===== Adding a schedule ===== */
336
- addSchedule ( ) ;
337
- cy . expect_flash ( flashClassMap . success , FLASH_MESSAGE_SCHEDULE_SAVED ) ;
337
+ addSchedule ( {
338
+ afterScheduleCreated : ( createdScheduleName ) => {
339
+ // createdScheduleName value will be "Test-name"
340
+ // Assert schedule saved flash message
341
+ cy . expect_flash ( flashClassMap . success , FLASH_MESSAGE_SCHEDULE_SAVED ) ;
342
+ // Selecting the schedule and intercepting the API call to get schedule details
343
+ clickScheduleItem ( createdScheduleName ) ;
344
+ } ,
345
+ } ) ;
338
346
339
347
/* ===== Editing a schedule ===== */
340
- // Selecting the schedule and intercepting the API call to get schedule details
341
- clickScheduleItem ( INITIAL_SCHEDULE_NAME ) ;
342
348
// Open edit schedule form
343
349
selectConfigMenu ( EDIT_SCHEDULE_CONFIG_OPTION ) ;
344
350
// Editing name and description
@@ -355,11 +361,15 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
355
361
356
362
it ( 'Checking whether Cancel & Reset buttons work fine in the Edit form' , ( ) => {
357
363
/* ===== Adding a schedule ===== */
358
- addSchedule ( ) ;
364
+ addSchedule ( {
365
+ afterScheduleCreated : ( createdScheduleName ) => {
366
+ // createdScheduleName value will be "Test-name"
367
+ // Selecting the schedule and intercepting the API call to get schedule details
368
+ clickScheduleItem ( createdScheduleName ) ;
369
+ } ,
370
+ } ) ;
359
371
360
372
/* ===== Checking whether Reset button works ===== */
361
- // Selecting the schedule and intercepting the API call to get schedule details
362
- clickScheduleItem ( INITIAL_SCHEDULE_NAME ) ;
363
373
// Open edit schedule form
364
374
selectConfigMenu ( EDIT_SCHEDULE_CONFIG_OPTION ) ;
365
375
// Editing description and start date
0 commit comments