Skip to content

Commit 42fc3ea

Browse files
sw-mattwZain Kassam
and
Zain Kassam
authored
feat(FN-3671): add bank correction history tab frontend (#4185)
Co-authored-by: Zain Kassam <zkassam@ukexportfinance.gov.uk>
1 parent 156be62 commit 42fc3ea

File tree

31 files changed

+916
-14
lines changed

31 files changed

+916
-14
lines changed

dtfs-central-api/src/v1/controllers/utilisation-report-service/get-utilisation-report-reconciliation-details-by-id.controller/helpers/get-record-correction-details.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { format } from 'date-fns';
2-
import { FeeRecordEntity, FeeRecordCorrectionSummary, mapReasonsToDisplayValues } from '@ukef/dtfs2-common';
2+
import { FeeRecordEntity, FeeRecordCorrectionSummary, mapReasonsToDisplayValues, DATE_FORMATS } from '@ukef/dtfs2-common';
33
import { getFormattedOldAndCorrectValues } from './get-formatted-old-and-correct-values';
44

55
/**
@@ -39,7 +39,7 @@ export const getRecordCorrectionDetails = (feeRecords: FeeRecordEntity[]): FeeRe
3939
feeRecordId,
4040
exporter,
4141
formattedReasons,
42-
formattedDateSent: format(dateRequested, 'dd MMM yyyy'),
42+
formattedDateSent: format(dateRequested, DATE_FORMATS.DD_MMM_YYYY),
4343
formattedOldRecords,
4444
formattedCorrectRecords,
4545
isCompleted,
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
const page = {
2+
table: () => cy.get('[data-cy="correction-log-table"]'),
3+
tableHeaders: {
4+
dateSent: () => cy.get(`[data-cy="correction-log-table"] [data-cy="correction-log-header--date-sent"]`),
5+
exporter: () => cy.get(`[data-cy="correction-log-table"] [data-cy="correction-log-header--exporter"]`),
6+
reasons: () => cy.get(`[data-cy="correction-log-table"] [data-cy="correction-log-header--formatted-reasons"]`),
7+
correctRecord: () => cy.get(`[data-cy="correction-log-table"] [data-cy="correction-log-header--formatted-corrected-values"]`),
8+
oldRecord: () => cy.get(`[data-cy="correction-log-table"] [data-cy="correction-log-header--formatted-previous-values"]`),
9+
correctionNotes: () => cy.get(`[data-cy="correction-log-table"] [data-cy="correction-log-header--bank-commentary"]`),
10+
},
11+
rows: () => cy.get(`[data-cy="correction-log-table"] tr`),
12+
row: (index) => ({
13+
dateSent: () => cy.get(`[data-cy="correction-log-table"] tr:nth-child(${index}) [data-cy="correction-log-row--date-sent"]`),
14+
exporter: () => cy.get(`[data-cy="correction-log-table"] tr:nth-child(${index}) [data-cy="correction-log-row--exporter"]`),
15+
reasons: () => cy.get(`[data-cy="correction-log-table"] tr:nth-child(${index}) [data-cy="correction-log-row--formatted-reasons"]`),
16+
correctRecord: () => cy.get(`[data-cy="correction-log-table"] tr:nth-child(${index}) [data-cy="correction-log-row--formatted-corrected-values"]`),
17+
oldRecord: () => cy.get(`[data-cy="correction-log-table"] tr:nth-child(${index}) [data-cy="correction-log-row--formatted-previous-values"]`),
18+
correctionNotes: () => cy.get(`[data-cy="correction-log-table"] tr:nth-child(${index}) [data-cy="correction-log-row--bank-commentary"]`),
19+
}),
20+
correctionsTextLine1: () => cy.get('[data-cy="corrections-text-line-1"]'),
21+
correctionsTextLine2: () => cy.get('[data-cy="corrections-text-line-2"]'),
22+
noCorrectionsTextLine1: () => cy.get('[data-cy="no-corrections-text-line-1"]'),
23+
noCorrectionsTextLine2: () => cy.get('[data-cy="no-corrections-text-line-2"]'),
24+
};
25+
26+
module.exports = page;

libs/common/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,15 @@
4747
"unit-test-ff": "jest --coverage --verbose --config=unit.ff.jest.config.js --passWithNoTests"
4848
},
4949
"dependencies": {
50+
"@types/lodash": "^4.17.15",
5051
"axios": "1.7.8",
5152
"big.js": "^6.2.2",
5253
"date-fns": "^3.3.1",
5354
"date-fns-tz": "^2.0.1",
5455
"dotenv": "^16.4.5",
5556
"express": "^4.21.2",
5657
"html-entities": "^2.5.2",
57-
"lodash.difference": "^4.5.0",
58+
"lodash": "^4.17.21",
5859
"mongodb": "^4.17.2",
5960
"mssql": "^11.0.1",
6061
"node-cron": "^3.0.3",

libs/common/src/change-stream/validate-audit-details.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ObjectId } from 'mongodb';
2-
import difference from 'lodash.difference';
2+
import { difference } from 'lodash';
33
import { validateAuditDetails, validateAuditDetailsAndUserType } from './validate-audit-details';
44
import { AUDIT_USER_TYPES_AS_ARRAY, AUDIT_USER_TYPES_NOT_REQUIRING_ID, AUDIT_USER_TYPES_REQUIRING_ID } from '../constants';
55
import { InvalidAuditDetailsError } from '../errors';

libs/common/src/constants/date-formats.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ export const DATE_FORMATS = {
88
DO_MMMM_YYYY: 'do MMMM yyyy',
99
D_MMMM_YYYY: 'd MMMM yyyy',
1010
H_MMAAA: 'H:mmaaa', // e.g 12:34am
11+
DD_MMM_YYYY: 'dd MMM yyyy', // e.g. '01 Feb 2024'
1112
};

libs/common/src/helpers/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ export * from './is-ukef-email';
2222
export * from './fee-record-corrections';
2323
export * from './decode-html-entities';
2424
export * from './map-currencies-to-radio-items';
25+
export * from './table-data-sort';
2526
export * from './utilisation-report-emails';
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getKeyToDateSortValueMap, GetKeyToDateSortValueMapItem } from './get-key-to-date-sort-value-map-helper';
1+
import { GetKeyToDateSortValueMapItem, getKeyToDateSortValueMap } from './get-key-to-date-sort-value-map-helper';
22

33
describe('get-key-to-currency-and-amount-sort-value-map-helper', () => {
44
describe('getKeyToCurrencyAndAmountSortValueMap', () => {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import orderBy from 'lodash.orderby';
1+
import { orderBy } from 'lodash';
22
import { parseISO } from 'date-fns';
3-
import { IsoDateTimeStamp } from '@ukef/dtfs2-common';
3+
import { IsoDateTimeStamp } from '../../types';
44

55
export type GetKeyToDateSortValueMapItem = {
66
date?: IsoDateTimeStamp;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './get-key-to-date-sort-value-map-helper';

package-lock.json

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

portal/api-tests/utilisation-report-routes.api-test.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,4 +171,44 @@ describe('utilisation-report routes', () => {
171171
});
172172
});
173173
});
174+
175+
describe('GET /utilisation-reports/correction-log', () => {
176+
const originalProcessEnv = { ...process.env };
177+
const url = '/utilisation-reports/correction-log';
178+
179+
describe('when FF_FEE_RECORD_CORRECTION_ENABLED is set to `true`', () => {
180+
beforeAll(() => {
181+
process.env.FF_FEE_RECORD_CORRECTION_ENABLED = 'true';
182+
});
183+
184+
afterAll(() => {
185+
process.env = { ...originalProcessEnv };
186+
});
187+
188+
withRoleValidationApiTests({
189+
makeRequestWithHeaders: (headers) => get(url, {}, headers),
190+
whitelistedRoles: [ROLES.PAYMENT_REPORT_OFFICER],
191+
successCode: HttpStatusCode.Ok,
192+
disableHappyPath: true,
193+
});
194+
});
195+
196+
describe('when FF_FEE_RECORD_CORRECTION_ENABLED is set to `false`', () => {
197+
beforeAll(() => {
198+
process.env.FF_FEE_RECORD_CORRECTION_ENABLED = 'false';
199+
});
200+
201+
afterAll(() => {
202+
process.env = { ...originalProcessEnv };
203+
});
204+
205+
it(`should redirect to "/not-found"`, async () => {
206+
// Act
207+
const response = await get(url);
208+
209+
// Assert
210+
expect(response.headers.location).toEqual('/not-found');
211+
});
212+
});
213+
});
174214
});

portal/component-tests/assertions.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ const assertions = (wrapper, html) => ({
8383
toHaveAttribute: (attribute, value) => {
8484
expect(wrapper(selector).attr(attribute)).toEqual(value);
8585
},
86+
notToHaveAttribute: (attribute) => {
87+
expect(wrapper(selector).attr(attribute)).toBeUndefined();
88+
},
8689
lengthToEqual: (expectedLength) => {
8790
const expected = expectedLength + 1; // cheerio html() assertion automatically adds 1.
8891
expect(wrapper(selector).html().length).toEqual(expected);

portal/component-tests/partials/primary-navigation.component-test.js

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ describe(page, () => {
1717

1818
itDoesNotRenderAUtilisationReportUploadLink();
1919
itDoesNotRenderAPreviousReportsLink();
20+
itDoesNotRenderARecordCorrectionLogLink();
2021
itDoesNotRenderAUsersLink();
2122
});
2223

@@ -30,6 +31,7 @@ describe(page, () => {
3031

3132
itDoesNotRenderAUtilisationReportUploadLink();
3233
itDoesNotRenderAPreviousReportsLink();
34+
itDoesNotRenderARecordCorrectionLogLink();
3335
itDoesNotRenderAUsersLink();
3436
});
3537

@@ -44,6 +46,7 @@ describe(page, () => {
4446

4547
itDoesNotRenderAUtilisationReportUploadLink();
4648
itDoesNotRenderAPreviousReportsLink();
49+
itDoesNotRenderARecordCorrectionLogLink();
4750
});
4851

4952
describe(`viewed by role '${ROLES.READ_ONLY}'`, () => {
@@ -56,16 +59,46 @@ describe(page, () => {
5659
itDoesNotRenderAReportsLink();
5760
itDoesNotRenderAUtilisationReportUploadLink();
5861
itDoesNotRenderAPreviousReportsLink();
62+
itDoesNotRenderARecordCorrectionLogLink();
5963
itDoesNotRenderAUsersLink();
6064
});
6165

62-
describe(`viewed by role '${ROLES.PAYMENT_REPORT_OFFICER}'`, () => {
66+
describe(`viewed by role '${ROLES.PAYMENT_REPORT_OFFICER}' and FF_FEE_RECORD_CORRECTION_ENABLED is set to "true"`, () => {
67+
const originalProcessEnv = { ...process.env };
68+
69+
beforeAll(() => {
70+
process.env.FF_FEE_RECORD_CORRECTION_ENABLED = 'true';
71+
wrapper = render({ user: { roles: [ROLES.PAYMENT_REPORT_OFFICER] } });
72+
});
73+
74+
afterAll(() => {
75+
process.env = originalProcessEnv;
76+
});
77+
78+
itRendersAUtilisationReportUploadLink();
79+
itRendersAPreviousReportsLink();
80+
itRendersARecordCorrectionLogLink();
81+
82+
itDoesNotRenderAHomeLink();
83+
itDoesNotRenderAReportsLink();
84+
itDoesNotRenderAUsersLink();
85+
});
86+
87+
describe(`viewed by role '${ROLES.PAYMENT_REPORT_OFFICER}' and FF_FEE_RECORD_CORRECTION_ENABLED is set to "false"`, () => {
88+
const originalProcessEnv = { ...process.env };
89+
6390
beforeAll(() => {
91+
process.env.FF_FEE_RECORD_CORRECTION_ENABLED = 'false';
6492
wrapper = render({ user: { roles: [ROLES.PAYMENT_REPORT_OFFICER] } });
6593
});
6694

95+
afterAll(() => {
96+
process.env = originalProcessEnv;
97+
});
98+
6799
itRendersAUtilisationReportUploadLink();
68100
itRendersAPreviousReportsLink();
101+
itDoesNotRenderARecordCorrectionLogLink();
69102

70103
itDoesNotRenderAHomeLink();
71104
itDoesNotRenderAReportsLink();
@@ -81,6 +114,7 @@ describe(page, () => {
81114
itDoesNotRenderAReportsLink();
82115
itDoesNotRenderAUtilisationReportUploadLink();
83116
itDoesNotRenderAPreviousReportsLink();
117+
itDoesNotRenderARecordCorrectionLogLink();
84118
itDoesNotRenderAUsersLink();
85119
});
86120

@@ -132,6 +166,18 @@ describe(page, () => {
132166
});
133167
}
134168

169+
function itRendersARecordCorrectionLogLink() {
170+
it('renders a record correction log link', () => {
171+
wrapper.expectLink('[data-cy="record_correction_log"]').toLinkTo('/utilisation-reports/correction-log', 'Record correction log');
172+
});
173+
}
174+
175+
function itDoesNotRenderARecordCorrectionLogLink() {
176+
it('does not render a record correction log link', () => {
177+
wrapper.expectLink('[data-cy="record_correction_log"]').notToExist();
178+
});
179+
}
180+
135181
function itRendersAUsersLink() {
136182
it('renders a users link', () => {
137183
wrapper.expectLink('[data-cy="users"]').toLinkTo('/admin/users', 'Users');

0 commit comments

Comments
 (0)