Skip to content

Commit

Permalink
chore: [DHIS2-17657] flaky scenario in EnrollmentAddEventPageForm.fea…
Browse files Browse the repository at this point in the history
…ture (#3716)
  • Loading branch information
simonadomnisoru authored Jul 22, 2024
1 parent 8dd4296 commit d18cbb9
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
Feature: User interacts with the Enrollment New Event Workspace

# DHIS2-17657
@skip
Scenario: User can complete a Lab monitoring Event
Given you land on the enrollment new event page by having typed /#/enrollment?programId=ur1Edk5Oe2n&orgUnitId=DiszpKrYNg8&teiId=yGIeBkYzW2o&enrollmentId=Pm0VlgHBgRm
And the enrollment overview is finished loading
Expand All @@ -12,9 +10,8 @@ Feature: User interacts with the Enrollment New Event Workspace
And you click the Complete button
Then all events should be displayed
And the newest event in datatable nr 0 should contain Completed
And the events in Lab monitoring are deleted

# DHIS2-17657
@skip
Scenario: User can save a Sputum smear microscopy test without completing
Given you land on the enrollment new event page by having typed /#/enrollment?programId=ur1Edk5Oe2n&orgUnitId=DiszpKrYNg8&teiId=yGIeBkYzW2o&enrollmentId=Pm0VlgHBgRm
And the enrollment overview is finished loading
Expand All @@ -24,9 +21,10 @@ Feature: User interacts with the Enrollment New Event Workspace
And the user selects Positive
And you click the Save without completing button
Then all events should be displayed
And the newest event in datatable nr 2 should contain Active
And the newest event in datatable nr 2 should contain 13
And the newest event in datatable nr 2 should contain Positive
And the newest event in datatable nr 1 should contain Active
And the newest event in datatable nr 1 should contain 13
And the newest event in datatable nr 1 should contain Positive
And the events in Sputum smear microscopy are deleted

Scenario: Required fields should display an error when saving without data
Given you land on the enrollment new event page by having typed /#/enrollment?programId=ur1Edk5Oe2n&orgUnitId=DiszpKrYNg8&teiId=yGIeBkYzW2o&enrollmentId=Pm0VlgHBgRm
Expand Down Expand Up @@ -87,6 +85,6 @@ Feature: User interacts with the Enrollment New Event Workspace
And the enrollment status is active
And you type 2021-10-15 in the input number 0
And you select Died in the select number 0
And the user completes the event
And you click the Complete button
And the user completes the enrollment
Then the user sees the enrollment status and recently added event in Case outcome event status is completed
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,18 @@ And('the enrollment status is active', () => {
changeEnrollmentAndEventsStatus();
});

And('the user completes the event', () => {
And('you click the Complete button', () => {
cy.get('[data-test="dhis2-uicore-button"]')
.contains('Complete')
.click();
});

And('you click the Save without completing button', () => {
cy.get('[data-test="dhis2-uicore-button"]')
.contains('Save without completing')
.click();
});

When('the user completes the enrollment', () => {
cy.get('[data-test="enrollment-complete-modal"]').within(() => {
cy.contains('Case outcome completed').should('exist');
Expand Down Expand Up @@ -230,3 +236,23 @@ Then('the user sees the enrollment status and recently added event in Case outco
});
changeEnrollmentAndEventsStatus();
});

And(/^the events in (.*) are deleted$/, (name) => {
const programStages = [
{ name: 'Lab monitoring', id: 'EPEcjy3FWmI' },
{ name: 'Sputum smear microscopy', id: 'jdRD35YwbRH' },
];
const programStage = programStages.find(e => e.name === name);

cy.buildApiUrl('tracker', 'enrollments/Pm0VlgHBgRm?fields=events[programStage,event]')
.then(url => cy.request(url))
.then(({ body }) => {
const eventsToDelete = body.events.filter(e => e.programStage === programStage.id);

if (eventsToDelete) {
cy.buildApiUrl('tracker?async=false&importStrategy=DELETE').then((eventUrl) => {
cy.request('POST', eventUrl, { events: eventsToDelete });
});
}
});
});

0 comments on commit d18cbb9

Please sign in to comment.