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-13800] ask user to complete enrollment and events #3535

Merged
merged 13 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,12 @@ Feature: User interacts with the Enrollment New Event Workspace
And you select the schedule tab
When you add a comment to the event
And the events saves successfully

Scenario: User can add a new event and complete the enrollment
Given you land on the enrollment new event page by having typed #/enrollmentEventNew?enrollmentId=FZAa7j0muDj&orgUnitId=DiszpKrYNg8&programId=qDkgAbB5Jlk&stageId=eHvTba5ijAh&teiId=bj4UmUpqaSp
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 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 @@ -157,3 +157,72 @@ Then('the user clicks the first second antenatal care visit event', () => {
cy.contains('[data-test="stage-content"]', 'Last updated a few seconds ago')
.should('exist');
});

And('the enrollment status is active', () => {
cy.buildApiUrl(
'tracker',
'trackedEntities/bj4UmUpqaSp?program=qDkgAbB5Jlk&fields=enrollments[enrollment,events,orgUnit,program,enrolledAt,trackedEntity]',
)
.then(url => cy.request(url))
.then(({ body }) => {
const enrollment = body.enrollments && body.enrollments.find(e => e.enrollment === 'FZAa7j0muDj');
const eventToDelete = enrollment.events.find(e => e.programStage === 'eHvTba5ijAh');
const { events, ...rest } = enrollment;
const enrollmentToUpdate = { ...rest, status: 'ACTIVE' };

return cy
.buildApiUrl('tracker?async=false&importStrategy=UPDATE')
.then(enrollmentUrl => cy.request('POST', enrollmentUrl, { enrollments: [enrollmentToUpdate] }))
.then(() => {
if (eventToDelete) {
cy.buildApiUrl('events', eventToDelete.event)
.then((eventUrl) => {
cy.request('DELETE', eventUrl);
}).then(() => {
cy.reload();
cy.get('[data-test="widget-enrollment"]').within(() => {
cy.get('[data-test="widget-enrollment-status"]').contains('Active').should('exist');
});
});
} else {
cy.reload();
cy.get('[data-test="widget-enrollment"]').within(() => {
cy.get('[data-test="widget-enrollment-status"]').contains('Active').should('exist');
});
}
});
});
});

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

When('the user completes the enrollment', () => {
cy.get('[data-test="enrollment-complete-modal"]').within(() => {
cy.contains('Case outcome completed').should('exist');
cy.contains('Would you like to complete the enrollment and all active events as well?').should('exist');
cy.contains('The following events will be completed:').should('exist');
cy.contains('1 event in Case investigation & classification').should('exist');
cy.contains('1 event in Diagnosis & treatment').should('exist');
cy.contains('No, cancel').should('exist');
cy.contains('Complete enrollment only').should('exist');
cy.contains('Yes, complete enrollment and events').should('exist');
});
cy.get('[data-test="enrollment-actions-complete-button"]').click();
});

