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

DTSCCI-313 check defendant is linked for civil claims #4224

Merged
merged 54 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
4e60ad6
check if defendant is linked for civil claim.
velimd Jul 11, 2024
0712a03
Merge branch 'master' into DTSCCI-313
velimd Jul 11, 2024
0c1e3be
update implementation to check if defendant linked for civil claims
velimd Jul 18, 2024
3ca3c83
point to BE PR.
velimd Jul 18, 2024
eeecf5a
clean up + test
velimd Jul 19, 2024
1864d7d
Merge branch 'master' into DTSCCI-313
velimd Jul 19, 2024
0dec6df
Merge branch 'master' into DTSCCI-313
velimd Jul 22, 2024
0066a45
Merge branch 'master' into DTSCCI-313
mfallonhmcts Jul 24, 2024
d2d8aa5
Merge branch 'master' into DTSCCI-313
mfallonhmcts Jul 25, 2024
fb8c550
Update values.preview.template.yaml
mfallonhmcts Jul 25, 2024
bc32bcd
Merge branch 'master' into DTSCCI-313
mfallonhmcts Jul 25, 2024
3cc6671
Merge branch 'master' into DTSCCI-313
mfallonhmcts Jul 26, 2024
85d155d
Merge branch 'master' into DTSCCI-313
mfallonhmcts Jul 29, 2024
bbc2126
Update values.preview.template.yaml
mfallonhmcts Jul 29, 2024
a7a4784
Merge branch 'master' into DTSCCI-313
mfallonhmcts Jul 29, 2024
c0c1108
Merge branch 'master' into DTSCCI-313
mfallonhmcts Jul 30, 2024
60023cb
Merge branch 'master' into DTSCCI-313
mfallonhmcts Aug 1, 2024
a9e21ee
Merge branch 'master' into DTSCCI-313
mfallonhmcts Aug 2, 2024
a58190b
Merge branch 'master' into DTSCCI-313
mfallonhmcts Aug 8, 2024
b3df40b
Merge branch 'master' into DTSCCI-313
mfallonhmcts Aug 8, 2024
84d55cb
Merge branch 'master' into DTSCCI-313
mfallonhmcts Aug 9, 2024
c71a949
Update steps.js
mfallonhmcts Aug 9, 2024
24acc33
Update login.js
mfallonhmcts Aug 9, 2024
1bc9259
Merge branch 'master' into DTSCCI-313
mfallonhmcts Aug 9, 2024
4ff7125
Merge branch 'master' into DTSCCI-313
mfallonhmcts Aug 9, 2024
02c2cbc
Update steps.js
mfallonhmcts Aug 9, 2024
3d4e022
editing tests to allow PIP assignment through UI
mfallonhmcts Aug 9, 2024
afe0603
Merge branch 'master' into DTSCCI-313
mfallonhmcts Aug 9, 2024
0248878
getting rid of open citizen login method
mfallonhmcts Aug 9, 2024
3b1402f
Merge branch 'master' into DTSCCI-313
mfallonhmcts Aug 9, 2024
50e19c7
Update login.js
mfallonhmcts Aug 9, 2024
d4840c9
Update login.js
mfallonhmcts Aug 9, 2024
2fd3b8e
getting rid of this test I accidentally re-committed
mfallonhmcts Aug 9, 2024
976e813
reverting all my changes to try and get this PR to build again
mfallonhmcts Aug 12, 2024
6e8888f
Merge branch 'master' into DTSCCI-313
mfallonhmcts Aug 12, 2024
04e1d6f
recommitting all my changes
mfallonhmcts Aug 12, 2024
28f607b
removing unused cuiCookies variable
mfallonhmcts Aug 12, 2024
a761f36
reinstating openCitizenLogin method
mfallonhmcts Aug 12, 2024
719d342
Update login.js
mfallonhmcts Aug 13, 2024
5f92d63
Merge branch 'master' into DTSCCI-313
mfallonhmcts Aug 13, 2024
da5325a
Reinstating CUI and IDAM cookies
mfallonhmcts Aug 13, 2024
d3c1f33
Update citizenDashboard.js
mfallonhmcts Aug 13, 2024
bc3b20e
Update citizenDashboard.js
mfallonhmcts Aug 13, 2024
bcce227
Merge branch 'master' into DTSCCI-313
mfallonhmcts Aug 13, 2024
ec1908f
Merge branch 'master' into DTSCCI-313
mfallonhmcts Aug 14, 2024
e98ff53
Merge branch 'master' into DTSCCI-313
mfallonhmcts Aug 14, 2024
48d9c58
Making it so that only one test runs manual PIP, and removing unneces…
mfallonhmcts Aug 14, 2024
d924702
swapping wait removals
mfallonhmcts Aug 14, 2024
5bfe9b4
Deleting this test file which was not meant to be committed
mfallonhmcts Aug 15, 2024
85a8a05
Removing point to civil-service PR
mfallonhmcts Aug 15, 2024
3219d41
Merge branch 'master' into DTSCCI-313
mfallonhmcts Aug 15, 2024
f38f5ff
Merge branch 'master' into DTSCCI-313
mfallonhmcts Aug 16, 2024
e254acb
Merge branch 'master' into DTSCCI-313
mfallonhmcts Aug 16, 2024
4e97ff3
Merge branch 'master' into DTSCCI-313
mfallonhmcts Aug 19, 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
11 changes: 6 additions & 5 deletions src/main/app/client/civilServiceClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
CIVIL_SERVICE_AGREED_RESPONSE_DEADLINE_DATE,
CIVIL_SERVICE_CALCULATE_DEADLINE,
CIVIL_SERVICE_CASES_URL,
CIVIL_SERVICE_CHECK_OCMC_DEFENDENT_LINKED_URL,
CIVIL_SERVICE_CHECK_DEFENDENT_LINKED_URL,
CIVIL_SERVICE_CLAIM_AMOUNT_URL,
CIVIL_SERVICE_AIRLINES_URL,
CIVIL_SERVICE_COURT_DECISION,
Expand Down Expand Up @@ -58,6 +58,7 @@ import {DashboardNotification} from 'models/dashboard/dashboardNotification';
import {TaskStatusColor} from 'models/dashboard/taskList/dashboardTaskStatus';
import { GAFeeRequestBody } from 'services/features/generalApplication/feeDetailsService';
import {CCDGeneralApplication} from 'models/gaEvents/eventDto';
import {DefendantLinkStatus} from 'models/DefendantLinkStatus';

