Skip to content

Commit

Permalink
Merge pull request #91 from companieshouse/IDVA5-467-which-name-is-re…
Browse files Browse the repository at this point in the history
…gistered-with-AML

IDVA5-467 which name is registered with AML
  • Loading branch information
atedros-ch authored Feb 19, 2024
2 parents 754cabd + bdfeb58 commit fa0ac3b
Show file tree
Hide file tree
Showing 10 changed files with 163 additions and 1 deletion.
10 changes: 10 additions & 0 deletions locales/cy/name-registered-with-aml.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"nameRegisteredWithAmlTitle" : "Which name is registered with your Anti-Money Laundering (AML) supervisory body? welsh",
"nameRegisteredWithAmlBody": "We'll check this matches what the AML supervisory body holds welsh",
"nameRegisteredWithAmlNameOfTheBusinessOption": "Name of the business welsh",
"nameRegisteredWithAmlYourNameOption": "Your name welsh",
"nameRegisteredWithAmlBothOption": "Both welsh",
"nameRegisteredWithAmlContinueBtn": "Continue welsh",

"error-nameRegisteredWithAmlSelectRadio" : "Select which name is registered welsh"
}
10 changes: 10 additions & 0 deletions locales/en/name-registered-with-aml.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"nameRegisteredWithAmlTitle" : "Which name is registered with your Anti-Money Laundering (AML) supervisory body?",
"nameRegisteredWithAmlBody": "We'll check this matches what the AML supervisory body holds",
"nameRegisteredWithAmlNameOfTheBusinessOption": "Name of the business",
"nameRegisteredWithAmlYourNameOption": "Your name",
"nameRegisteredWithAmlBothOption": "Both",
"nameRegisteredWithAmlContinueBtn": "Continue",

