From 19b0e2d8621d8f62e4de8d47b88768c11dc7ea15 Mon Sep 17 00:00:00 2001 From: Josh Salisbury Date: Fri, 5 Feb 2021 16:35:35 -0600 Subject: [PATCH 1/4] Program type constant updated. Only shows for grantee reports --- .../src/pages/ActivityReport/Pages/activitySummary.js | 4 ++++ frontend/src/pages/ActivityReport/__tests__/index.js | 9 +++++++++ frontend/src/pages/ActivityReport/constants.js | 8 +++----- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/frontend/src/pages/ActivityReport/Pages/activitySummary.js b/frontend/src/pages/ActivityReport/Pages/activitySummary.js index 930851cca8..10e79a8990 100644 --- a/frontend/src/pages/ActivityReport/Pages/activitySummary.js +++ b/frontend/src/pages/ActivityReport/Pages/activitySummary.js @@ -55,6 +55,7 @@ const ActivitySummary = ({ if (previousActivityRecipientType.current !== activityRecipientType) { setValue('activityRecipients', []); setValue('participants', []); + setValue('programTypes', []); previousActivityRecipientType.current = activityRecipientType; } }, [activityRecipientType, setValue]); @@ -123,6 +124,8 @@ const ActivitySummary = ({ options={collaborators.map((user) => ({ value: user.id, label: user.name }))} /> + {!nonGranteeSelected + && (
({ value: pt, label: pt }))} />
+ )}
{ }); }); + it('hides program type if non-grantee is selected', async () => { + renderActivityReport('new'); + const information = await screen.findByRole('group', { name: 'Who was the activity for?' }); + await waitFor(() => expect(screen.queryByLabelText('Program type(s)')).toBeVisible()); + const nonGrantee = within(information).getByLabelText('Non-Grantee'); + fireEvent.click(nonGrantee); + await waitFor(() => expect(screen.queryByLabelText('Program type(s)')).toBeNull()); + }); + it('defaults to activity summary if no page is in the url', async () => { renderActivityReport('new', null); await waitFor(() => expect(history.location.pathname).toEqual('/activity-reports/new/activity-summary')); diff --git a/frontend/src/pages/ActivityReport/constants.js b/frontend/src/pages/ActivityReport/constants.js index ae072c8922..3e9cc9984d 100644 --- a/frontend/src/pages/ActivityReport/constants.js +++ b/frontend/src/pages/ActivityReport/constants.js @@ -55,11 +55,9 @@ export const targetPopulations = [ ]; export const programTypes = [ - 'program type 1', - 'program type 2', - 'program type 3', - 'program type 4', - 'program type 5', + 'Early Head Start (ages 0-3)', + 'Head Start (ages 3-5)', + 'EHS-CCP', ]; export const topics = [ From cfb47374aed9b2752b9436c23adf9f94ec85e803 Mon Sep 17 00:00:00 2001 From: Josh Salisbury Date: Mon, 8 Feb 2021 15:49:31 -0600 Subject: [PATCH 2/4] Flip program type show/hide logic Explicitly look for a recipient type of grantee to show program type. Thie means program type only shows up when 'grantee' is selected --- frontend/src/pages/ActivityReport/Pages/activitySummary.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frontend/src/pages/ActivityReport/Pages/activitySummary.js b/frontend/src/pages/ActivityReport/Pages/activitySummary.js index 10e79a8990..3dccf181e4 100644 --- a/frontend/src/pages/ActivityReport/Pages/activitySummary.js +++ b/frontend/src/pages/ActivityReport/Pages/activitySummary.js @@ -45,6 +45,7 @@ const ActivitySummary = ({ const disableRecipients = activityRecipientType === ''; const nonGranteeSelected = activityRecipientType === 'non-grantee'; + const granteeSelected = activityRecipientType === 'grantee'; const selectedRecipients = nonGranteeSelected ? nonGrantees : grants; const previousActivityRecipientType = useRef(activityRecipientType); const recipientLabel = nonGranteeSelected ? 'Non-grantee name(s)' : 'Grantee name(s)'; @@ -124,7 +125,7 @@ const ActivitySummary = ({ options={collaborators.map((user) => ({ value: user.id, label: user.name }))} />
- {!nonGranteeSelected + {granteeSelected && (
Date: Mon, 8 Feb 2021 16:01:02 -0600 Subject: [PATCH 3/4] Fix program-type test --- frontend/src/pages/ActivityReport/__tests__/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/src/pages/ActivityReport/__tests__/index.js b/frontend/src/pages/ActivityReport/__tests__/index.js index f027a2816f..ac2d1ec455 100644 --- a/frontend/src/pages/ActivityReport/__tests__/index.js +++ b/frontend/src/pages/ActivityReport/__tests__/index.js @@ -88,10 +88,10 @@ describe('ActivityReport', () => { it('hides program type if non-grantee is selected', async () => { renderActivityReport('new'); const information = await screen.findByRole('group', { name: 'Who was the activity for?' }); - await waitFor(() => expect(screen.queryByLabelText('Program type(s)')).toBeVisible()); - const nonGrantee = within(information).getByLabelText('Non-Grantee'); - fireEvent.click(nonGrantee); await waitFor(() => expect(screen.queryByLabelText('Program type(s)')).toBeNull()); + const nonGrantee = within(information).getByLabelText('Grantee'); + fireEvent.click(nonGrantee); + await waitFor(() => expect(screen.queryByLabelText('Program type(s)')).toBeVisible()); }); it('defaults to activity summary if no page is in the url', async () => { From 5f003f0e1545c5e1e992ceb94b94516f34ff8698 Mon Sep 17 00:00:00 2001 From: Josh Salisbury Date: Wed, 10 Feb 2021 09:36:00 -0600 Subject: [PATCH 4/4] Test title for program type matches behavior --- frontend/src/pages/ActivityReport/__tests__/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/pages/ActivityReport/__tests__/index.js b/frontend/src/pages/ActivityReport/__tests__/index.js index ac2d1ec455..b12e811eef 100644 --- a/frontend/src/pages/ActivityReport/__tests__/index.js +++ b/frontend/src/pages/ActivityReport/__tests__/index.js @@ -85,7 +85,7 @@ describe('ActivityReport', () => { }); }); - it('hides program type if non-grantee is selected', async () => { + it('program type is hidden unless grantee is selected', async () => { renderActivityReport('new'); const information = await screen.findByRole('group', { name: 'Who was the activity for?' }); await waitFor(() => expect(screen.queryByLabelText('Program type(s)')).toBeNull());