From 6782c7007fde1e0635865762c37a5a6ec055c389 Mon Sep 17 00:00:00 2001 From: Simona Domnisoru Date: Mon, 16 Dec 2024 10:29:00 +0100 Subject: [PATCH 1/3] chore: fix cypress test --- .../EnrollmentEditEventPageForm.feature | 1 + .../EnrollmentEditEventPageForm.js | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/cypress/e2e/EnrollmentEditEventPage/EnrollmentEditEventPageForm/EnrollmentEditEventPageForm.feature b/cypress/e2e/EnrollmentEditEventPage/EnrollmentEditEventPageForm/EnrollmentEditEventPageForm.feature index 31ab0f99c8..b0eb978b21 100644 --- a/cypress/e2e/EnrollmentEditEventPage/EnrollmentEditEventPageForm/EnrollmentEditEventPageForm.feature +++ b/cypress/e2e/EnrollmentEditEventPage/EnrollmentEditEventPageForm/EnrollmentEditEventPageForm.feature @@ -77,6 +77,7 @@ And the user see the following text: 11 When the user clicks on the cancel button Then the user is navigated to the enrollment dashboard +@with-restore-event-schedule-date Scenario: User can update schedule date for a scheduled event Given you land on the enrollment event page with selected Person by having typed /#/enrollmentEventEdit?eventId=RIrfCcEP8Uu&orgUnitId=DiszpKrYNg8 Then the view enrollment event form is in edit mode diff --git a/cypress/e2e/EnrollmentEditEventPage/EnrollmentEditEventPageForm/EnrollmentEditEventPageForm.js b/cypress/e2e/EnrollmentEditEventPage/EnrollmentEditEventPageForm/EnrollmentEditEventPageForm.js index 3f42786176..46c7045b98 100644 --- a/cypress/e2e/EnrollmentEditEventPage/EnrollmentEditEventPageForm/EnrollmentEditEventPageForm.js +++ b/cypress/e2e/EnrollmentEditEventPage/EnrollmentEditEventPageForm/EnrollmentEditEventPageForm.js @@ -1,6 +1,18 @@ -import { defineStep as And, Given, Then, When } from '@badeball/cypress-cucumber-preprocessor'; +import { defineStep as And, Given, Then, When, Before } from '@badeball/cypress-cucumber-preprocessor'; import { getCurrentYear } from '../../../support/date'; +Before({ tags: '@with-restore-event-schedule-date' }, () => { + cy.buildApiUrl('tracker', 'events/RIrfCcEP8Uu') + .then(url => cy.request(url)) + .then((apiResponse) => { + const event = apiResponse.body; + const eventToUpdate = { ...event, scheduledAt: `${getCurrentYear() - 15}-01-07` }; + return cy + .buildApiUrl('tracker?async=false&importStrategy=UPDATE') + .then(eventUrl => cy.request('POST', eventUrl, { events: [eventToUpdate] })); + }); +}); + const changeEnrollmentAndEventsStatus = () => ( cy.buildApiUrl( 'tracker', From 8cd7192c6751164f115dbd5423ffc30e85d1f2a9 Mon Sep 17 00:00:00 2001 From: Simona Domnisoru Date: Mon, 16 Dec 2024 11:02:27 +0100 Subject: [PATCH 2/3] chore: stabilize cypress tests in dev --- .../EnrollmentAddEventPageForm.feature | 6 +++--- .../EnrollmentAddEventPageForm.js | 2 +- .../StagesAndEventsWidget/StagesAndEventsWidget.feature | 4 ++-- .../StagesAndEventsWidget/StagesAndEventsWidget.js | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cypress/e2e/EnrollmentAddEventPage/EnrollmentAddEventPageForm/EnrollmentAddEventPageForm.feature b/cypress/e2e/EnrollmentAddEventPage/EnrollmentAddEventPageForm/EnrollmentAddEventPageForm.feature index e74ed7c4f8..f6ac348149 100644 --- a/cypress/e2e/EnrollmentAddEventPage/EnrollmentAddEventPageForm/EnrollmentAddEventPageForm.feature +++ b/cypress/e2e/EnrollmentAddEventPage/EnrollmentAddEventPageForm/EnrollmentAddEventPageForm.feature @@ -21,9 +21,9 @@ 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 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 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 events in Sputum smear microscopy are deleted Scenario: Required fields should display an error when saving without data diff --git a/cypress/e2e/EnrollmentAddEventPage/EnrollmentAddEventPageForm/EnrollmentAddEventPageForm.js b/cypress/e2e/EnrollmentAddEventPage/EnrollmentAddEventPageForm/EnrollmentAddEventPageForm.js index 7a8523cfa6..8870d88e19 100644 --- a/cypress/e2e/EnrollmentAddEventPage/EnrollmentAddEventPageForm/EnrollmentAddEventPageForm.js +++ b/cypress/e2e/EnrollmentAddEventPage/EnrollmentAddEventPageForm/EnrollmentAddEventPageForm.js @@ -132,7 +132,7 @@ Then('all events should be displayed', () => { }); Then(/^the newest event in datatable nr (.*) should contain (.*)$/, (eq, status) => { - cy.get('[data-test="dhis2-uicore-datatable"]') + cy.get('[data-test="stage-content"]') .eq(eq) .within(() => { cy.get('[data-test="dhis2-uicore-datatablerow"]') diff --git a/cypress/e2e/EnrollmentPage/StagesAndEventsWidget/StagesAndEventsWidget.feature b/cypress/e2e/EnrollmentPage/StagesAndEventsWidget/StagesAndEventsWidget.feature index e944741b2f..c9b62f331e 100644 --- a/cypress/e2e/EnrollmentPage/StagesAndEventsWidget/StagesAndEventsWidget.feature +++ b/cypress/e2e/EnrollmentPage/StagesAndEventsWidget/StagesAndEventsWidget.feature @@ -69,9 +69,9 @@ Feature: User interacts with Stages and Events Widget When you click the Unskip event overflow button on the Skipped event Then there is an Overdue event in the TB visit stage - @with-restore-deleted-event + @with-add-event-to-delete Scenario: User can delete an event - Given you open the enrollment page by typing #/enrollment?enrollmentId=ikYMpSKXik1&orgUnitId=DiszpKrYNg8&programId=ur1Edk5Oe2n&teiId=Trc1H9T5C6f + Given you open the enrollment page by typing #/enrollment?enrollmentId=hVPClvNrk9Z&orgUnitId=DiszpKrYNg8&programId=ur1Edk5Oe2n&teiId=WLecfORSpr0 And there is an Active event in the TB visit stage When you click the Delete event overflow button on the Active event And you confirm you want to delete the event diff --git a/cypress/e2e/EnrollmentPage/StagesAndEventsWidget/StagesAndEventsWidget.js b/cypress/e2e/EnrollmentPage/StagesAndEventsWidget/StagesAndEventsWidget.js index 35d8996ee7..06c054a978 100644 --- a/cypress/e2e/EnrollmentPage/StagesAndEventsWidget/StagesAndEventsWidget.js +++ b/cypress/e2e/EnrollmentPage/StagesAndEventsWidget/StagesAndEventsWidget.js @@ -1,9 +1,9 @@ -import { Given, When, Then, defineStep as And, After } from '@badeball/cypress-cucumber-preprocessor'; +import { Given, When, Then, defineStep as And, Before } from '@badeball/cypress-cucumber-preprocessor'; import { getCurrentYear } from '../../../support/date'; import '../sharedSteps'; -After({ tags: '@with-restore-deleted-event' }, () => { - cy.visit('#/enrollment?enrollmentId=ikYMpSKXik1&orgUnitId=DiszpKrYNg8&programId=ur1Edk5Oe2n&teiId=Trc1H9T5C6f'); +Before({ tags: '@with-add-event-to-delete' }, () => { + cy.visit('#/enrollment?enrollmentId=hVPClvNrk9Z&orgUnitId=DiszpKrYNg8&programId=ur1Edk5Oe2n&teiId=WLecfORSpr0'); cy.get('[data-test="stages-and-events-widget"]') .find('[data-test="widget-contents"]') From 6c38c3c8584e09cd637b74b437f08c34169b2533 Mon Sep 17 00:00:00 2001 From: Simona Domnisoru Date: Mon, 16 Dec 2024 11:26:41 +0100 Subject: [PATCH 3/3] chore: stabilize cypress tests in dev --- .../StagesAndEventsWidget/StagesAndEventsWidget.feature | 4 ++-- .../StagesAndEventsWidget/StagesAndEventsWidget.js | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cypress/e2e/EnrollmentPage/StagesAndEventsWidget/StagesAndEventsWidget.feature b/cypress/e2e/EnrollmentPage/StagesAndEventsWidget/StagesAndEventsWidget.feature index c9b62f331e..e944741b2f 100644 --- a/cypress/e2e/EnrollmentPage/StagesAndEventsWidget/StagesAndEventsWidget.feature +++ b/cypress/e2e/EnrollmentPage/StagesAndEventsWidget/StagesAndEventsWidget.feature @@ -69,9 +69,9 @@ Feature: User interacts with Stages and Events Widget When you click the Unskip event overflow button on the Skipped event Then there is an Overdue event in the TB visit stage - @with-add-event-to-delete + @with-restore-deleted-event Scenario: User can delete an event - Given you open the enrollment page by typing #/enrollment?enrollmentId=hVPClvNrk9Z&orgUnitId=DiszpKrYNg8&programId=ur1Edk5Oe2n&teiId=WLecfORSpr0 + Given you open the enrollment page by typing #/enrollment?enrollmentId=ikYMpSKXik1&orgUnitId=DiszpKrYNg8&programId=ur1Edk5Oe2n&teiId=Trc1H9T5C6f And there is an Active event in the TB visit stage When you click the Delete event overflow button on the Active event And you confirm you want to delete the event diff --git a/cypress/e2e/EnrollmentPage/StagesAndEventsWidget/StagesAndEventsWidget.js b/cypress/e2e/EnrollmentPage/StagesAndEventsWidget/StagesAndEventsWidget.js index 06c054a978..35d8996ee7 100644 --- a/cypress/e2e/EnrollmentPage/StagesAndEventsWidget/StagesAndEventsWidget.js +++ b/cypress/e2e/EnrollmentPage/StagesAndEventsWidget/StagesAndEventsWidget.js @@ -1,9 +1,9 @@ -import { Given, When, Then, defineStep as And, Before } from '@badeball/cypress-cucumber-preprocessor'; +import { Given, When, Then, defineStep as And, After } from '@badeball/cypress-cucumber-preprocessor'; import { getCurrentYear } from '../../../support/date'; import '../sharedSteps'; -Before({ tags: '@with-add-event-to-delete' }, () => { - cy.visit('#/enrollment?enrollmentId=hVPClvNrk9Z&orgUnitId=DiszpKrYNg8&programId=ur1Edk5Oe2n&teiId=WLecfORSpr0'); +After({ tags: '@with-restore-deleted-event' }, () => { + cy.visit('#/enrollment?enrollmentId=ikYMpSKXik1&orgUnitId=DiszpKrYNg8&programId=ur1Edk5Oe2n&teiId=Trc1H9T5C6f'); cy.get('[data-test="stages-and-events-widget"]') .find('[data-test="widget-contents"]')