Skip to content

Commit 8400303

Browse files
authored
Merge branch 'master' into chore/add_unit_test_to_validate_token
2 parents 9fb6607 + 2e29cc5 commit 8400303

File tree

7 files changed

+16744
-9638
lines changed

7 files changed

+16744
-9638
lines changed

bmh_admin_portal_backend/poetry.lock

+901-339
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bmh_admin_portal_ui/README_DEPLOYMENT.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,9 @@ The react application expects certain environment variables to be present during
7676
* REACT_APP_HELP_EMAIL: help@brh.org
7777
* REACT_APP_ROOT_EMAIL_DOMAIN: brh.org
7878
* REACT_APP_DISPLAY_NAME: "STRIDES Portal"
79-
* REACT_APP_OCC_EMAIL_DOMAIN : occ-data.org
80-
* REACT_APP_OCC_HELPER_URL : API Gateway Endpoint deployed in backend for OCC
79+
* REACT_APP_OCC_EMAIL_DOMAIN: occ-data.org
80+
* REACT_APP_OCC_HELPER_URL: API Gateway Endpoint deployed in backend for OCC
81+
* REACT_APP_DISABLED_FORMS: Optional, an array of form names that to be hidden from the UI (e.g. `["stridesCredits", "directPay"]`)
8182

8283
### Build and deploy static files
8384

bmh_admin_portal_ui/package-lock.json

+15,798-9,285
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bmh_admin_portal_ui/package.json

+7-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
"version": "0.1.0",
44
"private": true,
55
"dependencies": {
6-
"@testing-library/jest-dom": "^5.11.9",
6+
"@testing-library/jest-dom": "^6.4.5",
77
"@testing-library/react": "^11.2.5",
88
"@testing-library/user-event": "^12.8.1",
9-
"axios": "^0.21.3",
9+
"axios": "^1.6.4",
1010
"bootstrap": "^4.6.0",
1111
"husky": "^5.1.3",
1212
"jwt-decode": "^3.1.2",
@@ -66,5 +66,10 @@
6666
},
6767
"overrides": {
6868
"@svgr/webpack": "$@svgr/webpack"
69+
},
70+
"jest": {
71+
"moduleNameMapper": {
72+
"^axios$": "axios/dist/node/axios.cjs"
73+
}
6974
}
7075
}

