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

CIV-12317 Store "give evidence yourself" details #4540

Merged
merged 23 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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,
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -12,6 +13,7 @@ export interface CCDRespondentLiPResponse {
respondent1LiPContactPerson?: string,
respondent1LiPCorrespondenceAddress?: CCDAddress,
respondent1ResponseLanguage?: CCDRespondentResponseLanguage;
respondent1DQEvidenceConfirmDetails?: CCDEvidenceConfirmDetails;
}

export enum CCDRespondentResponseLanguage {
Expand Down
2 changes: 2 additions & 0 deletions src/main/common/models/civilClaimResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -200,6 +201,7 @@ export interface CCDClaim extends ClaimUpdate {
specRespondent1DQDisclosureOfElectronicDocuments?: CCDDisclosureOfElectronicDocuments;
specRespondent1DQDisclosureOfNonElectronicDocuments?: CCDDisclosureOfNonElectronicDocuments;
respondent1DQClaimantDocumentsToBeConsidered?: CCDDocumentsToBeConsidered;
respondent1DQEvidenceConfirmDetails?: CCDEvidenceConfirmDetails;
sdoOrderDocument?: CaseDocument;
respondToClaim?: CCDRespondToClaim;
defenceRouteRequired?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,12 @@ const saveDirectionQuestionnaire = async (claimId: string, value: any, direction
const getConfirmYourDetailsEvidence = async (claimId: string, directionQuestionnairePropertyName: string, parentPropertyName?: string): Promise<ConfirmYourDetailsEvidence> => {
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]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -24,6 +26,7 @@ export interface CCDClaimantLiPResponse {
claimantCourtDecision?: RepaymentDecisionType,
applicant1RejectedRepaymentReason?: string,
applicant1SuggestedImmediatePaymentDeadLine?: Date,
applicant1DQEvidenceConfirmDetails?: CCDEvidenceConfirmDetails,
}

const toChoosesHowToProceed = {
Expand All @@ -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),
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
}
Expand Down
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;
}
};
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,
};
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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),
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"]',
};
Expand All @@ -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');
Expand All @@ -44,4 +44,4 @@ class ConfirmYourDetails {
}
}

module.exports = ConfirmYourDetails;
module.exports = ConfirmYourDetails;
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand All @@ -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);
});
Expand Down
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);
});
});
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);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
Loading