Skip to content

Commit 0d96dc2

Browse files
RRanathccbc-service-account
authored andcommitted
chore: enable fnha history
1 parent 5f0c2f4 commit 0d96dc2

File tree

10 files changed

+658
-4
lines changed

10 files changed

+658
-4
lines changed

app/components/Analyst/History/HistoryContent.tsx

+30
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import applicationSowDataSchema from 'formSchema/uiSchema/history/applicationSow
1515
import applicationAnnounced from 'formSchema/uiSchema/history/applicationAnnounced';
1616
import { processArrayDiff } from 'components/DiffTable';
1717
import communities from 'formSchema/uiSchema/history/communities';
18+
import fnhaContribution from 'formSchema/uiSchema/history/fnhaContribution';
1819
import StatusPill from '../../StatusPill';
1920
import HistoryDetails from './HistoryDetails';
2021
import HistoryAttachment from './HistoryAttachment';
@@ -1031,6 +1032,35 @@ const HistoryContent = ({
10311032
);
10321033
}
10331034

1035+
if (tableName === 'application_fnha_contribution') {
1036+
return (
1037+
<StyledContent data-testid="history-fnha-contribution">
1038+
<span>
1039+
{displayName} updated <b>FNHA Contribution</b> on {createdAtFormatted}
1040+
</span>
1041+
{showHistoryDetails && (
1042+
<HistoryDetails
1043+
json={record}
1044+
prevJson={prevHistoryItem?.record || {}}
1045+
excludedKeys={[
1046+
'id',
1047+
'updated_at',
1048+
'created_at',
1049+
'created_by',
1050+
'updated_by',
1051+
'archived_at',
1052+
'archived_by',
1053+
'reason_for_change',
1054+
]}
1055+
diffSchema={fnhaContribution}
1056+
overrideParent="fnhaContribution"
1057+
/>
1058+
)}
1059+
{reasonForChange && <ChangeReason reason={reasonForChange} />}
1060+
</StyledContent>
1061+
);
1062+
}
1063+
10341064
return null;
10351065
};
10361066

app/components/Analyst/History/HistoryFilter.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const typeLabelMappings: Record<string, string> = {
3030
change_request_data: 'Amendment',
3131
application_claims_data: 'Claims & Progress Report',
3232
application_gis_assessment_hh: 'Assessment',
33+
application_fnha_contribution: 'FNHA Contribution',
3334
};
3435

3536
const getLabelForType = (type: string) =>

app/components/Analyst/History/HistoryIcon.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ const iconMap = {
5454
application_milestone_data: faSignsPost,
5555
application_project_type: faWifi,
5656
application_communities: faClipboardList,
57+
application_fnha_contribution: faDollarSign,
5758
};
5859

