Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions src/main/app/case/case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export const formFieldsToCaseMapping: Partial<Record<keyof Case, keyof CaseData>
certifiedTranslation: 'marriageCertifiedTranslation',
ceremonyCountry: 'marriageCountryOfMarriage',
ceremonyPlace: 'marriagePlaceOfMarriage',
applicant1InRefuge: 'applicant1InRefuge',
applicant1LifeBasedInEnglandAndWales: 'jurisdictionApplicant1Residence',
applicant2LifeBasedInEnglandAndWales: 'jurisdictionApplicant2Residence',
applicant1DomicileInEnglandWales: 'jurisdictionApplicant1Domicile',
Expand Down
17 changes: 3 additions & 14 deletions src/main/app/case/from-api-format.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -559,16 +559,6 @@ describe('from-api-format', () => {
});
});
describe('fromApiFormat - applicant1InRefuge transformation', () => {
test('defaults applicant1InRefuge to NO if undefined', () => {
const nfdivFormat = fromApiFormat({
applicant1InRefuge: undefined, // Simulate missing value
} as unknown as CaseData);

expect(nfdivFormat).toMatchObject({
applicant1InRefuge: YesOrNo.NO,
});
});

test('retains applicant1InRefuge value if set to YES', () => {
const nfdivFormat = fromApiFormat({
applicant1InRefuge: YesOrNo.YES, // Explicit value set
Expand All @@ -578,7 +568,6 @@ describe('from-api-format', () => {
applicant1InRefuge: YesOrNo.YES,
});
});

test('retains applicant1InRefuge value if set to NO', () => {
const nfdivFormat = fromApiFormat({
applicant1InRefuge: YesOrNo.NO, // Explicit value set
Expand All @@ -590,7 +579,7 @@ describe('from-api-format', () => {
});

test.each([
{ applicant1InRefuge: undefined, expected: YesOrNo.NO },
{ applicant1InRefuge: undefined, expected: undefined },
{ applicant1InRefuge: YesOrNo.YES, expected: YesOrNo.YES },
{ applicant1InRefuge: YesOrNo.NO, expected: YesOrNo.NO },
])('correctly handles applicant1InRefuge with value %p', ({ applicant1InRefuge, expected }) => {
Expand All @@ -600,11 +589,11 @@ describe('from-api-format', () => {

test('handles null applicant1InRefuge gracefully', () => {
const nfdivFormat = fromApiFormat({
applicant1InRefuge: null, // Explicit null value
applicant1InRefuge: null,
} as unknown as CaseData);

expect(nfdivFormat).toMatchObject({
applicant1InRefuge: YesOrNo.NO, // Defaults to NO
applicant1InRefuge: null,
});
});
});
Expand Down
3 changes: 0 additions & 3 deletions src/main/app/case/from-api-format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@ const fields: FromApiConverters = {
applicant1ContactDetailsType: ({ applicant1ContactDetailsType }) => ({
applicant1AddressPrivate: applicant1ContactDetailsType === ContactDetailsType.PRIVATE ? YesOrNo.YES : YesOrNo.NO,
}),
applicant1InRefuge: ({ applicant1InRefuge }) => ({
applicant1InRefuge: applicant1InRefuge ?? YesOrNo.NO,
}),
applicant1WantsToHavePapersServedAnotherWay: data => ({
iWantToHavePapersServedAnotherWay: checkboxConverter(data.applicant1WantsToHavePapersServedAnotherWay),
}),
Expand Down
3 changes: 2 additions & 1 deletion src/main/app/case/to-api-format.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ describe('to-api-format', () => {

expect(apiFormat).toStrictEqual({
applicant1ContactDetailsType: ContactDetailsType.PUBLIC,
applicant1InRefuge: null,
applicant1KnowsApplicant2EmailAddress: YesOrNo.YES,
applicant2ContactDetailsType: ContactDetailsType.PUBLIC,
applicant1PrayerDissolveDivorce: [],
Expand Down Expand Up @@ -296,7 +297,7 @@ describe('to-api-format', () => {
applicant2HWFReferenceNumber: '',
applicant1InterimAppsHwfRefNumber: '',
marriageDate: undefined,
applicant1InRefuge: YesOrNo.NO,
applicant1InRefuge: undefined,
applicant1AddressOverseas: YesOrNo.NO,
applicant2AddressOverseas: YesOrNo.NO,
applicant2SolicitorAddressOverseas: YesOrNo.NO,
Expand Down
8 changes: 3 additions & 5 deletions src/main/app/case/to-api-format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,10 @@ const fields: ToApiConverters = {
applicant2AgreeToReceiveEmails: data => ({
applicant2AgreedToReceiveEmails: checkboxConverter(data.applicant2AgreeToReceiveEmails),
}),
applicant1AddressPrivate: ({ applicant1AddressPrivate }) => ({
applicant1AddressPrivate: data => ({
applicant1ContactDetailsType:
applicant1AddressPrivate === YesOrNo.YES ? ContactDetailsType.PRIVATE : ContactDetailsType.PUBLIC,
}),
applicant1InRefuge: ({ applicant1InRefuge }) => ({
applicant1InRefuge: applicant1InRefuge ?? YesOrNo.NO, // Default to YesOrNo.NO if undefined
data.applicant1AddressPrivate === YesOrNo.YES ? ContactDetailsType.PRIVATE : ContactDetailsType.PUBLIC,
...(data.applicant1AddressPrivate === YesOrNo.NO ? setUnreachableAnswersToNull(['applicant1InRefuge']) : {}),
}),
applicant1AddressOverseas: ({ applicant1AddressOverseas }) => ({
applicant1AddressOverseas: applicant1AddressOverseas ?? YesOrNo.NO,
Expand Down
30 changes: 1 addition & 29 deletions src/main/steps/applicant1/address-private/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,22 @@ import { TranslationFn } from '../../../app/controller/GetController';
import { FormContent } from '../../../app/form/Form';
import { isFieldFilledIn } from '../../../app/form/validation';
import { CommonContent } from '../../common/common.content';
import { InputLabelsByLanguage, ydwOrNacYdwRadioAnswers } from '../../common/input-labels.content';
import { InputLabelsByLanguage } from '../../common/input-labels.content';

const en = ({ partner, required }: CommonContent) => ({
title: `Do you need your contact details kept private from your ${partner}?`,
line1: `The court can keep your address, email address and phone number private from your ${partner}.`,
detailsPrivateMoreDetails: 'If you think you might be experiencing domestic abuse or you feel unsafe, then',
supportAvailable: 'support is available',
errors: {
applicant1AddressPrivate: { required },
applicant1InRefuge: { required },
},
inRefugeLabel: 'Are you currently in a refuge?', // Label for the 'inRefuge' question
});

const cy: typeof en = ({ partner, required }: CommonContent) => ({
title: `A oes arnoch angen cadw eich manylion cyswllt yn breifat oddi wrth eich ${partner}?`,
line1: `Gall y llys gadw eich cyfeiriad, eich cyfeiriad e-bost a'ch rhif ffôn yn breifat oddi wrth eich ${partner}.`,
detailsPrivateMoreDetails:
"Os credwch eich bod efallai'n profi cam-drin domestig neu os nad ydych yn teimlo'n ddiogel, yna",
supportAvailable: 'mae cymorth ar gael',
errors: {
applicant1AddressPrivate: { required },
applicant1InRefuge: { required },
},
inRefugeLabel: 'Ydych chi’n preswylio mewn lloches ar hyn o bryd?',
});

export const form: FormContent = {
Expand All @@ -41,21 +32,6 @@ export const form: FormContent = {
{
label: l => l.detailsPrivate,
value: YesOrNo.YES,
conditionalText: l =>
`<p class="govuk-label">${l.detailsPrivateMoreDetails} <a class="govuk-link" href="https://www.gov.uk/guidance/domestic-abuse-how-to-get-help">${l.supportAvailable}</a></p>`,
subFields: {
applicant1InRefuge: {
id: 'inRefuge',
type: 'radios',
classes: 'govuk-radios--inline',
label: l => l.inRefugeLabel,
values: [
{ label: l => l[YesOrNo.YES], value: YesOrNo.YES },
{ label: l => l[YesOrNo.NO], value: YesOrNo.NO },
],
validator: value => isFieldFilledIn(value), // Only validate if this field is shown
},
},
Comment thread
IswaryaPepakayala marked this conversation as resolved.
},
{
label: l => l.detailsNotPrivate,
Expand All @@ -75,8 +51,6 @@ const languages = {
cy,
};

export const radioButtonAnswersRefuge = ydwOrNacYdwRadioAnswers;

export const radioButtonAnswersPrivate: InputLabelsByLanguage<YesOrNo> = {
en: {
[YesOrNo.YES]: 'Keep my contact details private',
Expand All @@ -90,11 +64,9 @@ export const radioButtonAnswersPrivate: InputLabelsByLanguage<YesOrNo> = {

export const generateContent: TranslationFn = (content: CommonContent) => {
const translations = languages[content.language](content);
const radioAnswersRefuge = radioButtonAnswersRefuge[content.language];
const radioAnswersPrivate = radioButtonAnswersPrivate[content.language];
return {
...translations,
...radioAnswersRefuge,
detailsPrivate: radioAnswersPrivate[YesOrNo.YES],
detailsNotPrivate: radioAnswersPrivate[YesOrNo.NO],
form,
Expand Down
121 changes: 0 additions & 121 deletions src/main/steps/applicant1/address-private/post.test.ts

This file was deleted.

20 changes: 0 additions & 20 deletions src/main/steps/applicant1/address-private/post.ts

This file was deleted.

16 changes: 7 additions & 9 deletions src/main/steps/applicant1/check-your-answers/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ import { jurisdictionMoreDetailsContent } from '../../../app/jurisdiction/moreDe
import { SupportedLanguages } from '../../../modules/i18n';
import { isApplicationReadyToSubmit } from '../../index';
import * as urls from '../../urls';
import {
radioButtonAnswersPrivate as addressPrivateAnswersPrivate,
radioButtonAnswersRefuge as addressPrivateAnswersRefuge,
} from '../address-private/content';
import { radioButtonAnswersPrivate as addressPrivateAnswersPrivate } from '../address-private/content';
import { radioButtonAnswers as residualJurisdictionAnswers } from '../are-you-eligible-for-residual-jurisdiction/content';
import { radioButtonAnswers as certificateInEnglishAnswers } from '../certificate-in-english/content';
import { radioButtonAnswers as certifiedTranslationAnswers } from '../certified-translation/content';
Expand All @@ -44,6 +41,7 @@ import { radioButtonAnswers as habituallyResidentAnswers } from '../habitually-r
import { radioButtonAnswers as helpWithYourFeeAnswers } from '../help-with-your-fee/content';
import { radioButtonAnswers as howDoYouWantToApplyAnswers } from '../how-do-you-want-to-apply/content';
import { checkBoxAnswers as howTheCourtWillContactYouAnswers } from '../how-the-court-will-contact-you/content';
import { radioButtonAnswersRefuge as answersRefuge } from '../in-refuge/content';
import { radioButtonAnswers as inTheUkAnswers } from '../in-the-uk/content';
import { radioButtonAnswers as irretrievableBreakdownAnswers } from '../irretrievable-breakdown/content';
import { radioButtonAnswers as livingEnglandWalesSixMonthsAnswers } from '../living-england-wales-six-months/content';
Expand Down Expand Up @@ -285,7 +283,7 @@ const en = ({
line6: 'By phone',
line7: 'What language do you want to receive emails and documents in?',
line8: `Do you need your contact details kept private from your ${partner}?`,
line9: 'Are you currently in a refuge?',
line9: 'Do you currently live in a refuge?',
line10: 'Your postal address',
line11: 'Is this an international address?',
},
Expand Down Expand Up @@ -480,7 +478,7 @@ const en = ({
line9: `${
!userCase.applicant1AddressPrivate || (userCase.applicant1AddressPrivate === YesOrNo.YES && isApplicant2)
? ''
: stripTags(addressPrivateAnswersRefuge.en[userCase.applicant1InRefuge])
: stripTags(answersRefuge.en[userCase.applicant1InRefuge])
}`,
line10: `${
userCase.applicant1AddressPrivate === YesOrNo.YES && isApplicant2
Expand Down Expand Up @@ -649,7 +647,7 @@ const en = ({
line6: urls.HOW_THE_COURTS_WILL_CONTACT_YOU,
line7: urls.ENGLISH_OR_WELSH,
line8: urls.ADDRESS_PRIVATE,
line9: urls.ADDRESS_PRIVATE,
line9: urls.IN_REFUGE,
line10: urls.ENTER_YOUR_ADDRESS,
line11: urls.ENTER_YOUR_ADDRESS,
},
Expand Down Expand Up @@ -841,7 +839,7 @@ const cy: typeof en = ({
line6: 'Dros y ffôn',
line7: 'Ym mha iaith hoffech chi gael negeseuon e-bost a dogfennau?',
line8: `A oes arnoch angen cadw eich manylion cyswllt yn breifat oddi wrth eich ${partner}?`,
line9: 'Ydych chi’n preswylio mewn lloches ar hyn o bryd?',
line9: 'Ydych chi’n byw mewn lloches ar hyno bryd?',
line10: 'Eich cyfeiriad post',
line11: 'Ydy hwn yn gyfeiriad rhyngwladol?',
},
Expand Down Expand Up @@ -1045,7 +1043,7 @@ const cy: typeof en = ({
line9: `${
!userCase.applicant1AddressPrivate || (userCase.applicant1AddressPrivate === YesOrNo.YES && isApplicant2)
? ''
: stripTags(addressPrivateAnswersRefuge.cy[userCase.applicant1InRefuge])
: stripTags(answersRefuge.cy[userCase.applicant1InRefuge])
}`,
line10: `${
userCase.applicant1AddressPrivate === YesOrNo.YES && isApplicant2
Expand Down
Loading