Skip to content

Commit

Permalink
chore: handle no events in the program stage during cypress cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
simonadomnisoru committed Sep 5, 2023
1 parent e48824d commit a2d9456
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions cypress/integration/EnrollmentPage/HiddenProgramStage/index.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
import moment from 'moment';

const cleanUp = () => {
cy.visit(
'/#/enrollment?enrollmentId=fmhIsWXVDmS&orgUnitId=s7SLtx8wmRA&programId=WSGAb5XwJ3Y&teiId=uW8Y7AIcRKA',
);

cy.get('[data-test="enrollment-page-content"]').contains('Enrollment Dashboard');

cy.get('[data-test="stages-and-events-widget"]')
.find('[data-test="stage-content"]')
.eq(3)
.click();

cy.contains('WHOMCH Pregnancy outcome').should('exist');
cy.contains('[data-test="dhis2-uicore-button"]', 'Edit event').click();
cy.contains('[data-test="dhis2-uicore-button"]', 'Delete').click();
cy.contains('[data-test="dhis2-uicore-button"]', 'Yes, delete event').click();
const cleanUpIfApplicable = () => {
cy.buildApiUrl(
'tracker',
'trackedEntities/uW8Y7AIcRKA?program=WSGAb5XwJ3Y&fields=enrollments',
)
.then(url => cy.request(url))
.then(({ body }) => {
const enrollment = body.enrollments?.find(e => e.enrollment === 'fmhIsWXVDmS');
const event = enrollment?.events?.find(e => e.programStage === 'PFDfvmGpsR3');
if (!event) {
return null;
}
return cy
.buildApiUrl('events', event.event)
.then(eventUrl =>
cy.request('DELETE', eventUrl));
});
};

Given('you add an enrollment event that will result in a rule effect to hide a program stage', () => {
cleanUp();
cleanUpIfApplicable();
cy.visit(
'/#/enrollmentEventNew?enrollmentId=fmhIsWXVDmS&orgUnitId=s7SLtx8wmRA&programId=WSGAb5XwJ3Y&stageId=PFDfvmGpsR3&teiId=uW8Y7AIcRKA',
);
Expand Down

0 comments on commit a2d9456

Please sign in to comment.