Then('the user sees the enrollment status and recently added event in Case outcome event status is completed', () => {
cy.url().should('include', `${Cypress.config().baseUrl}/#/enrollment?`);
cy.get('[data-test="widget-enrollment"]').within(() => {
cy.get('[data-test="widget-enrollment-status"]').contains('Completed').should('exist');
});

cy.get('[data-test="stage-content"]')
.eq(2)
.within(() => {
cy.get('[data-test="dhis2-uicore-tag-text"]').contains('Completed').should('exist');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,11 @@ Scenario: User can see disabled scheduled date for active event
When the user clicks on the edit button
Then the user see the following text: Enrollment: Edit Event
Then the user see the schedule date field with tooltip: Scheduled date cannot be changed for Active events


Scenario: User can edit the event and complete the enrollment
Given you land on the enrollment event page with selected Malaria Entity by having typed #/enrollmentEventEdit?eventId=MHR4Zj6KLz0&orgUnitId=DiszpKrYNg8
And the enrollment status is active
And the user clicks on the edit button
And the user completes the event
And the user completes the enrollment
Then the user sees the enrollment status and recently edited event in Case outcome event status is completed
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor';
import { Given, When, Then, defineStep as And } from '@badeball/cypress-cucumber-preprocessor';
import { getCurrentYear } from '../../../support/date';
import '../../sharedSteps';

Expand Down Expand Up @@ -95,3 +95,71 @@ Then(/^the user see the schedule date field with tooltip: (.*)$/, (tooltipConten
cy.get('[data-test="dhis2-uicore-tooltip-reference"]').eq(0).trigger('mouseover');
cy.get('[data-test="dhis2-uicore-tooltip-content"]').contains(tooltipContent).should('exist');
});

And('the enrollment status is active', () => {
cy.buildApiUrl(
'tracker',
'trackedEntities/JM29jwvw8Ub?program=qDkgAbB5Jlk&fields=enrollments[enrollment,events,orgUnit,program,enrolledAt,trackedEntity]',
)
.then(url => cy.request(url))
.then(({ body }) => {
const enrollment = body.enrollments && body.enrollments.find(e => e.enrollment === 'C4iB0VTbfrK');
const eventToUpdate = enrollment.events.find((e => e.programStage === 'eHvTba5ijAh'));
const enrollmentToUpdate = {
...enrollment,
status: 'ACTIVE',
events: [{ ...eventToUpdate, status: 'ACTIVE' }],
};

return cy
.buildApiUrl('tracker?async=false&importStrategy=UPDATE')
.then(enrollmentUrl => cy.request('POST', enrollmentUrl, { enrollments: [enrollmentToUpdate] }))
.then(() => {
cy.reload();
cy.get('[data-test="widget-enrollment"]').within(() => {
cy.get('[data-test="widget-enrollment-status"]').contains('Active').should('exist');
});
});
});
});

And('the user completes the event', () => {
cy.get('[data-test="dataentry-field-complete"]')
.find('input')
.click()
.blur();

cy
.get('[data-test="widget-enrollment-event"]')
.find('[data-test="dhis2-uicore-button"]')
.contains('Save')
.click();
});

When('the user completes the enrollment', () => {
cy.get('[data-test="enrollment-complete-modal"]').within(() => {
cy.contains('Case outcome completed').should('exist');
cy.contains('Would you like to complete the enrollment and all active events as well?').should('exist');
cy.contains('The following events will be completed:').should('exist');
cy.contains('1 event in Case outcome').should('exist');
cy.contains('1 event in Diagnosis & treatment').should('exist');
cy.contains('No, cancel').should('exist');
cy.contains('Complete enrollment only').should('exist');
cy.contains('Yes, complete enrollment and events').should('exist');
});
cy.get('[data-test="enrollment-actions-complete-button"]').click();
});

Then('the user sees the enrollment status and recently edited event in Case outcome event status is completed', () => {
cy.url().should('include', `${Cypress.config().baseUrl}/#/enrollment?`);
cy.get('[data-test="widget-enrollment"]').within(() => {
cy.get('[data-test="widget-enrollment-status"]').contains('Completed').should('exist');
});

cy.get('[data-test="stage-content"]')
.eq(2)
.within(() => {
cy.get('[data-test="dhis2-uicore-tag-text"]').contains('Completed').should('exist');
});
});

50 changes: 50 additions & 0 deletions cypress/e2e/WidgetsForEnrollmentPages/WidgetEnrollment/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,53 @@ Then(/^the user sees the delete enrollment modal/, () =>
cy.contains('Yes, delete enrollment').should('exist');
}),
);

Then('the user sees the enrollment status and the Baby Postnatal event status is active', () => {
cy.buildApiUrl('tracker', 'trackedEntities/osF4RF4EiqP?program=IpHINAT79UW&fields=enrollments')
.then(url => cy.request(url))
.then(({ body }) => {
const enrollment = body.enrollments && body.enrollments.find(e => e.enrollment === 'qyx7tscVpVB');
const eventsToUpdate = enrollment.events.reduce(
(acc, e) => [...acc, e.programStage === 'ZzYYXq4fJie' ? { ...e, status: 'ACTIVE' } : e],
[],
);
const enrollmentToUpdate = { ...enrollment, status: 'ACTIVE', events: eventsToUpdate };

return cy
.buildApiUrl('tracker?async=false&importStrategy=UPDATE')
.then(enrollmentUrl => cy.request('POST', enrollmentUrl, { enrollments: [enrollmentToUpdate] }))
.then(() => {
cy.reload();
cy.get('[data-test="widget-enrollment"]').within(() => {
cy.get('[data-test="widget-enrollment-status"]').contains('Active').should('exist');
});
});
});
});

Then('the user sees the enrollment status and the Baby Postnatal event status is completed', () => {
cy.url().should('include', `${Cypress.config().baseUrl}/#/enrollment?`);
cy.get('[data-test="widget-enrollment"]').within(() => {
cy.get('[data-test="widget-enrollment-status"]').contains('Completed').should('exist');
});

cy.get('[data-test="stage-content"]')
.eq(1)
.within(() => {
cy.get('[data-test="dhis2-uicore-tag-text"]').contains('Completed').should('exist');
});
});

When('the user completes the enrollment and the active events', () => {
cy.get('[data-test="widget-enrollment-actions-complete"]').click();

cy.get('[data-test="widget-enrollment-complete-modal"]').within(() => {
cy.contains('Would you like to complete the enrollment and all active events as well?').should('exist');
cy.contains('The following events will be completed:').should('exist');
cy.contains('1 event in Baby Postnatal').should('exist');
cy.contains('No, cancel').should('exist');
cy.contains('Complete enrollment only').should('exist');
cy.contains('Yes, complete enrollment and events').should('exist');
});
cy.get('[data-test="widget-enrollment-actions-complete-button"]').click();
});
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,11 @@ Feature: The user interacts with the widgets on the enrollment add event page
Given you land on the enrollment edit event page by having typed /#/enrollmentEventNew?enrollmentId=zRfAPUpjoG3&orgUnitId=DiszpKrYNg8&programId=M3xtLkYBlKI&stageId=uvMKOn1oWvd&teiId=S3JjTA4QMNe
When you click switch tab to Schedule
Then you can assign a user when scheduling the event

Scenario: User can complete the enrollment and the active events
Given you land on the enrollment edit event page by having typed #/enrollmentEventNew?enrollmentId=qyx7tscVpVB&orgUnitId=DiszpKrYNg8&programId=IpHINAT79UW&teiId=osF4RF4EiqP
And the enrollment widget should be opened
And the user sees the enrollment status and the Baby Postnatal event status is active
And the user opens the enrollment actions menu
When the user completes the enrollment and the active events
Then the user sees the enrollment status and the Baby Postnatal event status is completed
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,12 @@ Feature: The user interacts with the widgets on the enrollment dashboard

Scenario: The program rules are triggered and the effects are displayed in the sidebar widgets
Given you land on the enrollment dashboard page by having typed #/enrollment?enrollmentId=wBU0RAsYjKE
Then the user can see the program rules effect in the indicator widget
Then the user can see the program rules effect in the indicator widget

Scenario: User can complete the enrollment and the active events
Given you land on the enrollment dashboard page by having typed #/enrollment?enrollmentId=qyx7tscVpVB
And the enrollment widget should be opened
And the user sees the enrollment status and the Baby Postnatal event status is active
And the user opens the enrollment actions menu
When the user completes the enrollment and the active events
Then the user sees the enrollment status and the Baby Postnatal event status is completed
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,11 @@ Feature: The user interacts with the widgets on the enrollment edit event
Then the event has the user Tracker demo User assigned
When you remove the assigned user
Then the event has no assignd user

Scenario: User can complete the enrollment and the active events
Given you land on the enrollment edit event page by having typed #/enrollmentEventEdit?eventId=OWpIzQ4xabC&orgUnitId=DiszpKrYNg8
And the enrollment widget should be opened
And the user sees the enrollment status and the Baby Postnatal event status is active
And the user opens the enrollment actions menu
When the user completes the enrollment and the active events
Then the user sees the enrollment status and the Baby Postnatal event status is completed
38 changes: 38 additions & 0 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,29 @@ msgstr "Indicators"
msgid "Warnings"
msgstr "Warnings"

msgid "{{programStageName}} completed"
msgstr "{{programStageName}} completed"

msgid "Would you like to complete the enrollment and all active events as well?"
msgstr "Would you like to complete the enrollment and all active events as well?"

msgid "{{count}} event in {{programStageName}}"
msgid_plural "{{count}} event in {{programStageName}}"
msgstr[0] "{{count}} event in {{programStageName}}"
msgstr[1] "{{count}} events in {{programStageName}}"

msgid "Yes, complete enrollment and events"
msgstr "Yes, complete enrollment and events"

msgid "Complete enrollment only"
msgstr "Complete enrollment only"

msgid "Would you like to complete the enrollment?"
msgstr "Would you like to complete the enrollment?"

msgid "Complete enrollment"
msgstr "Complete enrollment"

msgid "Generate new event"
msgstr "Generate new event"

Expand Down Expand Up @@ -932,6 +955,11 @@ msgstr "Search {{uniqueAttrName}}"
msgid "Search by attributes"
msgstr "Search by attributes"

msgid "Fill in at least {{count}} attribute to search"
msgid_plural "Fill in at least {{count}} attribute to search"
msgstr[0] "Fill in at least {{count}} attribute to search"
msgstr[1] "Fill in at least {{count}} attributes to search"

msgid "Could not retrieve metadata. Please try again later."
msgstr "Could not retrieve metadata. Please try again later."

Expand Down Expand Up @@ -1281,12 +1309,22 @@ msgstr "Scheduled automatically for {{suggestedScheduleDate}}"
msgid "The scheduled date matches the suggested date, but can be changed if needed."
msgstr "The scheduled date matches the suggested date, but can be changed if needed."

msgid "The scheduled date is {{count}} days {{position}} the suggested date."
msgid_plural "The scheduled date is {{count}} days {{position}} the suggested date."
msgstr[0] "The scheduled date is {{count}} day {{position}} the suggested date."
msgstr[1] "The scheduled date is {{count}} days {{position}} the suggested date."

msgid "after"
msgstr "after"

msgid "before"
msgstr "before"

msgid "There are {{count}} scheduled event in {{orgUnitName}} on this day."
msgid_plural "There are {{count}} scheduled event in {{orgUnitName}} on this day."
msgstr[0] "There are {{count}} scheduled event in {{orgUnitName}} on this day."
msgstr[1] "There are {{count}} scheduled events in {{orgUnitName}} on this day."

msgid "Scheduling an event in {{stageName}} for {{programName}} in {{orgUnitName}}"
msgstr "Scheduling an event in {{stageName}} for {{programName}} in {{orgUnitName}}"

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@
"@babel/preset-react": "7.16.7",
"@dhis2/ui": "^9.1.1",
"@js-temporal/polyfill": "0.4.3",
"core-js": "2.5.7"
"core-js": "2.5.7",
"i18next": "^20.5.0"
},
"browserslist": {
"production": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export { withErrorOutput } from './dataEntryOutput/withErrorOutput';
export { withIndicatorOutput } from './dataEntryOutput/withIndicatorOutput';
export { withCleanUp } from './withCleanUp';
export { withAskToCreateNew } from './withAskToCreateNew';
export { withAskToCompleteEnrollment } from './withAskToCompleteEnrollment';

// misc
export { inMemoryFileStore } from './file/inMemoryFileStore';
Expand Down
Loading
Loading