-
Notifications
You must be signed in to change notification settings - Fork 22
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-13343] hidden program stage rule effect #3406
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f036d61
feat: hidden program stage
simonadomnisoru 0303463
fix: cypress tests
simonadomnisoru b649920
Merge branch 'master' into DHIS2-13343
simonadomnisoru 2999017
fix: add ConditionalTooltip when a rule hides the program stage
simonadomnisoru e48824d
chore: move cleanUp at the beginning of the test
simonadomnisoru a2d9456
chore: handle no events in the program stage during cypress cleanup
simonadomnisoru File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
65 changes: 65 additions & 0 deletions
65
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,65 @@ | ||
import moment from 'moment'; | ||
|
||
const cleanUp = () => { | ||
cy.visit( | ||
'/#/enrollment?enrollmentId=fmhIsWXVDmS&orgUnitId=s7SLtx8wmRA&programId=WSGAb5XwJ3Y&teiId=uW8Y7AIcRKA', | ||
); | ||
|
||
cy.get('[data-test="enrollment-page-content"]').contains('Enrollment Dashboard'); | ||
|
||
cy.get('[data-test="stages-and-events-widget"]') | ||
.find('[data-test="stage-content"]') | ||
.eq(3) | ||
.click(); | ||
|
||
cy.contains('WHOMCH Pregnancy outcome').should('exist'); | ||
cy.contains('[data-test="dhis2-uicore-button"]', 'Edit event').click(); | ||
cy.contains('[data-test="dhis2-uicore-button"]', 'Delete').click(); | ||
cy.contains('[data-test="dhis2-uicore-button"]', 'Yes, delete event').click(); | ||
}; | ||
|
||
Given('you add an enrollment event that will result in a rule effect to hide a program stage', () => { | ||
cleanUp(); | ||
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we run into trouble if there are no events in the program stage (which is initially the case?). Is it possible to do an early return if the program stage is empty?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great suggestion! I updated to code to handle the case of no events in the program stage. Thanks