-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [DHIS2-13343] hidden program stage rule effect (#3406)
- Loading branch information
1 parent
85a67db
commit 4ef2973
Showing
31 changed files
with
287 additions
and
48 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
cypress/integration/EnrollmentPage/HiddenProgramStage.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Feature: Hidden program stage | ||
|
||
Scenario: The user cannot add an event in a hidden program stage | ||
Given you add an enrollment event that will result in a rule effect to hide a program stage | ||
Then the New Postpartum care visit event button is disabled in the stages and events widget | ||
And and an error is show in the Postpartum care visit stage | ||
And the Postpartum care visit button is disabled in the enrollmentEventNew page |
66 changes: 66 additions & 0 deletions
66
cypress/integration/EnrollmentPage/HiddenProgramStage/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import moment from 'moment'; | ||
|
||
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', () => { | ||
cleanUpIfApplicable(); | ||
cy.visit( | ||
'/#/enrollmentEventNew?enrollmentId=fmhIsWXVDmS&orgUnitId=s7SLtx8wmRA&programId=WSGAb5XwJ3Y&stageId=PFDfvmGpsR3&teiId=uW8Y7AIcRKA', | ||
); | ||
|
||
cy.get('[data-test="capture-ui-input"]') | ||
.eq(0) | ||
.type(moment().format('YYYY-MM-DD')) | ||
.blur(); | ||
|
||
cy | ||
.get('[data-test="virtualized-select"]') | ||
.eq(6) | ||
.click() | ||
.contains('Termination of pregnancy') | ||
.click(); | ||
|
||
cy.contains('[data-test="dhis2-uicore-button"]', 'Save without completing').click(); | ||
}); | ||
|
||
Then('the New Postpartum care visit event button is disabled in the stages and events widget', () => { | ||
cy.contains('[data-test="create-new-button"]', 'New Postpartum care visit event') | ||
.should('be.disabled'); | ||
}); | ||
|
||
Then('and an error is show in the Postpartum care visit stage', () => { | ||
cy.visit( | ||
'/#/enrollmentEventNew?enrollmentId=fmhIsWXVDmS&orgUnitId=s7SLtx8wmRA&programId=WSGAb5XwJ3Y&teiId=uW8Y7AIcRKA&stageId=bbKtnxRZKEP', | ||
); | ||
cy.contains('[data-test="dhis2-uicore-button"]', 'Complete') | ||
.should('be.disabled'); | ||
cy.contains('[data-test="dhis2-uicore-button"]', 'Save without completing') | ||
.should('be.disabled'); | ||
cy.contains('[data-test="dhis2-uicore-noticebox-content"]', 'You can\'t add any more Postpartum care visit events') | ||
.should('exist'); | ||
}); | ||
|
||
Then('the Postpartum care visit button is disabled in the enrollmentEventNew page', () => { | ||
cy.visit( | ||
'/#/enrollmentEventNew?enrollmentId=fmhIsWXVDmS&orgUnitId=s7SLtx8wmRA&programId=WSGAb5XwJ3Y&teiId=uW8Y7AIcRKA', | ||
); | ||
|
||
cy.contains('[data-test="program-stage-selector-button"]', 'Postpartum care visit').should('be.disabled'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...les/capture-core/components/Pages/common/EnrollmentOverviewDomain/useRuleEffects/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// @flow | ||
export { useRuleEffects } from './useRuleEffects'; | ||
export type * from './useRuleEffects.types'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...modules/capture-core/components/WidgetEnrollmentEventNew/ErrorText/ErrorText.component.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// @flow | ||
import React from 'react'; | ||
import i18n from '@dhis2/d2-i18n'; | ||
import { NoticeBox } from '@dhis2/ui'; | ||
import type { Props } from './ErrorText.types'; | ||
|
||
export const ErrorText = ({ stageName }: Props) => ( | ||
<> | ||
<br /> | ||
<NoticeBox error> | ||
<span> | ||
{i18n.t("You can't add any more {{ programStageName }} events", { | ||
programStageName: stageName, | ||
interpolation: { escapeValue: false }, | ||
})} | ||
</span> | ||
</NoticeBox> | ||
<br /> | ||
</> | ||
); |
5 changes: 5 additions & 0 deletions
5
...ore_modules/capture-core/components/WidgetEnrollmentEventNew/ErrorText/ErrorText.types.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// @flow | ||
|
||
export type Props = {| | ||
stageName: string, | ||
|}; |
2 changes: 2 additions & 0 deletions
2
src/core_modules/capture-core/components/WidgetEnrollmentEventNew/ErrorText/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// @flow | ||
export { ErrorText } from './ErrorText.component'; |
Oops, something went wrong.