-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [DHIS2-10941] Enrollment widget
* feat: [DHIS2-10941] enrollment widget * feat: [DHIS2-10941] enrollment widget
- Loading branch information
1 parent
0077366
commit 67b34d0
Showing
8 changed files
with
82 additions
and
5 deletions.
There are no files selected for viewing
6 changes: 2 additions & 4 deletions
6
cypress/integration/EnrollmentPage/StagesAndEventsWidget/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
12 changes: 12 additions & 0 deletions
12
cypress/integration/EnrollmentPage/WidgetEnrollment.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,12 @@ | ||
Feature: User interacts with Enrollment Widget | ||
|
||
Scenario: User can close the Enrollment Widget | ||
Given you open the enrollment page | ||
When you click the enrollment widget toggle open close button | ||
Then the enrollment widget should be closed | ||
|
||
Scenario: User can close and reopen the Enrollment Widget | ||
Given you open the enrollment page | ||
When you click the enrollment widget toggle open close button | ||
And you click the enrollment widget toggle open close button | ||
Then the enrollment details should be displayed |
30 changes: 30 additions & 0 deletions
30
cypress/integration/EnrollmentPage/WidgetEnrollment/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,30 @@ | ||
import '../sharedSteps'; | ||
|
||
beforeEach(() => { | ||
cy.loginThroughForm(); | ||
}); | ||
|
||
Then('the enrollment details should be displayed', () => { | ||
cy.get('[data-test="enrollment-widget"]') | ||
.within(() => { | ||
cy.contains('placeholder content enrollment').should('exist'); | ||
}); | ||
}); | ||
|
||
When('you click the enrollment widget toggle open close button', () => { | ||
cy.get('[data-test="enrollment-widget"]') | ||
.within(() => { | ||
cy.get('[data-test="widget-open-close-toggle-button"]') | ||
.click(); | ||
}); | ||
}); | ||
|
||
Then('the enrollment widget should be closed', () => { | ||
cy.get('[data-test="enrollment-widget"]') | ||
.within(() => { | ||
cy.get('[data-test="widget-contents"]') | ||
.children() | ||
.should('not.exist'); | ||
cy.contains('placeholder content enrollment').should('not.exist'); | ||
}); | ||
}); |
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 @@ | ||
Given('you open the enrollment page', () => { | ||
cy.visit('#/enrollment?enrollmentId=wBU0RAsYjKE'); | ||
}); |
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
25 changes: 25 additions & 0 deletions
25
src/core_modules/capture-core/components/WidgetEnrollment/WidgetEnrollment.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,25 @@ | ||
// @flow | ||
import React, { useState, useCallback } from 'react'; | ||
import i18n from '@dhis2/d2-i18n'; | ||
import { Widget } from '../Widget'; | ||
import type { Props } from './enrollment.types'; | ||
|
||
export const WidgetEnrollment = ({ className }: Props) => { | ||
const [open, setOpenStatus] = useState(true); | ||
|
||
return ( | ||
<div | ||
data-test="enrollment-widget" | ||
className={className} | ||
> | ||
<Widget | ||
header={i18n.t('Enrollment')} | ||
onOpen={useCallback(() => setOpenStatus(true), [setOpenStatus])} | ||
onClose={useCallback(() => setOpenStatus(false), [setOpenStatus])} | ||
open={open} | ||
> | ||
[placeholder content enrollment] | ||
</Widget> | ||
</div> | ||
); | ||
}; |
5 changes: 5 additions & 0 deletions
5
src/core_modules/capture-core/components/WidgetEnrollment/enrollment.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 = {| | ||
className?: string, | ||
|}; |
2 changes: 2 additions & 0 deletions
2
src/core_modules/capture-core/components/WidgetEnrollment/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 { WidgetEnrollment } from './WidgetEnrollment.component'; |