-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #371 from openedx/kiram15/ENT-7959
Add Budget Distribution Selection in View and Edit modes
- Loading branch information
Showing
10 changed files
with
109 additions
and
12 deletions.
There are no files selected for viewing
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
33 changes: 33 additions & 0 deletions
33
...onfiguration/Provisioning/SubsidyDetailView/PolicyDetailView/PolicyDistributionDetail.jsx
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,33 @@ | ||
import PropTypes from 'prop-types'; | ||
import PROVISIONING_PAGE_TEXT from '../../data/constants'; | ||
import ProvisioningFormHelpText from '../../ProvisioningForm/ProvisioningFormHelpText'; | ||
|
||
const PolicyDistributionDetail = ({ policyType }) => { | ||
const { FORM: { POLICY_TYPE } } = PROVISIONING_PAGE_TEXT; | ||
|
||
return ( | ||
<div className="mb-1 mt-3"> | ||
<h3>{POLICY_TYPE.TITLE}</h3> | ||
<div className="ml-3"> | ||
<p className="mb-1 mt-3">{POLICY_TYPE.LABEL}</p> | ||
<p className="text-gray"> | ||
{(policyType === POLICY_TYPE.OPTIONS.ADMIN_SELECTS.VALUE) | ||
&& POLICY_TYPE.OPTIONS.ADMIN_SELECTS.DESCRIPTION} | ||
{(policyType === POLICY_TYPE.OPTIONS.LEARNER_SELECTS.VALUE) | ||
&& POLICY_TYPE.OPTIONS.LEARNER_SELECTS.DESCRIPTION} | ||
<ProvisioningFormHelpText /> | ||
</p> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
PolicyDistributionDetail.propTypes = { | ||
policyType: PropTypes.number, | ||
}; | ||
|
||
PolicyDistributionDetail.defaultProps = { | ||
policyType: null, | ||
}; | ||
|
||
export default PolicyDistributionDetail; |
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
51 changes: 51 additions & 0 deletions
51
...n/Provisioning/SubsidyDetailView/PolicyDetailView/tests/PolicyDistributionDetail.test.jsx
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,51 @@ | ||
import { render, screen } from '@testing-library/react'; | ||
import '@testing-library/jest-dom/extend-expect'; | ||
import PolicyDistributionDetail from '../PolicyDistributionDetail'; | ||
import { initialStateValue, ProvisioningContext } from '../../../../testData/Provisioning'; | ||
|
||
describe('PolicyDistributionDetail', () => { | ||
it('renders Learner selects option', () => { | ||
const value = { | ||
...initialStateValue, | ||
formData: { | ||
...initialStateValue.formData, | ||
policies: [ | ||
{ | ||
policyType: 'PerLearnerSpendCreditAccessPolicy', | ||
}, | ||
], | ||
}, | ||
}; | ||
const policyType = 'PerLearnerSpendCreditAccessPolicy'; | ||
render( | ||
<ProvisioningContext value={value}> | ||
<PolicyDistributionDetail policyType={policyType} /> | ||
</ProvisioningContext>, | ||
); | ||
expect(screen.getByText('Budget distribution mode')).toBeInTheDocument(); | ||
expect(screen.getByText('How is content selected?')).toBeInTheDocument(); | ||
expect(screen.getByText('Learner selects content or LMS')).toBeInTheDocument(); | ||
expect(screen.getByText('Not editable')).toBeInTheDocument(); | ||
}); | ||
it('renders Admin selects option', () => { | ||
const value = { | ||
...initialStateValue, | ||
formData: { | ||
...initialStateValue.formData, | ||
policies: [ | ||
{ | ||
policyType: 'AssignedLearnerCreditAccessPolicy', | ||
}, | ||
], | ||
}, | ||
}; | ||
const policyType = 'AssignedLearnerCreditAccessPolicy'; | ||
render( | ||
<ProvisioningContext value={value}> | ||
<PolicyDistributionDetail policyType={policyType} /> | ||
</ProvisioningContext>, | ||
); | ||
expect(screen.getByText('Admin selects content')).toBeInTheDocument(); | ||
expect(screen.getByText('Not editable')).toBeInTheDocument(); | ||
}); | ||
}); |
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