"error-nameRegisteredWithAmlSelectRadio" : "Select which name is registered"
}
2 changes: 2 additions & 0 deletions src/main/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const BASE_VIEWS_URL = "../views/features";
const BASE_SOLE_TRADER_URL = `${BASE_VIEWS_URL}/sole-trader`;
const BASE_LIMITED_TRADER_URL = `${BASE_VIEWS_URL}/limited`;
export const HOME = `${BASE_SOLE_TRADER_URL}/index/home`;
export const SOLE_TRADER_DOB = `${BASE_SOLE_TRADER_URL}/date-of-birth/capture-date-of-birth`;
export const SOLE_TRADER_NAME = `${BASE_SOLE_TRADER_URL}/name/capture-name`;
Expand All @@ -14,3 +15,4 @@ export const SOLE_TRADER_CORRESPONDENCE_ADDRESS_CONFIRM = `${BASE_SOLE_TRADER_UR
export const SOLE_TRADER_WHAT_IS_YOUR_NATIONALITY = `${BASE_SOLE_TRADER_URL}/nationality/nationality`;
export const SOLE_TRADER_TYPE_OF_BUSINESS = `${BASE_SOLE_TRADER_URL}/type-of-business/type-of-business`;
export const SOLE_TRADER_OTHER_TYPE_OFBUSINESS = `${BASE_SOLE_TRADER_URL}/other-type-of-business/other-type-of-business`;
export const LIMITED_NAME_REGISTERED_WITH_AML = `${BASE_LIMITED_TRADER_URL}/name-registered-with-aml/name-registered-with-aml`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { NextFunction, Request, Response, Router } from "express";
import { validationResult } from "express-validator";
import * as config from "../../../config";
import { FormattedValidationErrors, formatValidationError } from "../../../validation/validation";
import { selectLang, addLangToUrl, getLocalesService, getLocaleInfo } from "../../../utils/localise";
import { SOLE_TRADER_SECTOR_YOU_WORK_IN, LIMITED_NAME_REGISTERED_WITH_AML, LIMITED_WHAT_IS_YOUR_ROLE, BASE_URL } from "../../../types/pageURL";

export const get = async (req: Request, res: Response, next: NextFunction) => {
const lang = selectLang(req.query.lang);
const locales = getLocalesService();
res.render(config.LIMITED_NAME_REGISTERED_WITH_AML, {
previousPage: addLangToUrl(BASE_URL + LIMITED_WHAT_IS_YOUR_ROLE, lang),
title: "Which name is registered with your AML supervisory body?",
...getLocaleInfo(locales, lang),
currentUrl: BASE_URL + LIMITED_NAME_REGISTERED_WITH_AML
});
};

export const post = async (req: Request, res: Response, next: NextFunction) => {
try {
const lang = selectLang(req.query.lang);
const locales = getLocalesService();
const errorList = validationResult(req);
if (!errorList.isEmpty()) {
const pageProperties = getPageProperties(formatValidationError(errorList.array(), lang));
res.status(400).render(config.LIMITED_NAME_REGISTERED_WITH_AML, {
previousPage: addLangToUrl(BASE_URL + LIMITED_WHAT_IS_YOUR_ROLE, lang),
title: "Which name is registered with your AML supervisory body?",
...getLocaleInfo(locales, lang),
currentUrl: BASE_URL + LIMITED_NAME_REGISTERED_WITH_AML,
...pageProperties
});
} else {
const nextPageUrl = addLangToUrl(BASE_URL + SOLE_TRADER_SECTOR_YOU_WORK_IN, lang);
res.redirect(nextPageUrl);
}
} catch (error) {
next(error);
}
};

const getPageProperties = (errors?: FormattedValidationErrors) => ({
errors
});
1 change: 1 addition & 0 deletions src/main/controllers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ export * as soleTraderNationalityController from "./features/SoleTrader/soleTrad
export * as typeOfBusinessController from "./features/SoleTrader/typeOfBusinessController";
export * as OtherTypeOfBusinessController from "./features/SoleTrader/otherTypeOfBusinessController";
export * as healthCheckController from "./healthCheckController";
export * as nameRegisteredWithAmlController from "./features/limited/nameRegisteredWithAmlController";
6 changes: 5 additions & 1 deletion src/main/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
statementRelevantOfficerController, stopNotRelevantOfficerController, sectorYouWorkInController,
soleTraderCorrespondenceAddressManualController, soleTraderWhereDoYouLiveController,
soleTraderNationalityController, typeOfBusinessController, healthCheckController, OtherTypeOfBusinessController, soleTraderCorrespondenceAddressAutoLookupController,
soleTraderCorrespodanceAddressDetailsController, soleTraderCorrespondenceAddressConfirmController
soleTraderCorrespodanceAddressDetailsController, soleTraderCorrespondenceAddressConfirmController, nameRegisteredWithAmlController

} from "../controllers";

Expand All @@ -19,6 +19,7 @@ import { nationalityValidator } from "../../../lib/validation/nationality";
import { typeOfBusinessValidator } from "../validation/typeOfBusiness";
import { otherTypeOfBusinessValidator } from "../validation/otherTypeOfBusiness";
import * as urls from "../types/pageURL";
import { nameRegisteredWithAmlValidator } from "../validation/nameRegisteredWithAml";

const routes = Router();

Expand Down Expand Up @@ -62,6 +63,9 @@ routes.post(urls.SOLE_TRADER_TYPE_OF_BUSINESS, typeOfBusinessValidator, typeOfBu
routes.get(urls.SOLE_TRADER_OTHER_TYPE_OFBUSINESS, OtherTypeOfBusinessController.get);
routes.post(urls.SOLE_TRADER_OTHER_TYPE_OFBUSINESS, otherTypeOfBusinessValidator, OtherTypeOfBusinessController.post);

routes.get(urls.LIMITED_NAME_REGISTERED_WITH_AML, nameRegisteredWithAmlController.get);
routes.post(urls.LIMITED_NAME_REGISTERED_WITH_AML, nameRegisteredWithAmlValidator, nameRegisteredWithAmlController.post);

routes.get(urls.HEALTHCHECK, healthCheckController.get);

export default routes;
5 changes: 5 additions & 0 deletions src/main/types/pageURL.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const SEPARATOR = "/";

const SOLE_TRADER = "/sole-trader";
const LIMITED = "/limited";

export const BASE_URL = "/register-acsp";

Expand All @@ -26,3 +27,7 @@ export const SOLE_TRADER_TYPE_OF_BUSINESS = SOLE_TRADER + "/type-of-business";
export const SOLE_TRADER_OTHER_TYPE_OFBUSINESS = SOLE_TRADER + "/other-type-of-business";

export const HEALTHCHECK = "/healthcheck";

export const LIMITED_NAME_REGISTERED_WITH_AML = LIMITED + "/name-registered-with-aml";

export const LIMITED_WHAT_IS_YOUR_ROLE = LIMITED + "/what-is-your-role";
5 changes: 5 additions & 0 deletions src/main/validation/nameRegisteredWithAml.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { body } from "express-validator";

export const nameRegisteredWithAmlValidator = [
body("nameRegisteredWithAml", "nameRegisteredWithAmlSelectRadio").notEmpty()
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{% from "govuk/components/radios/macro.njk" import govukRadios %}
{% extends "layouts/default.njk" %}

{% block main_content %}

<main>
<form action="" method="POST">
{% include "partials/user_name.njk" %}
<div class="govuk-form-group">
{{ govukRadios({
errorMessage: errors.nameRegisteredWithAml if errors,
classes: "govuk-radios",
id: "name-registered-with-aml-radios",
name: "nameRegisteredWithAml",
fieldset: {
legend: {
text: i18n.nameRegisteredWithAmlTitle,
isPageHeading: true,
classes: "govuk-fieldset__legend--l"
}
},
hint: {
text: i18n.nameRegisteredWithAmlBody
},
items: [
{
value: "NAME_OF_THE_BUSINESS",
text: i18n.nameRegisteredWithAmlNameOfTheBusinessOption,
checked: name-registered-with-aml == NAME_OF_THE_BUSINESS,
attributes: {
"data-event-id": "name-of-the-business-option"
}
},
{
value: "YOUR_NAME",
text: i18n.nameRegisteredWithAmlYourNameOption,
checked: name-registered-with-aml == YOUR_NAME,
attributes: {
"data-event-id": "your-company-option"
}
},
{
value: "BOTH",
text: i18n.nameRegisteredWithAmlBothOption,
checked: name-registered-with-aml == BOTH,
attributes: {
"data-event-id": "both-option"
}
}
]
}) }}
</div>
<button class="govuk-button">{{i18n.nameRegisteredWithAmlContinueBtn}}</button>
</form>
</main>


{% endblock main_content %}
23 changes: 23 additions & 0 deletions src/test/src/controllers/nameRegisteredWithAmlController.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import supertest from "supertest";
import app from "../../../main/app";
import { LIMITED_NAME_REGISTERED_WITH_AML, BASE_URL } from "../../../main/types/pageURL";
const router = supertest(app);

describe("GET" + LIMITED_NAME_REGISTERED_WITH_AML, () => {
it("should return status 200", async () => {
await router.get(BASE_URL + LIMITED_NAME_REGISTERED_WITH_AML).expect(200);
});
});

// Test when radio btn selected, will return 302 after redirecting to the next page.
describe("POST" + LIMITED_NAME_REGISTERED_WITH_AML, () => {
it("should return status 302 after redirect", async () => {
await router.post(BASE_URL + LIMITED_NAME_REGISTERED_WITH_AML).send({ nameRegisteredWithAml: "NAME_OF_THE_BUSINESS" }).expect(302);
});
});
// Test for no radio btn value selected, will return 400.
describe("POST" + LIMITED_NAME_REGISTERED_WITH_AML, () => {
it("should return status 400 after incorrect data entered", async () => {
await router.post(BASE_URL + LIMITED_NAME_REGISTERED_WITH_AML).send({ nameRegisteredWithAml: "" }).expect(400);
});
});

0 comments on commit fa0ac3b

Please sign in to comment.