Skip to content
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
12 changes: 12 additions & 0 deletions src/main/app/case/case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ export const formFieldsToCaseMapping: Partial<Record<keyof Case, keyof CaseData>
applicant1NoRespAddressHasFoundAddress: 'applicant1NoRespAddressHasFoundAddress',
applicant1NoRespAddressHasWayToContact: 'applicant1NoRespAddressHasWayToContact',
applicant1NoRespAddressWillApplyAltService: 'applicant1NoRespAddressWillApplyAltService',
applicant1NoRespAddressEmail: 'applicant1NoRespAddressEmail',
applicant1NoResponseOwnSearches: 'applicant1NoResponseOwnSearches',
applicant1NoResponseRespondentAddressInEnglandWales: 'applicant1NoResponseRespondentAddressInEnglandWales',
applicant1NoResponsePartnerInUkOrReceivingBenefits: 'applicant1NoResponsePartnerInUkOrReceivingBenefits',
Expand Down Expand Up @@ -673,6 +674,17 @@ export interface Case {
applicant1NoRespAddressHasFoundAddress: YesOrNo;
applicant1NoRespAddressHasWayToContact: YesOrNo;
applicant1NoRespAddressWillApplyAltService: YesOrNo;
applicant1NoRespAddressAddress?: AddressGlobalUK;
applicant1NoRespAddressAddress1?: string;
applicant1NoRespAddressAddress2?: string;
applicant1NoRespAddressAddress3?: string;
applicant1NoRespAddressAddressTown?: string;
applicant1NoRespAddressAddressCounty?: string;
applicant1NoRespAddressAddressCountry?: string;
applicant1NoRespAddressAddressPostcode?: string;
applicant1NoRespAddressAddressOverseas?: YesOrNo;
applicant1NoRespAddressEmail?: string;
applicant1NoRespAddressDoesNotKnowEmailAddress?: Checkbox;
applicant1NoResponseOwnSearches?: NoResponseOwnSearches;
applicant1NoResponseRespondentAddressInEnglandWales?: Checkbox;
applicant1NoResponsePartnerInUkOrReceivingBenefits?: YesOrNo;
Expand Down
4 changes: 4 additions & 0 deletions src/main/app/case/definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,10 @@ export interface CaseData {
applicant1NoRespAddressHasFoundAddress: YesOrNo;
applicant1NoRespAddressHasWayToContact: YesOrNo;
applicant1NoRespAddressWillApplyAltService: YesOrNo;
applicant1NoRespAddressAddress: AddressGlobalUK;
applicant1NoRespAddressAddressOverseas: YesOrNo;
applicant1NoRespAddressEmail: string;
applicant1NoRespAddressKnowsEmail: YesOrNo;
applicant1NoResponseOwnSearches: NoResponseOwnSearches;
applicant1NoResponseRespondentAddressInEnglandWales: YesOrNo;
applicant1NoResponsePartnerInUkOrReceivingBenefits: YesOrNo;
Expand Down
6 changes: 6 additions & 0 deletions src/main/app/case/formatter/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const fromApi = (
| 'applicant1NoResponsePartner'
| 'applicant1DispenseLivedTogether'
| 'applicant1SearchGovRecordsPartnerLastKnown'
| 'applicant1NoRespAddress'
): Partial<Case> => {
const fullAddress = data[`${addressPrefix}Address`];

Expand All @@ -31,6 +32,7 @@ const toApiAddress = (
| 'applicant1NoResponsePartner'
| 'applicant1DispenseLivedTogether'
| 'applicant1SearchGovRecordsPartnerLastKnown'
| 'applicant1NoRespAddress'
): AddressGlobalUK => ({
AddressLine1: data[`${addressPrefix}Address1`] || '',
AddressLine2: data[`${addressPrefix}Address2`] || '',
Expand Down Expand Up @@ -60,3 +62,7 @@ export const applicant1NoResponsePartnerAddressToApi = (data: Partial<Case>): Pa
export const applicant1SearchGovRecordsPartnerLastKnownAddressToApi = (data: Partial<Case>): Partial<CaseData> => ({
applicant1SearchGovRecordsPartnerLastKnownAddress: toApiAddress(data, 'applicant1SearchGovRecordsPartnerLastKnown'),
});

export const applicant1NoRespAddressAddressToApi = (data: Partial<Case>): Partial<CaseData> => ({
applicant1NoRespAddressAddress: toApiAddress(data, 'applicant1NoRespAddress'),
});
30 changes: 30 additions & 0 deletions src/main/app/case/from-api-format.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ describe('from-api-format', () => {
applicant1ContactDetailsType: ContactDetailsType.PRIVATE,
applicant1InRefuge: YesOrNo.NO,
applicant1KnowsApplicant2EmailAddress: YesOrNo.NO,
applicant1NoRespAddressKnowsEmail: YesOrNo.NO,
applicant1WantsToHavePapersServedAnotherWay: undefined,
applicant1LanguagePreferenceWelsh: YesOrNo.YES,
applicant2LanguagePreferenceWelsh: YesOrNo.YES,
Expand Down Expand Up @@ -58,6 +59,7 @@ describe('from-api-format', () => {
applicant1LanguagePreferenceWelsh: YesOrNo.NO,
applicant2LanguagePreferenceWelsh: YesOrNo.NO,
applicant1KnowsApplicant2EmailAddress: YesOrNo.YES,
applicant1NoRespAddressKnowsEmail: YesOrNo.YES,
applicant1ContactDetailsType: ContactDetailsType.PUBLIC,
applicant2ContactDetailsType: ContactDetailsType.PUBLIC,
applicant1PrayerDissolveDivorce: [],
Expand All @@ -77,6 +79,7 @@ describe('from-api-format', () => {
applicant1AddressPrivate: YesOrNo.YES,
applicant1InRefuge: YesOrNo.NO,
applicant1DoesNotKnowApplicant2EmailAddress: Checkbox.Checked,
applicant1NoRespAddressDoesNotKnowEmailAddress: Checkbox.Checked,
applicant2AddressPrivate: YesOrNo.NO,
iWantToHavePapersServedAnotherWay: undefined,
applicant1EnglishOrWelsh: LanguagePreference.Welsh,
Expand Down Expand Up @@ -115,6 +118,7 @@ describe('from-api-format', () => {
applicant1EnglishOrWelsh: LanguagePreference.English,
applicant2EnglishOrWelsh: LanguagePreference.English,
applicant1DoesNotKnowApplicant2EmailAddress: Checkbox.Unchecked,
applicant1NoRespAddressDoesNotKnowEmailAddress: Checkbox.Unchecked,
applicant1AddressPrivate: YesOrNo.NO,
applicant2AddressPrivate: YesOrNo.NO,
applicant1IConfirmPrayer: Checkbox.Unchecked,
Expand Down Expand Up @@ -158,6 +162,7 @@ describe('from-api-format', () => {
applicant1AddressPrivate: YesOrNo.YES,
applicant1InRefuge: YesOrNo.NO,
applicant1DoesNotKnowApplicant2EmailAddress: Checkbox.Checked,
applicant1NoRespAddressDoesNotKnowEmailAddress: Checkbox.Checked,
applicant2AddressPrivate: YesOrNo.NO,
iWantToHavePapersServedAnotherWay: undefined,
disputeApplication: YesOrNo.YES,
Expand Down Expand Up @@ -230,6 +235,7 @@ describe('from-api-format', () => {
applicant1AddressPrivate: YesOrNo.YES,
applicant1InRefuge: YesOrNo.NO,
applicant1DoesNotKnowApplicant2EmailAddress: Checkbox.Checked,
applicant1NoRespAddressDoesNotKnowEmailAddress: Checkbox.Checked,
applicant2AddressPrivate: YesOrNo.NO,
iWantToHavePapersServedAnotherWay: undefined,
disputeApplication: null,
Expand Down Expand Up @@ -277,6 +283,7 @@ describe('from-api-format', () => {
applicant1AddressPrivate: YesOrNo.YES,
applicant1InRefuge: YesOrNo.NO,
applicant1DoesNotKnowApplicant2EmailAddress: Checkbox.Checked,
applicant1NoRespAddressDoesNotKnowEmailAddress: Checkbox.Checked,
applicant2AddressPrivate: YesOrNo.NO,
iWantToHavePapersServedAnotherWay: undefined,
disputeApplication: YesOrNo.NO,
Expand Down Expand Up @@ -380,6 +387,29 @@ describe('from-api-format', () => {
});
});

test('converts to UK format for applicant1NoRespAddress', () => {
const nfdivFormat = fromApiFormat({
...results,
applicant1NoRespAddressAddress: {
AddressLine1: 'Line 1',
AddressLine2: 'Line 2',
PostTown: 'Town',
County: 'County',
PostCode: 'Postcode',
},
applicant1NoRespAddressAddressOverseas: YesOrNo.NO,
} as unknown as CaseData);

expect(nfdivFormat).toMatchObject({
applicant1NoRespAddressAddress1: 'Line 1',
applicant1NoRespAddressAddress2: 'Line 2',
applicant1NoRespAddressAddressTown: 'Town',
applicant1NoRespAddressAddressCounty: 'County',
applicant1NoRespAddressAddressPostcode: 'Postcode',
applicant1NoRespAddressAddressOverseas: YesOrNo.NO,
});
});

test('converts to UK format for applicant1DispenseLivedTogether', () => {
const nfdivFormat = fromApiFormat({
...results,
Expand Down
8 changes: 8 additions & 0 deletions src/main/app/case/from-api-format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,14 @@ const fields: FromApiConverters = {
}),
applicant1SearchGovRecordsPartnerLastKnownAddress: data =>
formatAddress(data, 'applicant1SearchGovRecordsPartnerLastKnown'),
applicant1NoRespAddressAddressOverseas: ({ applicant1NoRespAddressAddressOverseas }) => ({
applicant1NoRespAddressAddressOverseas: applicant1NoRespAddressAddressOverseas ?? YesOrNo.NO,
}),
applicant1NoRespAddressKnowsEmail: data => ({
applicant1NoRespAddressDoesNotKnowEmailAddress:
data.applicant1NoRespAddressKnowsEmail === YesOrNo.YES ? Checkbox.Unchecked : Checkbox.Checked,
}),
applicant1NoRespAddressAddress: data => formatAddress(data, 'applicant1NoRespAddress'),
};

const fromApiDate = date => {
Expand Down
4 changes: 4 additions & 0 deletions src/main/app/case/to-api-format.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ describe('to-api-format', () => {
applicant2FoHelpPayingNeeded: YesOrNo.YES,
applicant1AgreeToReceiveEmails: Checkbox.Checked,
applicant1DoesNotKnowApplicant2EmailAddress: Checkbox.Checked,
applicant1NoRespAddressDoesNotKnowEmailAddress: Checkbox.Checked,
applicant1AddressPrivate: YesOrNo.YES,
applicant1InRefuge: YesOrNo.YES,
applicant1KnowsApplicant2Address: YesOrNo.NO,
Expand Down Expand Up @@ -103,6 +104,7 @@ describe('to-api-format', () => {

const resultsWithSecondaryValues: OrNull<Partial<Case>> = {
applicant1DoesNotKnowApplicant2EmailAddress: Checkbox.Unchecked,
applicant1NoRespAddressDoesNotKnowEmailAddress: Checkbox.Unchecked,
applicant1IConfirmPrayer: Checkbox.Unchecked,
applicant2IConfirmPrayer: Checkbox.Unchecked,
applicant1AddressPrivate: YesOrNo.NO,
Expand Down Expand Up @@ -171,6 +173,7 @@ describe('to-api-format', () => {
applicant1KnowsApplicant2Address: YesOrNo.NO,
applicant1FoundApplicant2Address: YesOrNo.NO,
applicant1KnowsApplicant2EmailAddress: YesOrNo.NO,
applicant1NoRespAddressKnowsEmail: YesOrNo.NO,
applicant1WantsToHavePapersServedAnotherWay: null,
applicant1LanguagePreferenceWelsh: 'No',
applicant2LanguagePreferenceWelsh: 'No',
Expand Down Expand Up @@ -236,6 +239,7 @@ describe('to-api-format', () => {
expect(apiFormat).toStrictEqual({
applicant1ContactDetailsType: ContactDetailsType.PUBLIC,
applicant1KnowsApplicant2EmailAddress: YesOrNo.YES,
applicant1NoRespAddressKnowsEmail: YesOrNo.YES,
applicant2ContactDetailsType: ContactDetailsType.PUBLIC,
applicant1PrayerDissolveDivorce: [],
applicant1PrayerEndCivilPartnership: [],
Expand Down
9 changes: 9 additions & 0 deletions src/main/app/case/to-api-format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
import {
applicant1AddressToApi,
applicant1DispenseLivedTogetherAddressToApi,
applicant1NoRespAddressAddressToApi,
applicant1NoResponsePartnerAddressToApi,
applicant1SearchGovRecordsPartnerLastKnownAddressToApi,
applicant2AddressToApi,
Expand Down Expand Up @@ -738,6 +739,14 @@ const fields: ToApiConverters = {
? data.applicant1DispenseChildMaintenanceResults
: null,
}),
applicant1NoRespAddressDoesNotKnowEmailAddress: data => ({
applicant1NoRespAddressKnowsEmail:
data.applicant1NoRespAddressDoesNotKnowEmailAddress === Checkbox.Checked ? YesOrNo.NO : YesOrNo.YES,
}),
applicant1NoRespAddressAddressOverseas: ({ applicant1NoRespAddressAddressOverseas }) => ({
applicant1NoRespAddressAddressOverseas: applicant1NoRespAddressAddressOverseas ?? YesOrNo.NO,
}),
applicant1NoRespAddressAddressPostcode: applicant1NoRespAddressAddressToApi,
};

const toApiDate = (date: CaseDate | undefined | string) => {
Expand Down
6 changes: 5 additions & 1 deletion src/main/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,11 @@ export class Routes {
const postController = fs.existsSync(`${step.stepDir}/post${ext}`)
? require(`${step.stepDir}/post${ext}`).default
: PostController;
app.post(step.url, errorHandler(new postController(step.form.fields).post));
app.post(
step.url,
this.isRouteForUser as RequestHandler,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll also be applying validations to the post controllers of pages outside the main divorce journey with this page. Thinking we could add a QA note to guide their exploratory testing

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doo you think this is an issue. Since we already had a validation for getController here, Ii do not think it would be an issue if we aren't able to submit from here either.

errorHandler(new postController(step.form.fields).post)
);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,24 @@ const en = ({ partner, userCase }: CommonContent) => ({
},
stepAnswers: {
partnerAddress: `${[
stripTags(userCase.applicant2Address1),
stripTags(userCase.applicant2Address2),
stripTags(userCase.applicant2Address3),
stripTags(userCase.applicant2AddressTown),
stripTags(userCase.applicant2AddressCounty),
stripTags(userCase.applicant2AddressPostcode),
stripTags(userCase.applicant2AddressCountry),
stripTags(userCase.applicant1NoRespAddressAddress1),
stripTags(userCase.applicant1NoRespAddressAddress2),
stripTags(userCase.applicant1NoRespAddressAddress3),
stripTags(userCase.applicant1NoRespAddressAddressTown),
stripTags(userCase.applicant1NoRespAddressAddressCounty),
stripTags(userCase.applicant1NoRespAddressAddressPostcode),
stripTags(userCase.applicant1NoRespAddressAddressCountry),
]
.filter(Boolean)
.join('<br>')}`,
internationalAddress: `${
userCase.applicant2AddressOverseas === YesOrNo.NO ? '' : [stripTags(userCase.applicant2AddressOverseas)]
userCase.applicant1NoRespAddressAddressOverseas === YesOrNo.NO
? ''
: [stripTags(userCase.applicant1NoRespAddressAddressOverseas)]
}`,
partnerEmail: `${stripTags(userCase.applicant2EmailAddress)}`,
partnerEmail: `${stripTags(userCase.applicant1NoRespAddressEmail)}`,
doNotKnowEmail: `${
userCase.applicant1DoesNotKnowApplicant2EmailAddress === Checkbox.Checked
userCase.applicant1NoRespAddressDoesNotKnowEmailAddress === Checkbox.Checked
? 'I do not know their email address'
: ''
}`,
Expand All @@ -54,22 +56,24 @@ const cy: typeof en = ({ partner, userCase }: CommonContent) => ({
},
stepAnswers: {
partnerAddress: `${[
stripTags(userCase.applicant2Address1),
stripTags(userCase.applicant2Address2),
stripTags(userCase.applicant2Address3),
stripTags(userCase.applicant2AddressTown),
stripTags(userCase.applicant2AddressCounty),
stripTags(userCase.applicant2AddressPostcode),
stripTags(userCase.applicant2AddressCountry),
stripTags(userCase.applicant1NoRespAddressAddress1),
stripTags(userCase.applicant1NoRespAddressAddress2),
stripTags(userCase.applicant1NoRespAddressAddress3),
stripTags(userCase.applicant1NoRespAddressAddressTown),
stripTags(userCase.applicant1NoRespAddressAddressCounty),
stripTags(userCase.applicant1NoRespAddressAddressPostcode),
stripTags(userCase.applicant1NoRespAddressAddressCountry),
]
.filter(Boolean)
.join('<br>')}`,
internationalAddress: `${
userCase.applicant2AddressOverseas === YesOrNo.NO ? '' : [stripTags(userCase.applicant2AddressOverseas)]
userCase.applicant1NoRespAddressAddressOverseas === YesOrNo.NO
? ''
: [stripTags(userCase.applicant1NoRespAddressAddressOverseas)]
}`,
partnerEmail: `${stripTags(userCase.applicant2EmailAddress)}`,
partnerEmail: `${stripTags(userCase.applicant1NoRespAddressEmail)}`,
doNotKnowEmail: `${
userCase.applicant1DoesNotKnowApplicant2EmailAddress === Checkbox.Checked
userCase.applicant1NoRespAddressDoesNotKnowEmailAddress === Checkbox.Checked
? 'I do not know their email address'
: ''
}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{% from "govuk/components/button/macro.njk" import govukButton %}

{% extends "common/page.njk" %}
{% block backLink %}{% endblock %}
{% block page_content %}
<div class="govuk-panel govuk-panel--confirmation">
<h1 id="detailsUpdatedTitle" class="govuk-panel__title">{{ title }}</h1>
Expand Down
Loading