Skip to content

Commit 1f7f6ea

Browse files
Added validation to confirm navigation to App-Settings before triggering cleanup
1 parent f7bec34 commit 1f7f6ea

File tree

1 file changed

+24
-10
lines changed

1 file changed

+24
-10
lines changed

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

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,22 @@ function deleteSchedule(scheduleName = 'Test name') {
4747
);
4848
}
4949

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+
5066
describe('Automate Schedule form operations: Settings > Application Settings > Settings > Schedules > Configuration > Add a new schedule', () => {
5167
beforeEach(() => {
5268
cy.login();
@@ -307,17 +323,15 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
307323
});
308324

309325
afterEach(() => {
310-
cy.get('li.list-group-item').each(($el) => {
311-
const text = $el?.text()?.trim();
312-
if (text === 'Test name') {
313-
deleteSchedule();
314-
return false;
315-
}
316-
if (text === 'Dummy name') {
317-
deleteSchedule('Dummy name');
318-
return false;
326+
cy?.url()?.then((url) => {
327+
// Ensures navigation to Settings -> Application-Settings in the UI
328+
if (url?.includes('/ops/explorer')) {
329+
invokeCleanupDeletion();
330+
} else {
331+
// Navigate to Settings -> Application-Settings before looking out for Schedules created during test
332+
cy.menu('Settings', 'Application Settings');
333+
invokeCleanupDeletion();
319334
}
320-
return true;
321335
});
322336
});
323337
});

0 commit comments

Comments
 (0)