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

Aut-2844 : add new contact form problem with national insurance number #1651

Merged
merged 2 commits into from
May 31, 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
2 changes: 2 additions & 0 deletions src/app.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ export const CONTACT_US_THEMES = {
PROVING_IDENTITY_NEED_TO_UPDATE_PERSONAL_INFORMATION:
"proving_identity_need_to_update_personal_information",
PROVING_IDENTITY_SOMETHING_ELSE: "proving_identity_something_else",
PROVING_IDENTITY_PROBLEM_WITH_NATIONAL_INSURANCE_NUMBER:
"proving_identity_problem_with_national_insurance_number",
};

export const CONTACT_US_FIELD_MAX_LENGTH = 1200;
Expand Down
14 changes: 14 additions & 0 deletions src/components/contact-us/contact-us-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ const themeToPageTitle = {
"pages.contactUsQuestions.provingIdentityNeedToUpdatePersonalInformation.title",
[CONTACT_US_THEMES.PROVING_IDENTITY_SOMETHING_ELSE]:
"pages.contactUsQuestions.provingIdentitySomethingElse.title",
[CONTACT_US_THEMES.PROVING_IDENTITY_PROBLEM_WITH_NATIONAL_INSURANCE_NUMBER]:
"pages.contactUsQuestions.provingIdentityProblemWithNationalInsuranceNumber.title",
};

const somethingElseSubThemeToPageTitle = {
Expand Down Expand Up @@ -469,6 +471,8 @@ export function contactUsQuestionsFormPostToSmartAgent(
moreDetailDescription: req.body.moreDetailDescription,
serviceTryingToUse: req.body.serviceTryingToUse,
countryPhoneNumberFrom: req.body.countryPhoneNumberFrom,
problemWithNationalInsuranceNumber:
req.body.problemWithNationalInsuranceNumber,
},
themes: { theme: req.body.theme, subtheme: req.body.subtheme },
subject: "GOV.UK One Login",
Expand Down Expand Up @@ -824,6 +828,12 @@ export function getQuestionsFromFormTypeForMessageBody(
{ lng: "en" }
),
},
provingIdentityProblemWithNationalInsuranceNumber: {
serviceTryingToUse: req.t(
"pages.contactUsQuestions.serviceTryingToUse.header",
{ lng: "en" }
),
},
};

return formTypeToQuestions[formType];
Expand Down Expand Up @@ -993,6 +1003,10 @@ export function getQuestionFromThemes(
"pages.contactUsQuestions.provingIdentitySomethingElse.title",
{ lng: "en" }
),
proving_identity_problem_with_national_insurance_number: req.t(
"pages.contactUsQuestions.provingIdentityProblemWithNationalInsuranceNumber.title",
{ lng: "en" }
),
};

