Skip to content

Commit

Permalink
Merge pull request #2229 from HHS/main
Browse files Browse the repository at this point in the history
[Prod] Add columns to CSV, add iPD course widget, fix bad data in createdVia columns
  • Loading branch information
Jones-QuarteyDana authored Jun 25, 2024
2 parents 9b9365d + 32b7293 commit 8c9c24c
Show file tree
Hide file tree
Showing 16 changed files with 478 additions and 50 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ parameters:
default: "mb/TTAHUB-3007/no-disallowed-urls"
type: string
sandbox_git_branch: # change to feature branch to test deployment
default: "al-ttahub-add-fei-root-cause-to-review"
default: "jp/3005/ipd-courses-widget"
type: string
prod_new_relic_app_id:
default: "877570491"
Expand Down
13 changes: 13 additions & 0 deletions frontend/src/pages/ResourcesDashboard/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ const resourcesDefault = {
participant: {
numParticipants: '765',
},
ipdCourses: {
percentReports: '4.65%',
},
},
resourcesUse: {
headers: ['Jan-22'],
Expand Down Expand Up @@ -116,6 +119,9 @@ const resourcesRegion1 = {
participant: {
numParticipants: '665',
},
ipdCourses: {
percentReports: '4.65%',
},
},
resourcesUse: {
headers: ['Jan-22'],
Expand Down Expand Up @@ -183,6 +189,9 @@ const resourcesRegion2 = {
participant: {
numParticipants: '565',
},
ipdCourses: {
percentReports: '4.65%',
},
},
resourcesUse: {
headers: ['Jan-22'],
Expand Down Expand Up @@ -442,6 +451,10 @@ describe('Resource Dashboard page', () => {
expect(screen.getAllByText(/^[ \t]*reports with resources[ \t]*$/i)[0]).toBeInTheDocument();
expect(screen.getByText(/6,135 of 17,914/i)).toBeInTheDocument();

// iPD courses
expect(screen.getByText(/4.65%/i)).toBeInTheDocument();
expect(screen.getAllByText(/^[ \t]*reports citing ipd courses[ \t]*$/i)[0]).toBeInTheDocument();

expect(screen.getByText(/.66%/i)).toBeInTheDocument();
expect(screen.getAllByText(/^[ \t]*eclkc resources[ \t]*$/i)[0]).toBeInTheDocument();
expect(screen.getByText(/818 of 365/i)).toBeInTheDocument();
Expand Down
1 change: 1 addition & 0 deletions frontend/src/pages/ResourcesDashboard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ export default function ResourcesDashboard() {
'ECLKC Resources',
'Recipients reached',
'Participants reached',
'Reports citing iPD courses',
]}
showTooltips
/>
Expand Down
44 changes: 42 additions & 2 deletions frontend/src/widgets/ResourcesDashboardOverview.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Grid } from '@trussworks/react-uswds';
import { Link } from 'react-router-dom';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import {
faLink, faCube, faUser, faUserFriends,
faLink,
faCube,
faUser,
faUserFriends,
faFolder,
} from '@fortawesome/free-solid-svg-icons';
import './ResourcesDashboardOverview.css';

Expand All @@ -14,6 +19,7 @@ import colors from '../colors';
export function Field({
label1,
label2,
route,
data,
icon,
iconColor,
Expand All @@ -37,8 +43,15 @@ export function Field({
buttonLabel={`${tooltipText} click to visually reveal this information`}
tooltipText={tooltipText}
/>
) : label1}
) : (
<span className="margin-top-1">{label1}</span>
)}
{label2}
{route && (
<Link to={route.to} className="margin-top-1">
{route.label}
</Link>
)}
</span>
</Grid>
);
Expand All @@ -58,12 +71,17 @@ Field.propTypes = {
backgroundColor: PropTypes.string.isRequired,
tooltipText: PropTypes.string,
showTooltip: PropTypes.bool,
route: PropTypes.shape({
to: PropTypes.string,
label: PropTypes.string,
}),
};

Field.defaultProps = {
tooltipText: '',
showTooltip: false,
label2: '',
route: null,
};
const DASHBOARD_FIELDS = {
'Reports with resources': {
Expand Down Expand Up @@ -124,6 +142,24 @@ const DASHBOARD_FIELDS = {
/>
),
},
'Reports citing iPD courses': {
render: (data) => (
<Field
key="reports-citing-ipd-courses"
icon={faFolder}
showTooltip={false}
label1="Reports citing iPD courses"
iconColor={colors.baseDark}
backgroundColor={colors.baseLightest}
tooltipText="Total participants of ARs that cite at least one resource"
data={data.ipdCourses.percentReports}
route={{
to: '/dashboards/ipd-courses',
label: 'Display details',
}}
/>
),
},
};

export function ResourcesDashboardOverviewWidget({
Expand Down Expand Up @@ -180,6 +216,9 @@ ResourcesDashboardOverviewWidget.defaultProps = {
participant: {
numParticipants: '0',
},
ipdCourses: {
percentReports: '0%',
},
},
loading: false,
showTooltips: false,
Expand All @@ -188,6 +227,7 @@ ResourcesDashboardOverviewWidget.defaultProps = {
'ECLKC Resources',
'Recipients reached',
'Participants reached',
'Reports citing iPD courses',
],
};

Expand Down
28 changes: 21 additions & 7 deletions frontend/src/widgets/__tests__/ResourcesDashboardOverview.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
/* eslint-disable jest/no-disabled-tests */
import '@testing-library/jest-dom';
import React from 'react';
import { Router } from 'react-router-dom';
import { createMemoryHistory } from 'history';
import { render, screen } from '@testing-library/react';
import { ResourcesDashboardOverviewWidget } from '../ResourcesDashboardOverview';

const renderResourcesDashboardOverview = (props) => (
render(<ResourcesDashboardOverviewWidget loading={props.loading} data={props.data} />)
);
const renderResourcesDashboardOverview = (props) => {
const history = createMemoryHistory();

render(
<Router history={history}>
<ResourcesDashboardOverviewWidget loading={props.loading} data={props.data} />
</Router>,
);
};

describe('Resource Dashboard Overview Widget', () => {
it('handles undefined data', async () => {
Expand All @@ -16,6 +24,7 @@ describe('Resource Dashboard Overview Widget', () => {
expect(screen.getByText(/eclkc resources/i)).toBeInTheDocument();
expect(screen.getByText(/recipients reached/i)).toBeInTheDocument();
expect(screen.getByText(/participants reached/i)).toBeInTheDocument();
expect(screen.getByText(/reports citing ipd courses/i)).toBeInTheDocument();
});

it('shows the correct data', async () => {
Expand All @@ -36,14 +45,19 @@ describe('Resource Dashboard Overview Widget', () => {
participant: {
numParticipants: '765',
},
ipdCourses: {
percentReports: '88.88%',
},
};

renderResourcesDashboardOverview({ data });
expect(await screen.findByText(/^[ \t]*reports with resources\r?\n?[ \t]*8,135 of 19,914/i)).toBeVisible();
expect(await screen.findByText(/^[ \t]*eclkc resources\n?[ \t]*1,819 of 2,365/i)).toBeVisible();
expect(await screen.findByText(/248/i)).toBeVisible();
expect(await screen.findByText(/8,135 of 19,914/)).toBeVisible();
expect(await screen.findByText(/1,819 of 2,365/)).toBeVisible();
expect(await screen.findByText(/248/)).toBeVisible();
expect(await screen.findByText(/recipients reached/i)).toBeVisible();
expect(await screen.findByText(/765/i)).toBeVisible();
expect(await screen.findByText(/765/)).toBeVisible();
expect(await screen.findByText(/participants reached/i)).toBeVisible();
expect(await screen.findByText(/88.88%/)).toBeVisible();
expect(await screen.findByText(/reports citing ipd courses/i)).toBeVisible();
});
});
2 changes: 1 addition & 1 deletion src/goalServices/createOrUpdateGoals.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ describe('createOrUpdateGoals', () => {
status: 'Draft',
grantId: grants[0].id,
source: GOAL_SOURCES[0],
createdVia: 'activityReport',
});

objective = await Objective.create({
Expand Down Expand Up @@ -113,7 +114,6 @@ describe('createOrUpdateGoals', () => {
grantId: goal.grantId,
status: 'Draft',
};

newGoals = await createOrUpdateGoals([
{
...basicGoal,
Expand Down
5 changes: 1 addition & 4 deletions src/goalServices/goals.js
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,7 @@ export async function createOrUpdateGoals(goals) {
status: 'Draft', // if we are creating a goal for the first time, it should be set to 'Draft'
isFromSmartsheetTtaPlan: false,
rtrOrder: rtrOrder + 1,
createdVia: 'rtr',
});
}

Expand All @@ -504,10 +505,6 @@ export async function createOrUpdateGoals(goals) {
if (newGoal.status !== status) {
newGoal.set({ status });
}

if (!newGoal.createdVia || newGoal.createdVia !== createdVia) {
newGoal.set({ createdVia: createdVia || (newGoal.isFromSmartsheetTtaPlan ? 'imported' : 'rtr') });
}
}

// end date and source can be updated if the goal is not closed
Expand Down
Loading

0 comments on commit 8c9c24c

Please sign in to comment.