const {Logger} = require('@hmcts/nodejs-logging');
const logger = Logger.getLogger('civilServiceClient');
Expand Down Expand Up @@ -248,14 +249,14 @@ export class CivilServiceClient {
}
}

async isOcmcDefendantLinked(caseReference: string): Promise<boolean> {
async isDefendantLinked(caseReference: string): Promise<DefendantLinkStatus> {
try {
const response = await this.client.get(CIVIL_SERVICE_CHECK_OCMC_DEFENDENT_LINKED_URL //nosonar
const response = await this.client.get(CIVIL_SERVICE_CHECK_DEFENDENT_LINKED_URL //nosonar
.replace(':caseReference', caseReference), {headers: {'Content-Type': 'application/json'}});// no-sonar
if (!response.data) {
return false;
return new DefendantLinkStatus(false, false);
}
return response.data as boolean;
return response.data as DefendantLinkStatus;
} catch (err: unknown) {
logger.error(`Error when checking a claim ${caseReference} is linked to a defendant`);
throw err;
Expand Down
2 changes: 1 addition & 1 deletion src/main/app/client/civilServiceUrls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const CIVIL_SERVICE_AGREED_RESPONSE_DEADLINE_DATE =`${CIVIL_SERVICE_CASES
export const CIVIL_SERVICE_USER_CASE_ROLE = `${CIVIL_SERVICE_CASES_URL}:claimId/userCaseRoles`;
export const CIVIL_SERVICE_COURT_DECISION = `${CIVIL_SERVICE_CASES_URL}:claimId/courtDecision`;
export const CIVIL_SERVICE_VALIDATE_OCMC_PIN_URL = `${CIVIL_SERVICE_ASSIGNMENT_URL}/reference/:caseReference/ocmc`;
export const CIVIL_SERVICE_CHECK_OCMC_DEFENDENT_LINKED_URL = `${CIVIL_SERVICE_ASSIGNMENT_URL}/reference/:caseReference/ocmc`;
export const CIVIL_SERVICE_CHECK_DEFENDENT_LINKED_URL = `${CIVIL_SERVICE_ASSIGNMENT_URL}/reference/:caseReference/defendant-link-status`;
export const CIVIL_SERVICE_FEES_PAYMENT_URL= `${CIVIL_SERVICE_FEES_URL}/:feeType/case/:claimId/payment`;
export const CIVIL_SERVICE_FEES_PAYMENT_STATUS_URL= `${CIVIL_SERVICE_FEES_URL}/:feeType/case/:claimId/payment/:paymentReference/status`;
export const CIVIL_SERVICE_DASHBOARD_TASKLIST_URL= `${CIVIL_SERVICE_DASHBOARD_URL}/taskList/:ccd-case-identifier/role/:role-type`;
Expand Down
9 changes: 9 additions & 0 deletions src/main/common/models/DefendantLinkStatus.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export class DefendantLinkStatus {
isOcmcCase: boolean;
linked: boolean;

constructor(isOcmcCase: boolean, linked: boolean) {
this.isOcmcCase = isOcmcCase;
this.linked = linked;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ claimReferenceController.post(FIRST_CONTACT_CLAIM_REFERENCE_URL, (async (req: Re
} else {
try {
req.session = saveFirstContactData(req.session as AppSession, {claimReference: req.body.claimReferenceValue});
if (req.body.claimReferenceValue?.includes('MC') && await civilServiceClient.isOcmcDefendantLinked(req.body.claimReferenceValue)) {
res.redirect(ocmcBaseUrl + DASHBOARD_URL);
} else {
res.redirect(FIRST_CONTACT_PIN_URL);
if (req.body.claimReferenceValue?.includes('MC')) {
const results = await civilServiceClient.isDefendantLinked(req.body.claimReferenceValue);
if (results.linked) {
return res.redirect((results.isOcmcCase ? ocmcBaseUrl : '') + DASHBOARD_URL);
}
}
return res.redirect(FIRST_CONTACT_PIN_URL);
} catch (error) {
next(error);
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/unit/app/client/civilServiceClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1260,14 +1260,14 @@ describe('Civil Service Client', () => {
});

describe('Throw errors', ()=> {
it('should throw error isOcmcDefendantLinked ', async () => {
it('should throw error isDefendantLinked ', async () => {
const mockGet = jest.fn().mockImplementation(() => {
throw new Error('error');
});
mockedAxios.create.mockReturnValueOnce({get: mockGet} as unknown as AxiosInstance);
const civilServiceClient = new CivilServiceClient(baseUrl);
//Then
await expect(civilServiceClient.isOcmcDefendantLinked('123')).rejects.toThrow('error');
await expect(civilServiceClient.isDefendantLinked('123')).rejects.toThrow('error');
});
it('should throw error getFeeRanges ', async () => {
const mockGet = jest.fn().mockImplementation(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Session } from 'express-session';
import { AppSession } from 'common/models/AppRequest';
import nock from 'nock';
import config from 'config';
import {DefendantLinkStatus} from 'models/DefendantLinkStatus';

jest.mock('../../../../../../main/modules/oidc');
jest.mock('../../../../../../main/modules/draft-store');
Expand Down Expand Up @@ -68,8 +69,8 @@ describe('Respond to Claim - Claim Reference Controller', () => {
it('should redirect and set cookie value for OCMC case when case ia already linked', async () => {
app.request.cookies = {firstContact: {foo: 'blah'}};
nock(civilServiceUrl)
.get('/assignment/reference/' + validClaimNumberV1 + '/ocmc')
.reply(200, 'true');
.get('/assignment/reference/' + validClaimNumberV1 + '/defendant-link-status')
.reply(200, new DefendantLinkStatus(true, true));
await request(app).post(FIRST_CONTACT_CLAIM_REFERENCE_URL).send({claimReferenceValue: validClaimNumberV1}).expect((res) => {
expect(res.status).toBe(302);
expect(res.header.location).toBe(ocmcBaseUrl + DASHBOARD_URL);
Expand All @@ -80,8 +81,32 @@ describe('Respond to Claim - Claim Reference Controller', () => {
it('should redirect and set cookie value for OCMC case when case ia not linked', async () => {
app.request.cookies = {firstContact: {foo: 'blah'}};
nock(civilServiceUrl)
.get('/assignment/reference/' + validClaimNumberV1 + '/ocmc')
.reply(200, 'false');
.get('/assignment/reference/' + validClaimNumberV1 + '/defendant-link-status')
.reply(200, new DefendantLinkStatus(true, false));
await request(app).post(FIRST_CONTACT_CLAIM_REFERENCE_URL).send({claimReferenceValue: validClaimNumberV1}).expect((res) => {
expect(res.status).toBe(302);
expect(res.header.location).toBe(FIRST_CONTACT_PIN_URL);
expect((app.request.session as AppSession).firstContact.claimReference).toBe(validClaimNumberV1);
});
});

it('should redirect and set cookie value for Civil case when case ia already linked', async () => {
app.request.cookies = {firstContact: {foo: 'blah'}};
nock(civilServiceUrl)
.get('/assignment/reference/' + validClaimNumberV1 + '/defendant-link-status')
.reply(200, new DefendantLinkStatus(false, true));
await request(app).post(FIRST_CONTACT_CLAIM_REFERENCE_URL).send({claimReferenceValue: validClaimNumberV1}).expect((res) => {
expect(res.status).toBe(302);
expect(res.header.location).toBe(DASHBOARD_URL);
expect((app.request.session as AppSession).firstContact.claimReference).toBe(validClaimNumberV1);
});
});

it('should redirect and set cookie value for Civil case when case ia not linked', async () => {
app.request.cookies = {firstContact: {foo: 'blah'}};
nock(civilServiceUrl)
.get('/assignment/reference/' + validClaimNumberV1 + '/defendant-link-status')
.reply(200, new DefendantLinkStatus(false, false));
await request(app).post(FIRST_CONTACT_CLAIM_REFERENCE_URL).send({claimReferenceValue: validClaimNumberV1}).expect((res) => {
expect(res.status).toBe(302);
expect(res.header.location).toBe(FIRST_CONTACT_PIN_URL);
Expand Down
Loading