diff --git a/src/main/common/models/ccdResponse/ccdEvidenceConfirmDetails.ts b/src/main/common/models/ccdResponse/ccdEvidenceConfirmDetails.ts new file mode 100644 index 00000000000..abd890fd016 --- /dev/null +++ b/src/main/common/models/ccdResponse/ccdEvidenceConfirmDetails.ts @@ -0,0 +1,7 @@ +export interface CCDEvidenceConfirmDetails { + firstName: string, + lastName: string, + email?: string, + phone?: string, + jobTitle: string, +} diff --git a/src/main/common/models/ccdResponse/ccdRespondentLiPResponse.ts b/src/main/common/models/ccdResponse/ccdRespondentLiPResponse.ts index fb980b0935c..8835a106487 100644 --- a/src/main/common/models/ccdResponse/ccdRespondentLiPResponse.ts +++ b/src/main/common/models/ccdResponse/ccdRespondentLiPResponse.ts @@ -2,6 +2,7 @@ import {CCDMediation} from 'models/ccdResponse/ccdMediation'; import {CCDDQExtraDetails} from 'models/ccdResponse/ccdDQExtraDetails'; import {CCDHearingSupport} from 'models/ccdResponse/ccdHearingSupport'; import {CCDAddress} from 'models/ccdResponse/ccdAddress'; +import {CCDEvidenceConfirmDetails} from 'models/ccdResponse/ccdEvidenceConfirmDetails'; export interface CCDRespondentLiPResponse { timelineComment?: string; @@ -12,6 +13,7 @@ export interface CCDRespondentLiPResponse { respondent1LiPContactPerson?: string, respondent1LiPCorrespondenceAddress?: CCDAddress, respondent1ResponseLanguage?: CCDRespondentResponseLanguage; + respondent1DQEvidenceConfirmDetails?: CCDEvidenceConfirmDetails; } export enum CCDRespondentResponseLanguage { diff --git a/src/main/common/models/civilClaimResponse.ts b/src/main/common/models/civilClaimResponse.ts index b7ef9193a61..31e15ddfed1 100644 --- a/src/main/common/models/civilClaimResponse.ts +++ b/src/main/common/models/civilClaimResponse.ts @@ -88,6 +88,7 @@ import {CCDDisclosureOfElectronicDocuments} from 'models/ccdResponse/ccdDisclosu import {CCDDisclosureOfNonElectronicDocuments} from 'models/ccdResponse/ccdDisclosureOfNonElectronicDocuments'; import {CCDDocumentsToBeConsidered} from 'models/ccdResponse/ccdDocumentsToBeConsidered'; import {CCDGeneralApplication} from 'models/gaEvents/eventDto'; +import {CCDEvidenceConfirmDetails} from 'models/ccdResponse/ccdEvidenceConfirmDetails'; export class CivilClaimResponse { id: string; @@ -200,6 +201,7 @@ export interface CCDClaim extends ClaimUpdate { specRespondent1DQDisclosureOfElectronicDocuments?: CCDDisclosureOfElectronicDocuments; specRespondent1DQDisclosureOfNonElectronicDocuments?: CCDDisclosureOfNonElectronicDocuments; respondent1DQClaimantDocumentsToBeConsidered?: CCDDocumentsToBeConsidered; + respondent1DQEvidenceConfirmDetails?: CCDEvidenceConfirmDetails; sdoOrderDocument?: CaseDocument; respondToClaim?: CCDRespondToClaim; defenceRouteRequired?: string; diff --git a/src/main/services/features/directionsQuestionnaire/directionQuestionnaireService.ts b/src/main/services/features/directionsQuestionnaire/directionQuestionnaireService.ts index 3c2101e4def..18daa4a8708 100644 --- a/src/main/services/features/directionsQuestionnaire/directionQuestionnaireService.ts +++ b/src/main/services/features/directionsQuestionnaire/directionQuestionnaireService.ts @@ -90,7 +90,12 @@ const saveDirectionQuestionnaire = async (claimId: string, value: any, direction const getConfirmYourDetailsEvidence = async (claimId: string, directionQuestionnairePropertyName: string, parentPropertyName?: string): Promise => { try { const claim = await getCaseDataFromStore(claimId); - const directionQuestionnaire: any = claim?.directionQuestionnaire ? claim.directionQuestionnaire : new DirectionQuestionnaire(); + let directionQuestionnaire: any; + if (claim.isClaimantIntentionPending()) { + directionQuestionnaire = claim.claimantResponse?.directionQuestionnaire ? claim.claimantResponse.directionQuestionnaire : new DirectionQuestionnaire(); + } else { + directionQuestionnaire = claim?.directionQuestionnaire ? claim.directionQuestionnaire : new DirectionQuestionnaire(); + } if (parentPropertyName && directionQuestionnaire[parentPropertyName] && directionQuestionnaire[parentPropertyName][directionQuestionnairePropertyName]) { return directionQuestionnaire[parentPropertyName][directionQuestionnairePropertyName]; } else if (!parentPropertyName && directionQuestionnaire[directionQuestionnairePropertyName]) { diff --git a/src/main/services/translation/claimantResponse/convertToCCDClaimantLiPResponse.ts b/src/main/services/translation/claimantResponse/convertToCCDClaimantLiPResponse.ts index 1686d6ab6ca..2f7984d075a 100644 --- a/src/main/services/translation/claimantResponse/convertToCCDClaimantLiPResponse.ts +++ b/src/main/services/translation/claimantResponse/convertToCCDClaimantLiPResponse.ts @@ -9,6 +9,8 @@ import {ChooseHowProceed} from 'common/models/chooseHowProceed'; import {CourtProposedDateOptions} from 'common/form/models/claimantResponse/courtProposedDate'; import { CourtProposedPlanOptions } from 'common/form/models/claimantResponse/courtProposedPlan'; import {RepaymentDecisionType} from 'models/claimantResponse/RepaymentDecisionType'; +import {convertToCCDEvidenceConfirmDetails} from 'services/translation/response/convertToCCDEvidenceConfirmDetails'; +import {CCDEvidenceConfirmDetails} from 'models/ccdResponse/ccdEvidenceConfirmDetails'; export enum CCDChoosesHowToProceed { SIGN_A_SETTLEMENT_AGREEMENT = 'SIGN_A_SETTLEMENT_AGREEMENT', @@ -24,6 +26,7 @@ export interface CCDClaimantLiPResponse { claimantCourtDecision?: RepaymentDecisionType, applicant1RejectedRepaymentReason?: string, applicant1SuggestedImmediatePaymentDeadLine?: Date, + applicant1DQEvidenceConfirmDetails?: CCDEvidenceConfirmDetails, } const toChoosesHowToProceed = { @@ -41,5 +44,6 @@ export const toCCDClaimantLiPResponse = (claimantResponse: ClaimantResponse): CC claimantCourtDecision: claimantResponse?.courtDecision ? claimantResponse?.courtDecision : undefined, applicant1RejectedRepaymentReason: claimantResponse?.rejectionReason?.text, applicant1SuggestedImmediatePaymentDeadLine: claimantResponse?.suggestedImmediatePaymentDeadLine, + applicant1DQEvidenceConfirmDetails: convertToCCDEvidenceConfirmDetails(claimantResponse?.directionQuestionnaire?.confirmYourDetailsEvidence), }; }; diff --git a/src/main/services/translation/convertToCUI/convertToCUIDQs.ts b/src/main/services/translation/convertToCUI/convertToCUIDQs.ts index d803db41db1..d27ddc241a4 100644 --- a/src/main/services/translation/convertToCUI/convertToCUIDQs.ts +++ b/src/main/services/translation/convertToCUI/convertToCUIDQs.ts @@ -8,6 +8,7 @@ import {toCUIWitnesses} from 'services/translation/convertToCUI/convertToCUIWitn import {toCUIGenericYesNo} from 'services/translation/convertToCUI/convertToCUIYesNo'; import {toCUIExperts} from './convertToCUIExperts'; import {toCUIFixedRecoverableCosts} from 'services/translation/convertToCUI/convertToCUIFixedRecoverableCosts'; +import {convertToCUIEvidenceConfirmDetails} from 'services/translation/convertToCUI/convertToCUIEvidenceConfirmDetails'; export const toCUIDQs = (ccdClaim: CCDClaim): DirectionQuestionnaire => { if (ccdClaim) { @@ -18,6 +19,7 @@ export const toCUIDQs = (ccdClaim: CCDClaim): DirectionQuestionnaire => { dq.witnesses = toCUIWitnesses(ccdClaim.respondent1DQWitnesses); dq.defendantYourselfEvidence = toCUIGenericYesNo(ccdClaim.respondent1LiPResponse?.respondent1DQExtraDetails?.giveEvidenceYourSelf); dq.experts = toCUIExperts(ccdClaim); + dq.confirmYourDetailsEvidence = convertToCUIEvidenceConfirmDetails(ccdClaim); dq.fixedRecoverableCosts = toCUIFixedRecoverableCosts(ccdClaim); return dq; } diff --git a/src/main/services/translation/convertToCUI/convertToCUIEvidenceConfirmDetails.ts b/src/main/services/translation/convertToCUI/convertToCUIEvidenceConfirmDetails.ts new file mode 100644 index 00000000000..7c5d1ab40ae --- /dev/null +++ b/src/main/services/translation/convertToCUI/convertToCUIEvidenceConfirmDetails.ts @@ -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; + } +}; diff --git a/src/main/services/translation/response/convertToCCDEvidenceConfirmDetails.ts b/src/main/services/translation/response/convertToCCDEvidenceConfirmDetails.ts new file mode 100644 index 00000000000..4ec6d6c71de --- /dev/null +++ b/src/main/services/translation/response/convertToCCDEvidenceConfirmDetails.ts @@ -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, + }; + } +}; diff --git a/src/main/services/translation/response/convertToCCDRespondentLiPResponse.ts b/src/main/services/translation/response/convertToCCDRespondentLiPResponse.ts index de1a32a0784..9db1f793587 100644 --- a/src/main/services/translation/response/convertToCCDRespondentLiPResponse.ts +++ b/src/main/services/translation/response/convertToCCDRespondentLiPResponse.ts @@ -6,6 +6,7 @@ import {CCDRespondentLiPResponse, CCDRespondentResponseLanguage} from 'models/cc import {toCCDAddress} from 'services/translation/response/convertToCCDAddress'; import {YesNo} from 'form/models/yesNo'; import {ClaimBilingualLanguagePreference} from 'models/claimBilingualLanguagePreference'; +import {convertToCCDEvidenceConfirmDetails} from 'services/translation/response/convertToCCDEvidenceConfirmDetails'; export const toCCDRespondentLiPResponse = (claim: Claim): CCDRespondentLiPResponse => { return { @@ -19,6 +20,7 @@ export const toCCDRespondentLiPResponse = (claim: Claim): CCDRespondentLiPRespon respondent1LiPContactPerson: claim.respondent1?.partyDetails?.contactPerson, respondent1LiPCorrespondenceAddress: claim.respondent1?.partyDetails?.postToThisAddress === YesNo.YES ? toCCDAddress(claim.respondent1?.partyDetails?.correspondenceAddress) : undefined, respondent1ResponseLanguage: toCCDRespondentResponseLanguage(claim.claimBilingualLanguagePreference), + respondent1DQEvidenceConfirmDetails: convertToCCDEvidenceConfirmDetails(claim.directionQuestionnaire?.confirmYourDetailsEvidence), }; }; diff --git a/src/test/functionalTests/citizenFeatures/response/pages/defendantLipResponse/defendantDQ/confirmYourDetails.js b/src/test/functionalTests/citizenFeatures/response/pages/defendantLipResponse/defendantDQ/confirmYourDetails.js index 7076608b919..de421720584 100644 --- a/src/test/functionalTests/citizenFeatures/response/pages/defendantLipResponse/defendantDQ/confirmYourDetails.js +++ b/src/test/functionalTests/citizenFeatures/response/pages/defendantLipResponse/defendantDQ/confirmYourDetails.js @@ -6,7 +6,7 @@ const cButtons = require('../../../../../commonComponents/cButtons'); const fields ={ firstName : 'input[id="firstName"]', lastName: 'input[id="lastName"]', - email:'input[id="lastName"]', + email:'input[id="emailAddress"]', telephone: 'input[id="phoneNumber"]', jobTitle: 'input[id="jobTitle"]', }; @@ -32,7 +32,7 @@ const inputs = { class ConfirmYourDetails { async enterYourDetails() { - const { language } = sharedData; + const { language } = sharedData; await I.waitForContent(content.heading[language], config.WaitForText); await I.see(content.descriptionText[language]); await I.fillField(fields.firstName, 'John'); @@ -44,4 +44,4 @@ class ConfirmYourDetails { } } -module.exports = ConfirmYourDetails; \ No newline at end of file +module.exports = ConfirmYourDetails; diff --git a/src/test/unit/services/translation/convertToCUI/convertToCUIDQs.test.ts b/src/test/unit/services/translation/convertToCUI/convertToCUIDQs.test.ts index cbb59ef5e02..0659674b0a6 100644 --- a/src/test/unit/services/translation/convertToCUI/convertToCUIDQs.test.ts +++ b/src/test/unit/services/translation/convertToCUI/convertToCUIDQs.test.ts @@ -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: 'abc@def.ghi', + phone: '7788994455', + jobTitle: 'Chef', + }, }, }; + + const confirmDetails: ConfirmYourDetailsEvidence = new ConfirmYourDetailsEvidence(); + confirmDetails.firstName = 'Gordon'; + confirmDetails.lastName = 'Ramsay'; + confirmDetails.emailAddress = 'abc@def.ghi'; + 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); }); diff --git a/src/test/unit/services/translation/convertToCUI/convertToCUIEvidenceConfirmDetails.test.ts b/src/test/unit/services/translation/convertToCUI/convertToCUIEvidenceConfirmDetails.test.ts new file mode 100644 index 00000000000..5fa7ec88baa --- /dev/null +++ b/src/test/unit/services/translation/convertToCUI/convertToCUIEvidenceConfirmDetails.test.ts @@ -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: 'ant@pant.com', + jobTitle: 'Chant', + }, + }, + }; + + const expected: ConfirmYourDetailsEvidence = { + firstName: 'Ant', + lastName: 'Pant', + phoneNumber: 778899456, + emailAddress: 'ant@pant.com', + jobTitle: 'Chant', + }; + + // When + const result = convertToCUIEvidenceConfirmDetails(ccdClaim); + // Then + expect(result).toMatchObject(expected); + }); +}); diff --git a/src/test/unit/services/translation/response/convertToCCDEvidenceConfirmDetails.test.ts b/src/test/unit/services/translation/response/convertToCCDEvidenceConfirmDetails.test.ts new file mode 100644 index 00000000000..656faa38678 --- /dev/null +++ b/src/test/unit/services/translation/response/convertToCCDEvidenceConfirmDetails.test.ts @@ -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: 'ted@ned.ed', + jobTitle: 'Person', + }; + + const expected: CCDEvidenceConfirmDetails = { + firstName: 'Ted', + lastName: 'Ned', + phone: '7788445566', + email: 'ted@ned.ed', + 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: 'ted@ned.ed', + jobTitle: 'Person', + }; + + const expected: CCDEvidenceConfirmDetails = { + firstName: 'Ted', + lastName: 'Ned', + email: 'ted@ned.ed', + jobTitle: 'Person', + }; + + //When + const actual = convertToCCDEvidenceConfirmDetails(claim.directionQuestionnaire.confirmYourDetailsEvidence); + //then + expect(actual).toEqual(expected); + }); +}); diff --git a/src/test/unit/services/translation/response/convertToCCDRespondentLiPResponse.test.ts b/src/test/unit/services/translation/response/convertToCCDRespondentLiPResponse.test.ts index c78af34e406..d3314eeb9e1 100644 --- a/src/test/unit/services/translation/response/convertToCCDRespondentLiPResponse.test.ts +++ b/src/test/unit/services/translation/response/convertToCCDRespondentLiPResponse.test.ts @@ -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: 'test@test.com', + 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', + 'test@test.com', 600000000, 'Doctor'); const expected : CCDRespondentLiPResponse = { respondent1MediationLiPResponse: undefined, respondent1DQHearingSupportLip: setUpUndefinedDQHearingSupport(), respondent1DQExtraDetails: setUpUndefinedDQExtraDetails(), respondent1LiPContactPerson: 'Example contactPerson', + respondent1DQEvidenceConfirmDetails: evidenceConfirmDetails, respondent1LiPCorrespondenceAddress: addressCCD, }; //When