generated from hmcts/expressjs-template
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CIV-12317 Store "give evidence yourself" details (#4540)
* CIV-12317 Store "give evidence yourself" details * test fix * translate claimant fields * lint fix * test fix * test fix * sonar fix * sonar fix * sonar fix * lint fix * add test * fix test * point to service PR * point back to master * add test --------- Co-authored-by: Madhan Mahadevan <[email protected]> Co-authored-by: vasudevganesanhmcts <[email protected]>
- Loading branch information
1 parent
4c5ca49
commit 5419002
Showing
14 changed files
with
224 additions
and
5 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
src/main/common/models/ccdResponse/ccdEvidenceConfirmDetails.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export interface CCDEvidenceConfirmDetails { | ||
firstName: string, | ||
lastName: string, | ||
email?: string, | ||
phone?: string, | ||
jobTitle: string, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/main/services/translation/convertToCUI/convertToCUIEvidenceConfirmDetails.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import {CCDClaim} from 'models/civilClaimResponse'; | ||
import {ConfirmYourDetailsEvidence} from 'form/models/confirmYourDetailsEvidence'; | ||
|
||
export const convertToCUIEvidenceConfirmDetails = (ccdClaim: CCDClaim) : ConfirmYourDetailsEvidence => { | ||
if (ccdClaim) { | ||
const confirmDetails: ConfirmYourDetailsEvidence = new ConfirmYourDetailsEvidence(); | ||
if (ccdClaim.respondent1LiPResponse?.respondent1DQEvidenceConfirmDetails?.firstName) { | ||
confirmDetails.firstName = ccdClaim.respondent1LiPResponse.respondent1DQEvidenceConfirmDetails.firstName; | ||
confirmDetails.lastName = ccdClaim.respondent1LiPResponse.respondent1DQEvidenceConfirmDetails.lastName; | ||
confirmDetails.emailAddress = ccdClaim.respondent1LiPResponse.respondent1DQEvidenceConfirmDetails.email; | ||
confirmDetails.phoneNumber = ccdClaim.respondent1LiPResponse.respondent1DQEvidenceConfirmDetails.phone ? Number(ccdClaim.respondent1LiPResponse.respondent1DQEvidenceConfirmDetails.phone) : undefined; | ||
confirmDetails.jobTitle = ccdClaim.respondent1LiPResponse.respondent1DQEvidenceConfirmDetails.jobTitle; | ||
} | ||
return confirmDetails; | ||
} | ||
}; |
13 changes: 13 additions & 0 deletions
13
src/main/services/translation/response/convertToCCDEvidenceConfirmDetails.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import {ConfirmYourDetailsEvidence} from 'form/models/confirmYourDetailsEvidence'; | ||
|
||
export const convertToCCDEvidenceConfirmDetails = (confirmDetails: ConfirmYourDetailsEvidence) => { | ||
if (confirmDetails?.firstName) { | ||
return { | ||
firstName: confirmDetails.firstName, | ||
lastName: confirmDetails.lastName, | ||
email: confirmDetails.emailAddress, | ||
phone: confirmDetails.phoneNumber?.toString(), | ||
jobTitle: confirmDetails.jobTitle, | ||
}; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ import {TypeOfDisclosureDocument} from 'models/directionsQuestionnaire/hearing/d | |
import { | ||
HasAnAgreementBeenReachedOptions, | ||
} from 'models/directionsQuestionnaire/mintiMultitrack/hasAnAgreementBeenReachedOptions'; | ||
import {ConfirmYourDetailsEvidence} from 'form/models/confirmYourDetailsEvidence'; | ||
|
||
describe('translate CCDDQ to CUI DQ model', () => { | ||
it('should return undefined if ccdClaim doesnt exist', () => { | ||
|
@@ -39,11 +40,26 @@ describe('translate CCDDQ to CUI DQ model', () => { | |
respondent1DQExtraDetails: { | ||
giveEvidenceYourSelf: YesNoUpperCamelCase.YES, | ||
}, | ||
respondent1DQEvidenceConfirmDetails : { | ||
firstName: 'Gordon', | ||
lastName: 'Ramsay', | ||
email: '[email protected]', | ||
phone: '7788994455', | ||
jobTitle: 'Chef', | ||
}, | ||
}, | ||
}; | ||
|
||
const confirmDetails: ConfirmYourDetailsEvidence = new ConfirmYourDetailsEvidence(); | ||
confirmDetails.firstName = 'Gordon'; | ||
confirmDetails.lastName = 'Ramsay'; | ||
confirmDetails.emailAddress = '[email protected]'; | ||
confirmDetails.phoneNumber = 7788994455; | ||
confirmDetails.jobTitle = 'Chef'; | ||
|
||
//When | ||
const output = toCUIDQs(input); | ||
const expected : DirectionQuestionnaire = new DirectionQuestionnaire(new GenericYesNo(YesNo.YES), new Hearing(), undefined, new Experts()); | ||
const expected : DirectionQuestionnaire = new DirectionQuestionnaire(new GenericYesNo(YesNo.YES), new Hearing(), undefined, new Experts(), undefined, undefined, confirmDetails); | ||
//Then | ||
expect(output).toEqual(expected); | ||
}); | ||
|
73 changes: 73 additions & 0 deletions
73
src/test/unit/services/translation/convertToCUI/convertToCUIEvidenceConfirmDetails.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import {convertToCUIEvidenceConfirmDetails} from 'services/translation/convertToCUI/convertToCUIEvidenceConfirmDetails'; | ||
import {CCDClaim} from 'models/civilClaimResponse'; | ||
import {ConfirmYourDetailsEvidence} from 'form/models/confirmYourDetailsEvidence'; | ||
|
||
describe('translate CCD data to CUI DQ Evidence confirm details', () => { | ||
it('should return undefined when no lip response', () => { | ||
// Given | ||
const ccdClaim: CCDClaim = {}; | ||
|
||
const expected: ConfirmYourDetailsEvidence = { | ||
firstName: undefined, | ||
lastName: undefined, | ||
phoneNumber: undefined, | ||
emailAddress: undefined, | ||
jobTitle: undefined, | ||
}; | ||
|
||
// When | ||
const result = convertToCUIEvidenceConfirmDetails(ccdClaim); | ||
// Then | ||
expect(result).toEqual(expected); | ||
}); | ||
|
||
it('should return undefined', () => { | ||
// Given | ||
const ccdClaim: CCDClaim = { | ||
respondent1LiPResponse: { | ||
respondent1LiPContactPerson: 'a', | ||
}, | ||
}; | ||
|
||
const expected: ConfirmYourDetailsEvidence = { | ||
firstName: undefined, | ||
lastName: undefined, | ||
phoneNumber: undefined, | ||
emailAddress: undefined, | ||
jobTitle: undefined, | ||
}; | ||
|
||
// When | ||
const result = convertToCUIEvidenceConfirmDetails(ccdClaim); | ||
// Then | ||
expect(result).toEqual(expected); | ||
}); | ||
|
||
it('should translate CCD data when values exist', () => { | ||
// Given | ||
const ccdClaim: CCDClaim = { | ||
respondent1LiPResponse: { | ||
respondent1DQEvidenceConfirmDetails: { | ||
firstName: 'Ant', | ||
lastName: 'Pant', | ||
phone: '778899456', | ||
email: '[email protected]', | ||
jobTitle: 'Chant', | ||
}, | ||
}, | ||
}; | ||
|
||
const expected: ConfirmYourDetailsEvidence = { | ||
firstName: 'Ant', | ||
lastName: 'Pant', | ||
phoneNumber: 778899456, | ||
emailAddress: '[email protected]', | ||
jobTitle: 'Chant', | ||
}; | ||
|
||
// When | ||
const result = convertToCUIEvidenceConfirmDetails(ccdClaim); | ||
// Then | ||
expect(result).toMatchObject(expected); | ||
}); | ||
}); |
62 changes: 62 additions & 0 deletions
62
src/test/unit/services/translation/response/convertToCCDEvidenceConfirmDetails.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import {Claim} from 'models/claim'; | ||
import {DirectionQuestionnaire} from 'models/directionsQuestionnaire/directionQuestionnaire'; | ||
import {convertToCCDEvidenceConfirmDetails} from 'services/translation/response/convertToCCDEvidenceConfirmDetails'; | ||
import {CCDEvidenceConfirmDetails} from 'models/ccdResponse/ccdEvidenceConfirmDetails'; | ||
|
||
describe('translate DQ confirm details for evidence CCD model', () => { | ||
const claim = new Claim(); | ||
claim.directionQuestionnaire = new DirectionQuestionnaire(); | ||
|
||
it('should return undefined if data doesnt exist', () => { | ||
//When | ||
const dqExtraDetails = convertToCCDEvidenceConfirmDetails(claim.directionQuestionnaire.confirmYourDetailsEvidence); | ||
//then | ||
expect(dqExtraDetails).toEqual(undefined); | ||
}); | ||
|
||
it('should return values if data exist',() => { | ||
//given | ||
claim.directionQuestionnaire.confirmYourDetailsEvidence = { | ||
firstName: 'Ted', | ||
lastName: 'Ned', | ||
phoneNumber: 7788445566, | ||
emailAddress: '[email protected]', | ||
jobTitle: 'Person', | ||
}; | ||
|
||
const expected: CCDEvidenceConfirmDetails = { | ||
firstName: 'Ted', | ||
lastName: 'Ned', | ||
phone: '7788445566', | ||
email: '[email protected]', | ||
jobTitle: 'Person', | ||
}; | ||
|
||
//When | ||
const actual = convertToCCDEvidenceConfirmDetails(claim.directionQuestionnaire.confirmYourDetailsEvidence); | ||
//then | ||
expect(actual).toEqual(expected); | ||
}); | ||
|
||
it('should return values if data exist - no phone number',() => { | ||
//given | ||
claim.directionQuestionnaire.confirmYourDetailsEvidence = { | ||
firstName: 'Ted', | ||
lastName: 'Ned', | ||
emailAddress: '[email protected]', | ||
jobTitle: 'Person', | ||
}; | ||
|
||
const expected: CCDEvidenceConfirmDetails = { | ||
firstName: 'Ted', | ||
lastName: 'Ned', | ||
email: '[email protected]', | ||
jobTitle: 'Person', | ||
}; | ||
|
||
//When | ||
const actual = convertToCCDEvidenceConfirmDetails(claim.directionQuestionnaire.confirmYourDetailsEvidence); | ||
//then | ||
expect(actual).toEqual(expected); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,9 @@ import {TimelineRow} from 'form/models/timeLineOfEvents/timelineRow'; | |
import {YesNo} from 'common/form/models/yesNo'; | ||
import {ClaimDetails} from 'common/form/models/claim/details/claimDetails'; | ||
import {HelpWithFees} from 'common/form/models/claim/details/helpWithFees'; | ||
import {DirectionQuestionnaire} from 'models/directionsQuestionnaire/directionQuestionnaire'; | ||
import {ConfirmYourDetailsEvidence} from 'form/models/confirmYourDetailsEvidence'; | ||
import {CCDEvidenceConfirmDetails} from 'models/ccdResponse/ccdEvidenceConfirmDetails'; | ||
|
||
const setUpUndefinedDQExtraDetails = () : CCDDQExtraDetails => { | ||
return { | ||
|
@@ -66,6 +69,14 @@ const addressCCD: CCDAddress = { | |
PostTown: 'london', | ||
}; | ||
|
||
const evidenceConfirmDetails: CCDEvidenceConfirmDetails = { | ||
firstName: 'John', | ||
lastName: 'Doe', | ||
email: '[email protected]', | ||
phone: '600000000', | ||
jobTitle: 'Doctor', | ||
}; | ||
|
||
describe('translate cui fields to CCD model', () => { | ||
it('should return undefined if it is undefined', () => { | ||
//Given | ||
|
@@ -82,12 +93,16 @@ describe('translate cui fields to CCD model', () => { | |
input.respondent1.partyDetails.contactPerson = 'Example contactPerson'; | ||
input.respondent1.partyDetails.postToThisAddress = 'yes'; | ||
input.respondent1.partyDetails.correspondenceAddress = new Address('line 1', 'line 2', 'line 3', 'london', 'SW1A 2AA' ); | ||
input.directionQuestionnaire = new DirectionQuestionnaire(); | ||
input.directionQuestionnaire.confirmYourDetailsEvidence = new ConfirmYourDetailsEvidence('John', 'Doe', | ||
'[email protected]', 600000000, 'Doctor'); | ||
|
||
const expected : CCDRespondentLiPResponse = { | ||
respondent1MediationLiPResponse: undefined, | ||
respondent1DQHearingSupportLip: setUpUndefinedDQHearingSupport(), | ||
respondent1DQExtraDetails: setUpUndefinedDQExtraDetails(), | ||
respondent1LiPContactPerson: 'Example contactPerson', | ||
respondent1DQEvidenceConfirmDetails: evidenceConfirmDetails, | ||
respondent1LiPCorrespondenceAddress: addressCCD, | ||
}; | ||
//When | ||
|