const themeQuestion = themesToQuestions[theme];
Expand Down
28 changes: 28 additions & 0 deletions src/components/contact-us/contact-us-questions-validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,34 @@ export function validateContactUsQuestionsRequest(): ValidationChainFunc {
{ value, lng: req.i18n.lng }
);
}),
body("problemWithNationalInsuranceNumber")
.if(body("theme").equals("proving_identity"))
.if(
body("subtheme").equals(
"proving_identity_problem_with_national_insurance_number"
)
)
.notEmpty()
.withMessage((value, { req }) => {
return req.t(
"pages.contactUsQuestions.provingIdentityProblemWithNationalInsuranceNumber.section1.errorMessage",
{ value, lng: req.i18n.lng }
);
}),
body("problemWithNationalInsuranceNumber")
.if(body("theme").equals("proving_identity"))
.if(
body("subtheme").equals(
"proving_identity_problem_with_national_insurance_number"
)
)
.isLength({ max: CONTACT_US_FIELD_MAX_LENGTH })
.withMessage((value, { req }) => {
return req.t(
"pages.contactUsQuestions.optionalDescriptionErrorMessage.entryTooLongMessage",
{ value, lng: req.i18n.lng }
);
}),
body("contact")
.notEmpty()
.withMessage((value, { req }) => {
Expand Down
5 changes: 5 additions & 0 deletions src/components/contact-us/contact-us-service-smart-agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@ export function contactUsServiceSmartAgent(
contactForm.descriptions.issueDescription;
}

if (contactForm.descriptions.problemWithNationalInsuranceNumber) {
customAttributes["sa-tag-national-insurance-number"] =
contactForm.descriptions.problemWithNationalInsuranceNumber;
}

customAttributes["sa-tag-what-gov-service"] =
contactForm.descriptions.serviceTryingToUse;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<h1 class="govuk-heading-l govuk-!-margin-top-0 govuk-!-margin-bottom-3">
{{ 'pages.contactUsQuestions.provingIdentityProblemWithNationalInsuranceNumber.header' | translate }}
</h1>

<form action="{{formSubmissionUrl}}" method="post" novalidate>

<input type="hidden" name="_csrf" value="{{csrfToken}}"/>
<input type="hidden" name="theme" value="{{theme}}"/>
<input type="hidden" name="subtheme" value="{{subtheme}}"/>
<input type="hidden" name="backurl" value="{{backurl}}"/>
<input type="hidden" name="fromURL" value="{{fromURL}}"/>
<input type="hidden" name="formType" value="provingIdentityProblemWithNationalInsuranceNumber"/>
<input type="hidden" name="referer" value="{{referer}}"/>
{% include 'contact-us/questions/_id-check-app-hidden-fields.njk' %}

<p class="govuk-body">{{ 'pages.contactUsQuestions.provingIdentityProblemWithNationalInsuranceNumber.paragraph1' | translate }}</p>
<p class="govuk-body">{{ 'pages.contactUsQuestions.provingIdentityProblemWithNationalInsuranceNumber.paragraph2' | translate }}</p>
<p class="govuk-body">{{ 'pages.contactUsQuestions.provingIdentityProblemWithNationalInsuranceNumber.paragraph3' | translate }}</p>
<p class="govuk-body">{{ 'pages.contactUsQuestions.provingIdentityProblemWithNationalInsuranceNumber.paragraph4' | translate | safe}}</p>

{{ govukCharacterCount({
label: {
text: 'pages.contactUsQuestions.provingIdentityProblemWithNationalInsuranceNumber.section1.header' | translate,
classes: "govuk-label--s"
},
id: "problemWithNationalInsuranceNumber",
name: "problemWithNationalInsuranceNumber",
maxlength: contactUsFieldMaxLength,
value: problemWithNationalInsuranceNumber,
charactersAtLimitText: 'pages.contactUsQuestions.characterCountComponent.charactersAtLimitText' | translate,
charactersUnderLimitText: {
other: 'pages.contactUsQuestions.characterCountComponent.charactersUnderLimitText.other' | translate,
one: 'pages.contactUsQuestions.characterCountComponent.charactersUnderLimitText.one' | translate
},
charactersOverLimitText: {
other: 'pages.contactUsQuestions.characterCountComponent.charactersOverLimitText.other' | translate,
one: 'pages.contactUsQuestions.characterCountComponent.charactersOverLimitText.one' | translate
},
errorMessage: {
text: errors['problemWithNationalInsuranceNumber'].text | translate | replace('[maximumCharacters]', contactUsFieldMaxLength.toLocaleString())
} if (errors['problemWithNationalInsuranceNumber'])
}) }}

{% include 'contact-us/questions/_service-trying-to-use.njk' %}

{{ govukWarningText({
text:'pages.contactUsQuestions.personalInformation.paragraph1' | translate,
iconFallbackText: "Warning"
}) }}

{% include 'contact-us/questions/_reply_by_email.njk' %}

{{ govukButton({
"text": "general.sendMessage" | translate,
"type": "Submit",
"preventDoubleClick": true
}) }}

</form>
4 changes: 4 additions & 0 deletions src/components/contact-us/questions/index.njk
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,8 @@
{% include 'contact-us/questions/_proving-identity-something-else.njk' %}
{% endif %}

{% if (theme == 'proving_identity') and (subtheme == 'proving_identity_problem_with_national_insurance_number') %}
{% include 'contact-us/questions/_proving-identity-problem-with-national-insurance-number.njk' %}
{% endif %}

{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,24 @@ describe("Integration:: contact us - public user", () => {
});
});

describe("when a user had a problem with their national insurance number", () => {
it("should return validation error when user has not described which problem they had", (done) => {
const data = {
_csrf: token,
theme: "proving_identity",
subtheme: "proving_identity_problem_with_national_insurance_number",
contact: "false",
};
expectValidationErrorOnPost(
"/contact-us-questions",
data,
"#problemWithNationalInsuranceNumber-error",
"What problem were you having with your National Insurance number?",
done
);
});
});

describe("when a user had a problem with their phone number when creating an account", () => {
const phoneNumberIssueData = (
issueDescription: string,
Expand Down
2 changes: 2 additions & 0 deletions src/components/contact-us/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export interface Descriptions {
moreDetailDescription?: string;
serviceTryingToUse?: string;
countryPhoneNumberFrom?: string;
problemWithNationalInsuranceNumber?: string;
}

export interface Themes {
Expand Down Expand Up @@ -77,6 +78,7 @@ export interface SmartAgentCustomAttributes {
"sa-tag-subtheme"?: string;
"sa-app-error-code"?: string;
"sa-security-mobile-country"?: string;
"sa-tag-national-insurance-number"?: string;
}

export interface SmartAgentTicket {
Expand Down
13 changes: 13 additions & 0 deletions src/locales/cy/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -2171,8 +2171,21 @@
"section2": {
"errorMessage": "Rhowch beth ddigwyddodd"
}
},
"provingIdentityProblemWithNationalInsuranceNumber": {
"title": "Problem gyda’ch rhif Yswiriant Gwladol",
"header": "Problem gyda’ch rhif Yswiriant Gwladol",
"paragraph1": "Mae eich rhif Yswiriant Gwladol yn cael ei wneud i fyny o 2 lythyren, 6 rhif a llythyren terfynol.",
"paragraph2": "Er enghraifft, QQ123456B.",
"paragraph3": "Gallwch ddod o hyd i’ch rhif Yswiriant Gwladol ar eich slip cyflog, P60 neu lythyr budd-dal.",
"paragraph4": "Gallwch ddarllen mwy am gael neu ddod o hyd i’ch rhif Yswiriant Gwladol yn <a href=\"https://www.gov.uk/rhif-yswiriant-gwladol-coll\" class=\"govuk-link\" rel=\"noreferrer noopener\" target=\"_blank\">www.gov.uk/rhif-yswiriant-gwladol-coll</a>",
"section1": {
"header": "Pa broblem oeddech chi’n ei chael gyda’ch rhif Yswiriant Gwladol?",
"errorMessage": "Pa broblem oeddech chi’n ei chael gyda’ch rhif Yswiriant Gwladol?"
}
}
},

"contactUsSubmitSuccess": {
"title": "Mae eich neges wedi ei anfon",
"header": "Mae eich neges wedi ei anfon",
Expand Down
13 changes: 13 additions & 0 deletions src/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -2171,8 +2171,21 @@
"section2": {
"errorMessage": "Enter what happened"
}
},
"provingIdentityProblemWithNationalInsuranceNumber": {
"title": "A problem with your National Insurance number",
"header": "A problem with your National Insurance number",
"paragraph1": "Your National Insurance number is made up of 2 letters, 6 numbers and a final letter.",
"paragraph2": "For example, QQ123456B.",
"paragraph3": "You can find your National Insurance number on your payslip, P60 or benefit letter.",
"paragraph4": "You can read more about getting or finding your National Insurance number at <a href=\"https://www.gov.uk/find-national-insurance-number\" class=\"govuk-link\" rel=\"noreferrer noopener\" target=\"_blank\">www.gov.uk/find-national-insurance-number</a>",
"section1": {
"header": "What problem were you having with your National Insurance number?",
"errorMessage": "What problem were you having with your National Insurance number?"
}
}
},

"contactUsSubmitSuccess": {
"title": "Your message has been submitted",
"header": "Your message has been submitted",
Expand Down
Loading