Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [DHIS2-18018][DHIS2-17853] show related stages widget in view event page #3916

Merged
merged 42 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
ba81d9c
feat: show related stages Widget on registration page
simonadomnisoru Nov 14, 2024
293c359
feat: add enableLinkExistingEvent prop
simonadomnisoru Nov 18, 2024
0bd5fa9
Merge branch 'master' into DHIS2-17192
simonadomnisoru Nov 18, 2024
d88b9c2
Merge branch 'master' into DHIS2-17192
simonadomnisoru Nov 20, 2024
ddb3f0e
chore: improve wording
simonadomnisoru Nov 27, 2024
3eb3c93
feat: show related stages widget when adding a new relationship
simonadomnisoru Dec 2, 2024
c1a1edb
Merge branch 'master' into DHIS2-17192
simonadomnisoru Dec 2, 2024
32c824f
Merge branch 'master' into DHIS2-17192
simonadomnisoru Dec 5, 2024
9b2d205
Merge branch 'master' into DHIS2-17192
simonadomnisoru Dec 9, 2024
2a27f57
chore: typo
simonadomnisoru Dec 9, 2024
9ecf999
chore: fix PR comments
simonadomnisoru Dec 11, 2024
28e26b8
chore: correct the variable name to match its format
simonadomnisoru Dec 17, 2024
d137e8e
chore: move helpers files to DataEntries/EnrollmentRegistrationEntry
simonadomnisoru Dec 17, 2024
0dc2f01
chore: use action naming throughout the code
simonadomnisoru Dec 17, 2024
6b97817
chore: rename helper file to getRelationshipNewTeiName
simonadomnisoru Dec 17, 2024
d643dd6
Merge branch 'master' into DHIS2-17192
simonadomnisoru Dec 17, 2024
743bcbf
feat: simplify how we determine what event to redirect to
simonadomnisoru Dec 18, 2024
1e9b3f9
feat: show related stages widget in view event page
simonadomnisoru Dec 19, 2024
c619511
feat: show related stages widget in view event page
simonadomnisoru Jan 6, 2025
8366d23
Merge branch 'master' into DHIS2-17192
simonadomnisoru Jan 7, 2025
f8bcf40
Merge branch 'DHIS2-17192' into DHIS2-18018
simonadomnisoru Jan 7, 2025
e4a16ca
fix: simplify how we determine what event to redirect to
simonadomnisoru Jan 13, 2025
55aa99f
Merge branch 'DHIS2-17192' into DHIS2-18018
simonadomnisoru Jan 14, 2025
9d9879b
fix: remove breaking tests
eirikhaugstulen Jan 16, 2025
e1b9836
Revert "fix: remove breaking tests"
eirikhaugstulen Jan 16, 2025
6eed7c5
Merge branch 'master' into DHIS2-17192
simonadomnisoru Jan 21, 2025
38811ca
Merge branch 'DHIS2-17192' into DHIS2-18018
simonadomnisoru Jan 21, 2025
88d021e
chore: imporve Link button UI
simonadomnisoru Jan 23, 2025
91c1893
chore: fix 409 error for enrolledAt date in the future
simonadomnisoru Jan 23, 2025
3e9f419
Merge branch 'master' into DHIS2-18018
simonadomnisoru Jan 27, 2025
874ed03
test: [DHIS2-17853] Related stages Cypress tests (#3939)
simonadomnisoru Jan 27, 2025
497820d
fix: add success link messageand skipBidirectionalChecks if required
simonadomnisoru Jan 29, 2025
c751be5
fix: update enrollmentDomain value in Redux and fix the 409 error
simonadomnisoru Feb 6, 2025
f1b0917
fix: add loading logic to the Link action button
simonadomnisoru Feb 6, 2025
118498d
Merge branch 'master' into DHIS2-18018
simonadomnisoru Feb 6, 2025
0dc7399
Merge branch 'master' into DHIS2-18018
simonadomnisoru Feb 6, 2025
177a849
fix: loading spinner spins indefinitely
simonadomnisoru Feb 7, 2025
53c507c
chore: typos
simonadomnisoru Feb 10, 2025
4ac9469
Merge branch 'master' into DHIS2-18018
simonadomnisoru Feb 10, 2025
0b17150
fix: empty tooltip
simonadomnisoru Feb 10, 2025
77951a1
fix: update tooltip text
simonadomnisoru Feb 10, 2025
153c5a6
fix: update tooltip text
simonadomnisoru Feb 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 100 additions & 0 deletions cypress/e2e/RelatedStages/RelatedStages.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
Feature: Related stages

Scenario: Edit event -> User is able to link and unlink an existing event
Given you land on a enrollment page domain by having typed #/enrollmentEventEdit?eventId=TwoGi1mUFFw&orgUnitId=lyONqUkY1Bq
And the Related stages Actions is visible at the bottom of the page
And the schedule and enter details actions are disabled
And you select the Link to an existing event action
When you select the first existing Baby Postnatal event in the list
And you click the Link button
Then you can see the Baby Postnatal linked event
And the Related stages Actions is not visible at the bottom of the page
When you unlink the Baby Postnatal linked event
And the Related stages Actions is visible at the bottom of the page

Scenario: Edit event -> User is able to schedule an event in a different orgUnit
Given you land on a enrollment page domain by having typed #/enrollment?enrollmentId=VOU2Qe7T49r&orgUnitId=VFF7f43dJv4&programId=IpHINAT79UW&teiId=rBqwRgXvjk0
And you delete the events of the enrollmentId VOU2Qe7T49r
And you open the Birth new event page and fill in the required data in the form
And you click the Complete button
And you open the Birth event edit page
And the Related stages Actions is visible at the bottom of the page
And the link to an existing actions is disabled
And you select the Schedule event action
When you fill in the required values for the Baby postnatal event when scheduling
And you click the Schedule action button
Then you can see the Baby Postnatal linked event
And the Related stages Actions is not visible at the bottom of the page

Scenario: Edit event -> User is able to enter details in a different orgUnit
Given you land on a enrollment page domain by having typed #/enrollment?enrollmentId=VOU2Qe7T49r&orgUnitId=VFF7f43dJv4&programId=IpHINAT79UW&teiId=rBqwRgXvjk0
And you delete the events of the enrollmentId VOU2Qe7T49r
And you open the Birth new event page and fill in the required data in the form
And you click the Complete button
And you open the Birth event edit page
And the Related stages Actions is visible at the bottom of the page
And the link to an existing actions is disabled
And you select the Enter details now action
When you fill in the required values for the Baby postnatal event when entering details
And you click the Enter details action button
Then you can see the Birth linked event
And you can see the Baby postnatal new event form where you can enter details

Scenario: New event -> User is able to link and unlink an existing event
Given you land on a enrollment page domain by having typed #/enrollment?enrollmentId=EOxeNf2MdBf&orgUnitId=VFF7f43dJv4&programId=IpHINAT79UW&teiId=QhoMgzeGuGq
And you delete the Birth event
And you open the Birth new event page and fill in the required data in the form
And the Related stages Actions is visible at the bottom of the page
And the schedule and enter details actions are disabled
And you select the Link to an existing event action
When you select the first existing Baby Postnatal event in the list
And you click the Complete button
And you open the Birth event edit page
Then you can see the Baby Postnatal linked event
And the Related stages Actions is not visible at the bottom of the page
When you unlink the Baby Postnatal linked event
And the Related stages Actions is visible at the bottom of the page

Scenario: New event -> User is able to schedule an event in a different orgUnit
Given you land on a enrollment page domain by having typed #/enrollment?enrollmentId=EOxeNf2MdBf&orgUnitId=VFF7f43dJv4&programId=IpHINAT79UW&teiId=QhoMgzeGuGq
And you delete the events of the enrollmentId EOxeNf2MdBf
And you open the Birth new event page and fill in the required data in the form
And the Related stages Actions is visible at the bottom of the page
And the link to an existing actions is disabled
And you select the Schedule event action
When you fill in the required values for the Baby postnatal event when scheduling
And you click the Complete button
Then you are redirect to the enrollment dasboard and you see the 2 linked events in different orgUnits

Scenario: New event -> User is able to enter details in a different orgUnit
Given you land on a enrollment page domain by having typed #/enrollment?enrollmentId=YRgcBLZbsb6&orgUnitId=VFF7f43dJv4&programId=IpHINAT79UW&teiId=zFbWLBo4jta
And you delete the events of the enrollmentId YRgcBLZbsb6
And you open the Birth new event page and fill in the required data in the form
And the Related stages Actions is visible at the bottom of the page
And the link to an existing actions is disabled
And you select the Enter details now action
When you fill in the required values for the Baby postnatal event when entering details
And you click the Complete button
Then you can see the Birth linked event
And you can see the Baby postnatal new event form where you can enter details

Scenario: Enroll trackedEntity -> User is able to schedule an event in a different orgUnit
Given you are in Child programme and Tombo Wallah CHP organization unit registration page
When you fill the Child Program program registration form with unique values
And you select the Schedule event action
And you fill in the required values for the Baby postnatal event when scheduling
And you click the save person submit button
Then you are redirect to the enrollment dasboard and you see the 2 linked events in different orgUnits
And you delete the recently added tracked entity

Scenario: Enroll trackedEntity -> User is able to enter details in a different orgUnit
Given you are in Child programme and Tombo Wallah CHP organization unit registration page
When you fill the Child Program program registration form with unique values
And you select the Enter details now action
And you fill in the required values for the Baby postnatal event when entering details
And you click the save person submit button
Then you can see the Birth linked event
And you can see the Baby postnatal new event form where you can enter details
And you navigate to the Enrollment dashboard
And you are redirect to the enrollment dasboard and you see the 2 linked events in different orgUnits
And you delete the recently added tracked entity
258 changes: 258 additions & 0 deletions cypress/e2e/RelatedStages/RelatedStages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,258 @@
import { Given, Then, When, defineStep as And } from '@badeball/cypress-cucumber-preprocessor';
import { getCurrentYear } from '../../support/date';

Given(/^you land on a enrollment page domain by having typed (.*)$/, (url) => {
cy.visit(url);
cy.get('[data-test="person-selector-container"]').contains('Person');
});

And(/^the Related stages Actions is ?(.*) visible at the bottom of the page/, (not) => {
cy.get('[data-test="related-stages-section"]')
.should(not ? 'not.exist' : 'exist');
});

And('you select the Link to an existing event action', () => {
cy.get('[data-test="related-stages-section"]')
.and('contain', 'Actions - Birth to Baby postnatal');
cy.get('[data-test="related-stages-actions-link-existing-response"]')
.click();
});

And('you select the Schedule event action', () => {
cy.get('[data-test="related-stages-section"]')
.and('contain', 'Actions - Birth to Baby postnatal');
cy.get('[data-test="related-stages-actions-schedule"]')
.click();
});

And('you select the Enter details now action', () => {
cy.get('[data-test="related-stages-section"]')
.and('contain', 'Actions - Birth to Baby postnatal');
cy.get('[data-test="related-stages-actions-enter-details"]')
.click();
});

When('you select the first existing Baby Postnatal event in the list', () => {
cy.get('[data-test="related-stages-existing-response-list-content"]')
.click();
cy.get('[data-test="dhis2-uicore-singleselectoption"]')
.eq(0)
.click();
});

When('you click the Link button', () => {
cy.get('[data-test="related-stages-buttons-link-existing-response"]')
.click();
});

Then('you can see the Baby Postnatal linked event', () => {
cy.get('[data-test="enrollment-viewEvent-page"]')
.should('contain', 'This Birth event is linked to a Baby Postnatal event. Review the linked event details before entering data below');
});

Then('you can see the Birth linked event', () => {
cy.get('[data-test="enrollment-editEvent-page"]')
.should('contain', 'This Baby Postnatal event is linked to a Birth event. Review the linked event details before entering data below');
});

When('you unlink the Baby Postnatal linked event', () => {
cy.get('[data-test="widget-linked-event-overflow-menu"]')
.click();
cy.get('[data-test="event-overflow-unlink-event"]')
.click();
cy.get('[data-test="event-overflow-unlink-event-confirm"]')
.click();
});

And('you delete the Birth event', () => {
cy.get('[data-test="overflow-button"]')
.eq(0)
.click();
cy.get('[data-test="stages-and-events-delete"]')
.click();
cy.get('[data-test="dhis2-uicore-modal"]').within(() => {
cy.contains('button', 'Yes, delete event')
.click();
});
});

And('you open the Birth event edit page', () => {
cy.get('[data-test="stages-and-events-widget"]')
.find('[data-test="widget-contents"]')
.contains('[data-test="stage-content"]', 'Birth')
.find('[data-test="dhis2-uicore-datatablerow"]')
.eq(1)
.click();
});

And('you open the Birth new event page and fill in the required data in the form', () => {
cy.get('[data-test="stages-and-events-widget"]')
.find('[data-test="widget-contents"]')
.contains('[data-test="stage-content"]', 'Birth')
.find('[data-test="create-new-button"]')
.click();

cy.get('[data-test="dataentry-field-occurredAt"]')
.within(() => {
cy.get('input[type="text"]')
.eq(0)
.type(`${getCurrentYear()}-07-01`)
.blur();
});
});

When('you fill in the required values for the Baby postnatal event when scheduling', () => {
cy.get('[data-test="related-stages-section"]')
.within(() => {
cy.get('input[type="text"]')
.eq(0)
.type(`${getCurrentYear()}-08-01`)
.blur();

cy.get('input[type="text"]')
.eq(1)
.type('Barmoi CH');

cy.contains('Barmoi CHP')
.click();
});
});

And('you click the Schedule action button', () => {
cy.get('[data-test="related-stages-buttons-schedule"]')
.click();
});

When('you fill in the required values for the Baby postnatal event when entering details', () => {
cy.get('[data-test="related-stages-section"]')
.within(() => {
cy.get('input[type="text"]')
.eq(0)
.type('Barmoi CH');

cy.contains('Barmoi CHP')
.click();
});
});

And('you click the Enter details action button', () => {
cy.get('[data-test="related-stages-buttons-enter-details"]')
.click();
});

Then('you can see the Baby postnatal new event form where you can enter details', () => {
cy.get('[data-test="edit-event-report-tab"]')
.should('contain', 'Report');
cy.get('[data-test="edit-event-schedule-tab"]')
.should('contain', 'Schedule');
cy.get('[data-test="dhis2-uicore-button"]')
.contains('Cancel')
.should('exist');
});

And('the schedule and enter details actions are disabled', () => {
cy.get('input[name="related-stage-action-SCHEDULE_IN_ORG"]')
.should('be.disabled');
cy.get('input[name="related-stage-action-ENTER_DATA"]')
.should('be.disabled');
});

And('the link to an existing actions is disabled', () => {
cy.get('input[name="related-stage-action-LINK_EXISTING_RESPONSE"]')
.should('be.disabled');
});

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

Then('you are redirect to the enrollment dasboard and you see the 2 linked events in different orgUnits', () => {
cy.get('[data-test="stages-and-events-widget"]')
.find('[data-test="widget-contents"]')
.contains('[data-test="stage-content"]', 'Birth')
.find('[data-test="dhis2-uicore-datatablerow"]')
.eq(1)
.contains('Tombo Wallah CHP');

cy.get('[data-test="stages-and-events-widget"]')
.find('[data-test="widget-contents"]')
.contains('[data-test="stage-content"]', 'Baby Postnatal')
.find('[data-test="dhis2-uicore-datatablerow"]')
.eq(1)
.contains('Barmoi CHP');
});

And('you fill the Child Program program registration form with unique values', () => {
cy.get('input[type="text"]')
.eq(1)
.type('2021-01-01')
.blur();
cy.get('input[type="text"]')
.eq(2)
.type(20);
cy.get('input[type="text"]')
.eq(3)
.type(30)
.blur();
cy.get('input[type="text"]')
.eq(4)
.type(`Sarah-${Math.round((new Date()).getTime() / 1000)}`)
.blur();
cy.get('input[type="text"]')
.eq(5)
.type(`Beth-${Math.round((new Date()).getTime() / 1000)}`)
.blur();
cy.get('input[type="text"]')
.eq(7)
.type('2021-01-01')
.blur();
});

And('you delete the recently added tracked entity', () => {
cy.get('[data-test="profile-widget"]')
.contains('Person profile')
.should('exist');
cy.get('[data-test="widget-profile-overflow-menu"]')
.click();
cy.contains('Delete Person')
.click();
cy.get('[data-test="widget-profile-delete-modal"]').within(() => {
cy.contains('Yes, delete Person')
.click();
});
cy.url().should('include', 'selectedTemplateId=IpHINAT79UW');
});

And(/^you click the save (.*) submit button$/, (TEType) => {
cy.contains(`Save ${TEType}`)
.click();
});

And('you navigate to the Enrollment dashboard', () => {
cy.contains('Enrollment dashboard')
.click();
cy.contains('Yes, discard changes')
.click();
});

And('you are in Child programme and Tombo Wallah CHP organization unit registration page', () => {
cy.visit('/#/new?programId=IpHINAT79UW&orgUnitId=VFF7f43dJv4');
});

And(/^you delete the events of the enrollmentId (.*)$/, (enrollmentId) => {
cy.buildApiUrl('tracker', `enrollments/${enrollmentId}?fields=events[event]`)
.then(url => cy.request(url))
.then(({ body }) => {
const { events } = body;

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

15 changes: 12 additions & 3 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -1437,12 +1437,24 @@ msgstr "Actions - {{relationshipName}}"
msgid "Ambiguous relationships, contact system administrator"
msgstr "Ambiguous relationships, contact system administrator"

msgid "Enter details"
msgstr "Enter details"

msgid "Linked event"
msgstr "Linked event"

msgid "Enter details now"
msgstr "Enter details now"

msgid "Link to an existing event"
msgstr "Link to an existing event"

msgid "The event was succesfully linked"
msgstr "The event was succesfully linked"

msgid "An error occurred while linking the event"
msgstr "An error occurred while linking the event"

msgid "Scheduled date"
msgstr "Scheduled date"

Expand Down Expand Up @@ -1550,9 +1562,6 @@ msgstr "You do not have access to remove the link and delete the linked event"
msgid "An error occurred while loading the widget."
msgstr "An error occurred while loading the widget."

msgid "Linked event"
msgstr "Linked event"

msgid ""
"This {{stageName}} event is linked to a {{linkedStageName}} event. Review "
"the linked event details before entering data below"
Expand Down
Loading
Loading