Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PROD] TTAHUB-3329 Fix view of TR event after restructure #2387

Merged
merged 29 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
dcc574d
Replace xml2json
kryswisnaskas Sep 19, 2024
ef8c166
Fix lint error
kryswisnaskas Sep 19, 2024
674646f
Merge branch 'main' into kw-replace-xml2json
kryswisnaskas Sep 19, 2024
55ebfcd
Update known vulnerabilities
kryswisnaskas Sep 19, 2024
1996236
updates to event view
AdamAdHocTeam Sep 19, 2024
a3322bc
Add a new hook to update the flags as part of the merge process when …
GarrettEHill Sep 20, 2024
5d09182
Tests to cover the new hook
GarrettEHill Sep 20, 2024
719d59e
linter fixes
GarrettEHill Sep 20, 2024
3954d9e
more lint
GarrettEHill Sep 20, 2024
66e268d
Update activityReportGoal.test.js
GarrettEHill Sep 20, 2024
4da4e9f
Fix implementation error
GarrettEHill Sep 20, 2024
df0f71d
Update activityReportGoal.test.js
GarrettEHill Sep 20, 2024
996a64c
Update activityReportGoal.test.js
GarrettEHill Sep 20, 2024
b522cdb
Use xml2js
kryswisnaskas Sep 20, 2024
6264675
Merge branch 'main' into kw-replace-xml2json
kryswisnaskas Sep 20, 2024
76456ca
Fix lint errors
kryswisnaskas Sep 20, 2024
90a0ff7
Update known dependencies
kryswisnaskas Sep 20, 2024
28576d0
remove comment
AdamAdHocTeam Sep 23, 2024
c55adfb
move to dev
AdamAdHocTeam Sep 23, 2024
57f4742
ignore for now
AdamAdHocTeam Sep 24, 2024
60f03e7
Merge branch 'main' into al-ttahub-3329-fix-event-view
AdamAdHocTeam Sep 24, 2024
3a3c4c0
fix issue where is ist visit is not saved
AdamAdHocTeam Sep 24, 2024
4f54717
fix issues found by Lauren
AdamAdHocTeam Sep 24, 2024
4e7c770
Merge pull request #2383 from HHS/kw-replace-xml2json
kryswisnaskas Sep 25, 2024
6f54267
Merge pull request #2376 from HHS/al-ttahub-3329-fix-event-view
AdamAdHocTeam Sep 25, 2024
474a24e
Merge pull request #2377 from HHS/TTAHUB-3046/ar-flags-on-merged-goals
GarrettEHill Sep 26, 2024
d44bdf5
Bump rollup from 2.79.1 to 2.79.2 in /frontend
dependabot[bot] Sep 27, 2024
ff15db1
Update known dependencies
kryswisnaskas Sep 27, 2024
ba65915
Merge pull request #2388 from HHS/dependabot/npm_and_yarn/frontend/ro…
thewatermethod Sep 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ parameters:
type: string
dev_git_branch: # change to feature branch to test deployment
description: "Name of github branch that will deploy to dev"
default: "al-ttahub-3196-new-tr-views"
default: "al-ttahub-3329-fix-event-view"
type: string
sandbox_git_branch: # change to feature branch to test deployment
default: "kw-fix-duplicate-programs"
Expand Down
164 changes: 162 additions & 2 deletions frontend/src/pages/ViewTrainingReport/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const mockEvent = (data = {}) => ({
eventName: 'Health Webinar Series: Oral Health and Dental Care from a Regional and State Perspective',
eventOrganizer: 'Regional PD Event (with National Centers)',
'Full Event Title': 'R03 Health Webinar Series: Oral Health and Dental Care from a Regional and State Perspective',
targetPopulations: ['None'],
targetPopulations: ['Tgt Pop 1'],
'Event Duration/# NC Days of Support': 'Series',
},
updatedAt: '2023-06-27T13:46:29.884Z',
Expand Down Expand Up @@ -251,7 +251,7 @@ describe('ViewTrainingReport', () => {
expect(screen.getByText('Regional PD Event (with National Centers)')).toBeInTheDocument();

// target populations
expect(screen.getByText('None')).toBeInTheDocument();
expect(screen.getByText('Tgt Pop 1')).toBeInTheDocument();

// session 1
expect(screen.getByText('Session 1')).toBeInTheDocument();
Expand Down Expand Up @@ -581,6 +581,166 @@ describe('ViewTrainingReport', () => {
expect(await screen.findByText('USER 2')).toBeInTheDocument();
});

it('displays the is ist visit field and the appropriate participants', async () => {
const e = mockEvent();
e.sessionReports = [{
...e.sessionReports[0],
data: {
...e.sessionReports[0].data,
isIstVisit: 'yes',
regionalOfficeTta: ['Ist Office 1', 'Ist Office 2'],
},
},
{
...e.sessionReports[1],
data: {
...e.sessionReports[1].data,
isIstVisit: 'no',
recipients: [{ label: 'Recipient 1' }, { label: 'Recipient 2' }],
participants: ['Participants 1', 'Participants 2'],
},
}];
fetchMock.getOnce('/api/events/id/1?readOnly=true', e);

fetchMock.getOnce('/api/users/names?ids=1', ['USER 1']);
fetchMock.getOnce('/api/users/names?ids=2', ['USER 2']);

act(() => {
renderTrainingReport();
});

expect(await screen.findByRole('heading', { name: 'Training event report R03-PD-23-1037' })).toBeInTheDocument();

expect(screen.queryAllByText('IST visit').length).toBe(2);
expect(await screen.findByText('Regional Office/TTA')).toBeInTheDocument();
expect(await screen.findByText('Yes')).toBeInTheDocument();
expect(await screen.findByText(/ist office 1, ist office 2/i)).toBeInTheDocument();

expect(await screen.findByText('Recipient participants')).toBeInTheDocument();
expect(await screen.findByText('No')).toBeInTheDocument();
expect(await screen.findByText(/Recipient 1, Recipient 2/i)).toBeInTheDocument();

expect(await screen.findByText('Recipient participants')).toBeInTheDocument();
expect(await screen.findByText(/Participants 1, Participants 2/i)).toBeInTheDocument();
});

it('displays the delivery method field and the appropriate participants attending', async () => {
const e = mockEvent();
e.sessionReports = [{
...e.sessionReports[0],
data: {
...e.sessionReports[0].data,
deliveryMethod: 'in-person',
numberOfParticipants: 10,
},
},
{
...e.sessionReports[1],
data: {
...e.sessionReports[1].data,
deliveryMethod: 'hybrid',
numberOfParticipantsInPerson: 11,
numberOfParticipantsVirtually: 12,
},
}];
fetchMock.getOnce('/api/events/id/1?readOnly=true', e);

fetchMock.getOnce('/api/users/names?ids=1', ['USER 1']);
fetchMock.getOnce('/api/users/names?ids=2', ['USER 2']);

act(() => {
renderTrainingReport();
});

expect(await screen.findByRole('heading', { name: 'Training event report R03-PD-23-1037' })).toBeInTheDocument();

expect(screen.queryAllByText('Delivery method').length).toBe(2);
expect(await screen.findByText('In-person')).toBeInTheDocument();
expect(await screen.findByText('Number of participants')).toBeInTheDocument();
expect(await screen.findByText('10')).toBeInTheDocument();

expect(await screen.findByText('Hybrid')).toBeInTheDocument();
expect(await screen.findByText('Number of participants attending in person')).toBeInTheDocument();
expect(await screen.findByText('11')).toBeInTheDocument();
expect(await screen.findByText('Number of participants attending virtually')).toBeInTheDocument();
expect(await screen.findByText('12')).toBeInTheDocument();
});

it('display the correct value for Is IST visit if the value isIstVisit is not set and we have recipients', async () => {
const e = mockEvent();
e.sessionReports = [{
...e.sessionReports[0],
data: {
...e.sessionReports[0].data,
isIstVisit: null,
},
}];

fetchMock.getOnce('/api/events/id/1?readOnly=true', e);
fetchMock.getOnce('/api/users/names?ids=1', ['USER 1']);
fetchMock.getOnce('/api/users/names?ids=2', ['USER 2']);

act(() => {
renderTrainingReport();
});

expect(await screen.findByRole('heading', { name: 'Training event report R03-PD-23-1037' })).toBeInTheDocument();
expect(await screen.findByText('No')).toBeInTheDocument();

expect(screen.queryAllByText('IST visit').length).toBe(1);
});

it('display the correct value for Is IST visit if the value isIstVisit is not set and we have no recipients', async () => {
const e = mockEvent();
e.sessionReports = [{
...e.sessionReports[0],
data: {
...e.sessionReports[0].data,
isIstVisit: null,
recipients: [],
regionalOfficeTta: ['office 1', 'office 2'],
},
}];

fetchMock.getOnce('/api/events/id/1?readOnly=true', e);
fetchMock.getOnce('/api/users/names?ids=1', ['USER 1']);
fetchMock.getOnce('/api/users/names?ids=2', ['USER 2']);

act(() => {
renderTrainingReport();
});

expect(await screen.findByRole('heading', { name: 'Training event report R03-PD-23-1037' })).toBeInTheDocument();
expect(await screen.findByText('Yes')).toBeInTheDocument();

expect(screen.queryAllByText('IST visit').length).toBe(1);
expect(await screen.findByText(/office 1, office 2/i)).toBeInTheDocument();
});

it('displays none for objectiveResources not set', async () => {
const e = mockEvent();
e.sessionReports = [{
...e.sessionReports[0],
data: {
...e.sessionReports[0].data,
objectiveResources: [{ value: '' }],
courses: [],
files: [],
},
}];

fetchMock.getOnce('/api/events/id/1?readOnly=true', e);
fetchMock.getOnce('/api/users/names?ids=1', ['USER 1']);
fetchMock.getOnce('/api/users/names?ids=2', ['USER 2']);

act(() => {
renderTrainingReport();
});

expect(await screen.findByRole('heading', { name: 'Training event report R03-PD-23-1037' })).toBeInTheDocument();
expect(await screen.queryAllByText('None').length).toBe(3);
});

describe('formatOwnerName', () => {
test('handles an error', () => {
const result = formatOwnerName({ eventReportPilotNationalCenterUsers: 123 });
Expand Down
61 changes: 44 additions & 17 deletions frontend/src/pages/ViewTrainingReport/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,15 +214,48 @@ export default function ViewTrainingReport({ match }) {
'Training type': event.data['Event Duration/# NC Days of Support'],
Reasons: event.data.reasons,
'Target populations': event.data.targetPopulations,
},
striped: true,
}, {
heading: 'Vision',
data: {
Vision: event.data.vision,
},
striped: true,
}] : [];

const isIstVisit = (session) => {
if (session.data.isIstVisit === 'yes' || (session.data.regionalOfficeTta && session.data.regionalOfficeTta.length > 0)) {
return true;
}
return false;
};

const generateIstOfficeOrRecipientProperties = (session) => {
if (isIstVisit(session)) {
return {
'Regional Office/TTA': session.data.regionalOfficeTta.join(', '),
};
}

return {
Recipients: session.data.recipients ? session.data.recipients.map((r) => r.label).join(', ') : '',
'Recipient participants': session.data.participants ? session.data.participants.join(', ') : [],
};
};

const generateNumberOfParticipants = (session) => {
// In person or virtual.
if (session.data.deliveryMethod === 'in-person' || session.data.deliveryMethod === 'virtual') {
const numberOfParticipants = session.data.numberOfParticipants ? session.data.numberOfParticipants.toString() : '';
return {
'Number of participants': numberOfParticipants,
};
}
// Hybrid.
const numberOfParticipantsInPerson = session.data.numberOfParticipantsInPerson ? session.data.numberOfParticipantsInPerson.toString() : '';
const numberOfParticipantsVirtually = session.data.numberOfParticipantsVirtually ? session.data.numberOfParticipantsVirtually.toString() : '';
return {
'Number of participants attending in person': numberOfParticipantsInPerson,
'Number of participants attending virtually': numberOfParticipantsVirtually,
};
};

const sessions = event && event.sessionReports ? event.sessionReports.map((session, index) => (
<ReadOnlyContent
key={session.id}
Expand All @@ -244,25 +277,19 @@ export default function ViewTrainingReport({ match }) {
'Session objective': session.data.objective,
Topics: session.data.objectiveTopics,
Trainers: session.data.objectiveTrainers,
'Resource links': session.data.objectiveResources ? session.data.objectiveResources.map((o) => o.value) : [],
'iPD Courses': session.data.courses ? session.data.courses.map((o) => o.name) : [],
'Resource attachments': session.data.files ? session.data.files.map((f) => f.originalFileName) : [],
'Resource links': session.data.objectiveResources && session.data.objectiveResources.filter((r) => r.value).length ? session.data.objectiveResources.map((o) => o.value) : 'None',
'iPD Courses': session.data.courses && session.data.courses.length ? session.data.courses.map((o) => o.name) : 'None',
'Resource attachments': session.data.files && session.data.files.length ? session.data.files.map((f) => f.originalFileName) : 'None',
'Support type': session.data.objectiveSupportType,
},
}, {
heading: 'Participants',
striped: true,
data: {
Recipients: session.data.recipients ? session.data.recipients.map((r) => r.label).join(', ') : '',
'Recipient participants': session.data.participants ? session.data.participants.join(', ') : [],
'Number of participants': String((
session.data.numberOfParticipants || 0
) + (
session.data.numberOfParticipantsVirtually || 0
) + (
session.data.numberOfParticipantsInPerson || 0
)),
'IST visit': isIstVisit(session) ? 'Yes' : 'No',
...generateIstOfficeOrRecipientProperties(session),
'Delivery method': capitalize(session.data.deliveryMethod || ''),
...generateNumberOfParticipants(session),
'Language used': session.data.language ? session.data.language.join(', ') : [],
'TTA provided': session.data.ttaProvided,
},
Expand Down
Loading
Loading