Skip to content

Commit 84a923d

Browse files
Updated addSchedule method to pass down created name via callback
1 parent 8c8b4a9 commit 84a923d

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

cypress/e2e/ui/Settings/Application-Settings/schedule.cy.js

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ function selectConfigMenu(menuOption) {
7070
return cy.toolbar(CONFIG_TOOLBAR_BUTTON, menuOption);
7171
}
7272

73-
function addSchedule() {
73+
function addSchedule({ afterScheduleCreated = () => {} } = {}) {
7474
// Open add schedule form
7575
selectConfigMenu(ADD_SCHEDULE_CONFIG_OPTION);
7676
// Checks if Save button is disabled initially
@@ -106,6 +106,7 @@ function addSchedule() {
106106
.getFormFooterButtonByType(SAVE_BUTTON_TEXT, 'submit')
107107
.should('be.enabled') // Checks if Save button is enabled once all required fields are filled
108108
.click(),
109+
onApiResponse: () => afterScheduleCreated(INITIAL_SCHEDULE_NAME),
109110
});
110111
}
111112

@@ -333,12 +334,17 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
333334

334335
it('Checking whether add, edit & delete schedule works', () => {
335336
/* ===== 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+
});
338346

339347
/* ===== Editing a schedule ===== */
340-
// Selecting the schedule and intercepting the API call to get schedule details
341-
clickScheduleItem(INITIAL_SCHEDULE_NAME);
342348
// Open edit schedule form
343349
selectConfigMenu(EDIT_SCHEDULE_CONFIG_OPTION);
344350
// Editing name and description
@@ -355,11 +361,15 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
355361

356362
it('Checking whether Cancel & Reset buttons work fine in the Edit form', () => {
357363
/* ===== 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+
});
359371

360372
/* ===== Checking whether Reset button works ===== */
361-
// Selecting the schedule and intercepting the API call to get schedule details
362-
clickScheduleItem(INITIAL_SCHEDULE_NAME);
363373
// Open edit schedule form
364374
selectConfigMenu(EDIT_SCHEDULE_CONFIG_OPTION);
365375
// Editing description and start date

0 commit comments

Comments
 (0)