5960
interface Props {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const fnhaContribution = {
2+
fnhaContribution: {
3+
properties: {
4+
fnha_contribution: {
5+
type: 'number',
6+
title: 'FNHA Contribution',
7+
},
8+
},
9+
},
10+
};
11+
12+
export default fnhaContribution;

app/tests/pages/analyst/application/[applicationId]/history.test.tsx

+42-2
Original file line numberDiff line numberDiff line change
@@ -3058,6 +3058,32 @@ const mockQueryPayload = {
30583058
sessionSub: '54f0aa1ad196497bb80d05b21c20a1ef@bceidbasic',
30593059
tableName: 'application_communities',
30603060
},
3061+
{
3062+
applicationId: 1,
3063+
createdAt: '2025-03-06T19:50:30.265459+00:00',
3064+
createdBy: 243,
3065+
externalAnalyst: null,
3066+
familyName: 'Bar',
3067+
item: null,
3068+
givenName: 'Foo',
3069+
op: 'INSERT',
3070+
record: {
3071+
id: 1,
3072+
created_at: '2025-03-06T19:50:30.265459+00:00',
3073+
created_by: 243,
3074+
updated_at: '2025-03-06T19:50:30.265459+00:00',
3075+
updated_by: 243,
3076+
archived_at: null,
3077+
archived_by: null,
3078+
application_id: 1,
3079+
fnha_contribution: 10000,
3080+
reason_for_change: 'Some test reason',
3081+
},
3082+
oldRecord: null,
3083+
recordId: '5ebdd9d8-9f9f-53cb-abc5-580bee710b73',
3084+
sessionSub: 'feae2edcecbd418f9564bb170504321b@idir',
3085+
tableName: 'application_fnha_contribution',
3086+
},
30613087
],
30623088
},
30633089
formData: {
@@ -3757,7 +3783,7 @@ describe('The index page', () => {
37573783

37583784
const diffTables = screen.getAllByTestId('diff-table');
37593785

3760-
expect(diffTables.length).toBe(31);
3786+
expect(diffTables.length).toBe(32);
37613787

37623788
diffTables.forEach((table) => {
37633789
expect(table).toBeVisible();
@@ -4017,6 +4043,19 @@ describe('The index page', () => {
40174043
);
40184044
expect(removedCommunityRows).toHaveLength(1);
40194045
});
4046+
4047+
it('shows the correct history for fnha contribution', async () => {
4048+
pageTestingHelper.loadQuery();
4049+
pageTestingHelper.renderPage();
4050+
4051+
const fnhaHistory = screen.getAllByTestId('history-fnha-contribution')[0];
4052+
4053+
expect(fnhaHistory).toBeInTheDocument();
4054+
4055+
expect(fnhaHistory).toHaveTextContent(
4056+
'Foo Bar updated FNHA Contribution on Mar 6, 2025, 11:50 a.m.'
4057+
);
4058+
});
40204059
});
40214060

40224061
describe('The filter', () => {
@@ -4042,7 +4081,7 @@ describe('The filter', () => {
40424081
const dropdown = document.querySelector('[role="listbox"]') as HTMLElement;
40434082
const options = within(dropdown!).getAllByRole('option');
40444083
const optionNames = options.map((option) => option.textContent?.trim());
4045-
expect(options.length).toEqual(15);
4084+
expect(options.length).toEqual(16);
40464085

40474086
const expectedOptionNames = [
40484087
'Amendment',
@@ -4053,6 +4092,7 @@ describe('The filter', () => {
40534092
'Claims & progress report',
40544093
'Community progress report',
40554094
'Conditional approval',
4095+
'Fnha contribution',
40564096
'Funding agreement, sow & map',
40574097
'Lead',
40584098
'Milestone report',

db/deploy/computed_columns/application_history.sql

+10-1
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,16 @@ union all
268268
inner join ccbc_public.ccbc_user u on v.created_by=u.id
269269
where v.op='INSERT' and v.table_name='application_rd' and v.record->>'archived_by' is null
270270
and v.record->>'application_id'=application.id::varchar(10)
271-
group by v.created_at, v.op, v.table_name, u.family_name, u.given_name, u.session_sub, u.external_analyst, v.created_by;
271+
group by v.created_at, v.op, v.table_name, u.family_name, u.given_name, u.session_sub, u.external_analyst, v.created_by
272+
273+
union all
274+
select application.id, v.created_at, v.op, v.table_name, v.record_id, v.record, v.old_record,
275+
v.record->>'application_fnha_contribution' as item,
276+
u.family_name, u.given_name, u.session_sub, u.external_analyst, v.created_by
277+
from ccbc_public.record_version as v
278+
inner join ccbc_public.ccbc_user u on v.created_by=u.id
279+
where (v.op='INSERT' or v.op='UPDATE') and v.table_name='application_fnha_contribution' and v.record->>'archived_by' is null
280+
and v.record->>'application_id'=application.id::varchar(10);
272281

273282
$$ language sql stable;
274283

0 commit comments

Comments
 (0)