bmh_admin_portal_ui/src/components/request-workspace/direct-pay-form.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ const DirectPayForm = (props) => {
155155
if(requestApproved === "true"){
156156
componentToRender = (
157157
<div>
158-
<Form onSubmit={handleRequest} keyField='directpay_request_information'>
158+
<Form onSubmit={handleRequest} id='directpay_request_information'>
159159
<Form.Row className="mb-3">
160160
<Col>
161161
<Form.Check type="checkbox" name="approved_creditcard" onChange={handleChange} required label={
@@ -239,7 +239,7 @@ const DirectPayForm = (props) => {
239239

240240
return(
241241
<div>
242-
<Form onSubmit={handleSubmit} keyField='directpay_billingID_confirmation'>
242+
<Form onSubmit={handleSubmit} id='directpay_billingID_confirmation'>
243243
<Form.Label> BillingID <span data-tip data-for="billingID_help"><BiHelpCircle /></span></Form.Label>
244244
<ReactTooltip class="tooltip" id="billingID_help" place="top" effect="solid" multiline={true}>
245245
Enter the Billing ID provided from registration through the Payment Solutions Portal. <br />

bmh_admin_portal_ui/src/views/RequestWorkspace.test.js

+15-4
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,15 @@ const getRenderedFormTypesList = (wrapperTag) => {
3434
return renderedFormTypes;
3535
}
3636

37-
const mountRequestWorkspceWrapper = (isCreditsAuthorized = false) => {
37+
const mountRequestWorkspaceWrapper = (isCreditsAuthorized = false) => {
3838
jest.spyOn(authUtils, 'authorizeCredits').mockResolvedValue(isCreditsAuthorized);
3939
return mount( <RequestWorkspace/> );
4040
}
4141

42+
beforeEach(() => process.env.REACT_APP_DISABLED_FORMS = '[]');
43+
4244
it('renders RequestWorkspace page with default form', async () => {
43-
const requestWorkspaceWrapper = mountRequestWorkspceWrapper(false);
45+
const requestWorkspaceWrapper = mountRequestWorkspaceWrapper(false);
4446
requestWorkspaceWrapper.update();
4547
expect(requestWorkspaceWrapper.find('h2').text()).toBe("Workspace Account Request Form");
4648
expect(requestWorkspaceWrapper.find(FORM_TAGS[DEFAULT_FORM_TYPE])).toHaveLength(1);
@@ -49,7 +51,7 @@ it('renders RequestWorkspace page with default form', async () => {
4951
describe('verify the form toggles are working as expected', () => {
5052

5153
it('verifies the number of toggle buttons rendered correctly for all form types', async () => {
52-
const requestWorkspaceWrapper = mountRequestWorkspceWrapper(true);
54+
const requestWorkspaceWrapper = mountRequestWorkspaceWrapper(true);
5355

5456
await waitFor(() => {});
5557

@@ -66,7 +68,7 @@ describe('verify the form toggles are working as expected', () => {
6668

6769

6870
it('verifies RequestWorkspace toggles between forms', async () => {
69-
const requestWorkspaceWrapper = mountRequestWorkspceWrapper(true);
71+
const requestWorkspaceWrapper = mountRequestWorkspaceWrapper(true);
7072

7173
//Ensure default form is being loaded at first
7274
expect(getRenderedFormTypesList(requestWorkspaceWrapper)).toEqual([DEFAULT_FORM_TYPE]);
@@ -87,3 +89,12 @@ describe('verify the form toggles are working as expected', () => {
8789
});
8890

8991
});
92+
93+
it('verifies RequestWorkspace forms can be hidden by config', async () => {
94+
process.env.REACT_APP_DISABLED_FORMS = '["directPay"]';
95+
const requestWorkspaceWrapper = mountRequestWorkspaceWrapper(true);
96+
97+
for (const disabledForm in process.env.REACT_APP_DISABLED_FOR) {
98+
expect(requestWorkspaceWrapper.find(disabledForm)).not.toExist();
99+
}
100+
});

bmh_admin_portal_ui/src/views/request-workspace.jsx

+18-4
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,24 @@ const RequestWorkspace = () => {
3838
// const [grantsAuthorized, setGrantsAuthorized] = useState(false)
3939

4040
useEffect(() => {
41+
if (process.env.REACT_APP_DISABLED_FORMS) {
42+
try {
43+
const disabledForms = JSON.parse(process.env.REACT_APP_DISABLED_FORMS);
44+
if (disabledForms && Array.isArray(disabledForms)) {
45+
disabledForms.forEach((formName) => {
46+
if (formName in FORM_OPTIONS) {
47+
delete FORM_OPTIONS[formName]
48+
}
49+
})
50+
}
51+
} catch (err) {
52+
console.error(`Unable to parse disabled forms config: ${err}`);
53+
}
54+
}
4155
async function fetchAuthorized() {
4256
const cAuthorized = await authorizeCredits();
4357
// const gAuthorized = await authorizeGrants();
44-
if (cAuthorized) {
58+
if (cAuthorized && FORM_OPTIONS.stridesCredits) {
4559
setFormToggle(FORM_OPTIONS.stridesCredits)
4660
}
4761
setCreditsAuthorized(cAuthorized);
@@ -103,9 +117,9 @@ const RequestWorkspace = () => {
103117
<div>
104118
<Row className="mb-5">
105119
<ToggleButtonGroup key={formToggle} type="radio" name="form-select" defaultValue={formToggle} onChange={handleChange}>
106-
<ToggleButton variant="outline-primary" value={FORM_OPTIONS.stridesGrant}>STRIDES Grant/Award Funded</ToggleButton>
107-
{(creditsAuthorized) ? <ToggleButton variant="outline-primary" value={FORM_OPTIONS.stridesCredits}>STRIDES Credits</ToggleButton> : null}
108-
<ToggleButton variant="outline-success" value={FORM_OPTIONS.directPay}>OCC Direct Pay</ToggleButton>
120+
{(FORM_OPTIONS.stridesGrant) ? <ToggleButton variant="outline-primary" value={FORM_OPTIONS.stridesGrant}>STRIDES Grant/Award Funded</ToggleButton> : null}
121+
{(creditsAuthorized && FORM_OPTIONS.stridesCredits) ? <ToggleButton variant="outline-primary" value={FORM_OPTIONS.stridesCredits}>STRIDES Credits</ToggleButton> : null}
122+
{(FORM_OPTIONS.directPay) ? <ToggleButton variant="outline-success" value={FORM_OPTIONS.directPay}>OCC Direct Pay</ToggleButton> : null}
109123
</ToggleButtonGroup>
110124
</Row>
111125
</div>

0 commit comments

Comments
 (0)