From 0143664233abf33edcc0dcd40485406255237672 Mon Sep 17 00:00:00 2001 From: mattch1 Date: Mon, 9 Dec 2024 12:28:20 +0000 Subject: [PATCH 1/9] Partner legal entity choice page --- locales/cy/translations.json | 7 ++++ locales/en/translations.json | 7 ++++ .../controller/registration/PageType.ts | 1 + .../controller/registration/Routing.ts | 12 +++++- src/views/general-partner-choice.njk | 42 +++++++++++++++++++ 5 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 src/views/general-partner-choice.njk diff --git a/locales/cy/translations.json b/locales/cy/translations.json index 165f6b6..c01d279 100644 --- a/locales/cy/translations.json +++ b/locales/cy/translations.json @@ -50,6 +50,13 @@ "pageInformation": "WELSH - If the partnership has more than one general partner, you'll add them one at a time." }, + "generalPartnerChoicePage": { + "title": "WELSH - You now need to tell us about the general partners", + "hint": "WELSH - You can add more later.", + "person": "WELSH - A person", + "legalEntity": "WELSH - A legal entity" + }, + "pageNotFound" : { "title" : "WELSH - Page Not Found", "spelling" : "WELSH - If you typed the web address, check it is spelled correctly.", diff --git a/locales/en/translations.json b/locales/en/translations.json index c6de83e..1f78fc3 100644 --- a/locales/en/translations.json +++ b/locales/en/translations.json @@ -50,6 +50,13 @@ "pageInformation": "If the partnership has more than one general partner, you'll add them one at a time." }, + "generalPartnerChoicePage": { + "title": "Is the general partner a person or a legal entity?", + "hint": "You can add more later.", + "person": "A person", + "legalEntity": "A legal entity" + }, + "pageNotFound" : { "title" : "Page not found", "spelling" : "If you typed the web address, check it is spelled correctly.", diff --git a/src/presentation/controller/registration/PageType.ts b/src/presentation/controller/registration/PageType.ts index 2ff80e3..316f94e 100644 --- a/src/presentation/controller/registration/PageType.ts +++ b/src/presentation/controller/registration/PageType.ts @@ -2,6 +2,7 @@ enum RegistrationPageType { name = "name", whichType = "which-type", generalPartners = "general-partners", + generalPartnerChoice = "general-partner-choice", next = "next", } diff --git a/src/presentation/controller/registration/Routing.ts b/src/presentation/controller/registration/Routing.ts index da441b3..fc60047 100644 --- a/src/presentation/controller/registration/Routing.ts +++ b/src/presentation/controller/registration/Routing.ts @@ -11,12 +11,14 @@ const START_URL = `${BASE_URL}/start`; export const WHICH_TYPE_TEMPLATE = RegistrationPageType.whichType; export const NAME_TEMPLATE = RegistrationPageType.name; export const GENERAL_PARTNERS_TEMPLATE = RegistrationPageType.generalPartners; +export const GENERAL_PARTNER_CHOICE_TEMPLATE = RegistrationPageType.generalPartnerChoice; export const NEXT_TEMPLATE = RegistrationPageType.next; export const WHICH_TYPE_URL = `${BASE_URL}/${WHICH_TYPE_TEMPLATE}`; export const NAME_URL = `${BASE_URL}/${NAME_TEMPLATE}`; export const GENERAL_PARTNERS_URL = `${BASE_WITH_IDS_URL}/${GENERAL_PARTNERS_TEMPLATE}`; +export const GENERAL_PARTNER_CHOICE_URL = `${BASE_WITH_IDS_URL}/${GENERAL_PARTNER_CHOICE_TEMPLATE}`; export const NEXT_URL = `${BASE_WITH_IDS_URL}/${NEXT_TEMPLATE}`; @@ -37,10 +39,17 @@ export const registrationRoutingName = { const registrationRoutingGeneralPartners = { previousUrl: WHICH_TYPE_URL, currentUrl: GENERAL_PARTNERS_URL, - nextUrl: NEXT_URL, + nextUrl: GENERAL_PARTNER_CHOICE_URL, pageType: RegistrationPageType.generalPartners, }; +const registrationRoutingGeneralPartnerChoice = { + previousUrl: GENERAL_PARTNERS_URL, + currentUrl: GENERAL_PARTNER_CHOICE_URL, + nextUrl: NEXT_URL, + pageType: RegistrationPageType.generalPartnerChoice, +}; + const registrationRoutingNext = { previousUrl: WHICH_TYPE_URL, currentUrl: NEXT_URL, @@ -52,6 +61,7 @@ const list = [ registrationRoutingPartnershipType, registrationRoutingName, registrationRoutingGeneralPartners, + registrationRoutingGeneralPartnerChoice, registrationRoutingNext, ]; diff --git a/src/views/general-partner-choice.njk b/src/views/general-partner-choice.njk new file mode 100644 index 0000000..4d09f0f --- /dev/null +++ b/src/views/general-partner-choice.njk @@ -0,0 +1,42 @@ +{% extends "layout.njk" %} + +{% block beforeContent %} + {% include "includes/back-link.njk" %} +{% endblock %} + +{% block content %} +
+
+
+ + {{ govukRadios({ + name: "generalPartner", + value: data['generalPartner'], + fieldset: { + legend: { + text: i18n.generalPartnerChoicePage.title, + isPageHeading: true, + classes: "govuk-fieldset__legend--xl" + } + }, + hint: { + text: i18n.generalPartnerChoicePage.hint + }, + + items: [ + { + value: "person", + text: i18n.generalPartnerChoicePage.person + }, + { + value: "entity", + text: i18n.generalPartnerChoicePage.legalEntity + } + ] + }) }} + + {% include "includes/continue-button.njk" %} +
+
+
+{% endblock %} From 0e7f5d172a9877501f026e6875b9d66c4fcb9539 Mon Sep 17 00:00:00 2001 From: mattch1 Date: Mon, 9 Dec 2024 13:39:39 +0000 Subject: [PATCH 2/9] Test and registration --- .../general-partner-choice.test.ts | 36 +++++++++++++++++++ src/routes/registration.ts | 7 +++- 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 src/presentation/test/integration/registration/general-partner-choice.test.ts diff --git a/src/presentation/test/integration/registration/general-partner-choice.test.ts b/src/presentation/test/integration/registration/general-partner-choice.test.ts new file mode 100644 index 0000000..440a3f6 --- /dev/null +++ b/src/presentation/test/integration/registration/general-partner-choice.test.ts @@ -0,0 +1,36 @@ +import request from "supertest"; +import { LocalesService } from "@companieshouse/ch-node-utils"; +import * as config from "../../../../config/constants"; +import enTranslationText from "../../../../../locales/en/translations.json"; +import cyTranslationText from "../../../../../locales/cy/translations.json"; +import app from "../app"; +import { + GENERAL_PARTNER_CHOICE_URL, +} from "../../../controller/registration/Routing"; + +describe("General Partner Choice Page", () => { + beforeEach(() => { + setLocalesEnabled(false); + }); + + const setLocalesEnabled = (bool: boolean) => { + jest.spyOn(config, "isLocalesEnabled").mockReturnValue(bool); + LocalesService.getInstance().enabled = bool; + }; + + it("should load the general partner choice page with Welsh text", async () => { + setLocalesEnabled(true); + const res = await request(app).get(GENERAL_PARTNER_CHOICE_URL + "?lang=cy"); + + expect(res.status).toBe(200); + expect(res.text).toContain(cyTranslationText.generalPartnerChoicePage.title); + }); + + it("should load the general partner choice page with English text", async () => { + setLocalesEnabled(true); + const res = await request(app).get(GENERAL_PARTNER_CHOICE_URL + "?lang=en"); + + expect(res.status).toBe(200); + expect(res.text).toContain(enTranslationText.generalPartnerChoicePage.title); + }); +}); diff --git a/src/routes/registration.ts b/src/routes/registration.ts index fdb9123..ff1f862 100644 --- a/src/routes/registration.ts +++ b/src/routes/registration.ts @@ -9,6 +9,7 @@ import { NEXT_URL, WHICH_TYPE_URL, GENERAL_PARTNERS_URL, + GENERAL_PARTNER_CHOICE_URL, } from "../presentation/controller/registration/Routing"; export const registrationEndpoints = ( @@ -40,7 +41,11 @@ export const registrationEndpoints = ( authentication, dependencies.registrationController.getPageRouting() ); - + router.get( + GENERAL_PARTNER_CHOICE_URL, + authentication, + dependencies.registrationController.getPageRouting() + ); router.get( NEXT_URL, authentication, From b92374d393a27f6af7e369798f9477edf718514c Mon Sep 17 00:00:00 2001 From: mattch1 Date: Tue, 10 Dec 2024 09:51:49 +0000 Subject: [PATCH 3/9] Validation and next page post routing --- src/routes/registration.ts | 5 +++++ src/views/general-partner-choice.njk | 23 ++++++++++++++++++----- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/routes/registration.ts b/src/routes/registration.ts index ff1f862..71ee218 100644 --- a/src/routes/registration.ts +++ b/src/routes/registration.ts @@ -46,6 +46,11 @@ export const registrationEndpoints = ( authentication, dependencies.registrationController.getPageRouting() ); + router.post( + GENERAL_PARTNER_CHOICE_URL, + authentication, + dependencies.registrationController.redirectWithParameter() + ); router.get( NEXT_URL, authentication, diff --git a/src/views/general-partner-choice.njk b/src/views/general-partner-choice.njk index 4d09f0f..297ce17 100644 --- a/src/views/general-partner-choice.njk +++ b/src/views/general-partner-choice.njk @@ -7,7 +7,10 @@ {% block content %}
-
+ + + + {% include "includes/csrf_token.njk" %} {{ govukRadios({ name: "generalPartner", @@ -25,12 +28,22 @@ items: [ { - value: "person", - text: i18n.generalPartnerChoicePage.person + value: "Person", + text: i18n.generalPartnerChoicePage.person, + id: "person", + name: "person", + attributes: { + required: true + } }, { - value: "entity", - text: i18n.generalPartnerChoicePage.legalEntity + value: "Legal Entity", + text: i18n.generalPartnerChoicePage.legalEntity, + id: "legal_entity", + name: "legal_entity", + attributes: { + required: true + } } ] }) }} From fb404a5dadb0807180ba8bd226d5c292661141f6 Mon Sep 17 00:00:00 2001 From: mattch1 Date: Tue, 10 Dec 2024 10:36:02 +0000 Subject: [PATCH 4/9] Merge from main --- src/infrastructure/gateway/RegistrationGateway.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/infrastructure/gateway/RegistrationGateway.ts b/src/infrastructure/gateway/RegistrationGateway.ts index a79acf8..9e21b54 100644 --- a/src/infrastructure/gateway/RegistrationGateway.ts +++ b/src/infrastructure/gateway/RegistrationGateway.ts @@ -61,7 +61,7 @@ class RegistrationGateway implements IRegistrationGateway { ): Promise { const api = this.createApi(opt.access_token); - const response = + /*const response = await api.limitedPartnershipsService.patchLimitedPartnership( transactionId, submissionId, @@ -73,7 +73,7 @@ class RegistrationGateway implements IRegistrationGateway { if (response.httpStatusCode !== 200) { throw response; - } + }*/ } async getSubmissionById(id: string): Promise { From c1ac1686ceefec81735e869deb664e1ee05f038d Mon Sep 17 00:00:00 2001 From: mattch1 Date: Tue, 10 Dec 2024 10:38:59 +0000 Subject: [PATCH 5/9] Build and uncooment --- src/infrastructure/gateway/RegistrationGateway.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/infrastructure/gateway/RegistrationGateway.ts b/src/infrastructure/gateway/RegistrationGateway.ts index 9e21b54..a79acf8 100644 --- a/src/infrastructure/gateway/RegistrationGateway.ts +++ b/src/infrastructure/gateway/RegistrationGateway.ts @@ -61,7 +61,7 @@ class RegistrationGateway implements IRegistrationGateway { ): Promise { const api = this.createApi(opt.access_token); - /*const response = + const response = await api.limitedPartnershipsService.patchLimitedPartnership( transactionId, submissionId, @@ -73,7 +73,7 @@ class RegistrationGateway implements IRegistrationGateway { if (response.httpStatusCode !== 200) { throw response; - }*/ + } } async getSubmissionById(id: string): Promise { From 5eb35b404dc150a3739b419d0743109de1a3661b Mon Sep 17 00:00:00 2001 From: mattch1 Date: Tue, 10 Dec 2024 11:54:56 +0000 Subject: [PATCH 6/9] Post test --- .../general-partner-choice.test.ts | 14 +++++++++++++ src/routes/registration.ts | 21 +++++++++---------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/presentation/test/integration/registration/general-partner-choice.test.ts b/src/presentation/test/integration/registration/general-partner-choice.test.ts index 440a3f6..f526904 100644 --- a/src/presentation/test/integration/registration/general-partner-choice.test.ts +++ b/src/presentation/test/integration/registration/general-partner-choice.test.ts @@ -6,7 +6,9 @@ import cyTranslationText from "../../../../../locales/cy/translations.json"; import app from "../app"; import { GENERAL_PARTNER_CHOICE_URL, + NEXT_URL, } from "../../../controller/registration/Routing"; +import RegistrationPageType from "../../../../presentation/controller/registration/PageType"; describe("General Partner Choice Page", () => { beforeEach(() => { @@ -33,4 +35,16 @@ describe("General Partner Choice Page", () => { expect(res.status).toBe(200); expect(res.text).toContain(enTranslationText.generalPartnerChoicePage.title); }); + + it("should redirect to next page when choice is selected", async () => { + const selectedType = "Person"; + const res = await request(app).post(GENERAL_PARTNER_CHOICE_URL).send({ + pageType: RegistrationPageType.generalPartnerChoice, + parameter: selectedType, + }); + + const redirectUrl = `${NEXT_URL}?${RegistrationPageType.generalPartnerChoice}=${selectedType}`; + expect(res.status).toBe(302); + expect(res.text).toContain(redirectUrl); + }); }); diff --git a/src/routes/registration.ts b/src/routes/registration.ts index 170544a..f351da3 100644 --- a/src/routes/registration.ts +++ b/src/routes/registration.ts @@ -38,31 +38,30 @@ export const registrationEndpoints = ( dependencies.registrationController.createTransactionAndFirstSubmission() ); router.get( - GENERAL_PARTNERS_URL, + EMAIL_URL, authentication, dependencies.registrationController.getPageRouting() ); - router.get( - GENERAL_PARTNER_CHOICE_URL, + router.post( + EMAIL_URL, authentication, - dependencies.registrationController.getPageRouting() + dependencies.registrationController.sendPageData() ); - router.post( - GENERAL_PARTNER_CHOICE_URL, + router.get( + GENERAL_PARTNERS_URL, authentication, - dependencies.registrationController.redirectWithParameter() + dependencies.registrationController.getPageRouting() ); router.get( - EMAIL_URL, + GENERAL_PARTNER_CHOICE_URL, authentication, dependencies.registrationController.getPageRouting() ); router.post( - EMAIL_URL, + GENERAL_PARTNER_CHOICE_URL, authentication, - dependencies.registrationController.sendPageData() + dependencies.registrationController.redirectWithParameter() ); - router.get( NEXT_URL, authentication, From d357de9be4422a790e48b711a3cada5cee3c7227 Mon Sep 17 00:00:00 2001 From: mattch1 Date: Tue, 10 Dec 2024 12:55:10 +0000 Subject: [PATCH 7/9] Allow parameters to be passed --- src/views/general-partner-choice.njk | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/views/general-partner-choice.njk b/src/views/general-partner-choice.njk index 297ce17..303e48d 100644 --- a/src/views/general-partner-choice.njk +++ b/src/views/general-partner-choice.njk @@ -13,7 +13,8 @@ {% include "includes/csrf_token.njk" %} {{ govukRadios({ - name: "generalPartner", + classes: "govuk-radios", + name: "parameter", value: data['generalPartner'], fieldset: { legend: { @@ -28,7 +29,7 @@ items: [ { - value: "Person", + value: "person", text: i18n.generalPartnerChoicePage.person, id: "person", name: "person", @@ -37,7 +38,7 @@ } }, { - value: "Legal Entity", + value: "legalEntity", text: i18n.generalPartnerChoicePage.legalEntity, id: "legal_entity", name: "legal_entity", From 6bf24d6c78857d2d87886651945722a1d6d5a29d Mon Sep 17 00:00:00 2001 From: mattch1 Date: Tue, 10 Dec 2024 13:37:46 +0000 Subject: [PATCH 8/9] Removed unused backlink --- src/views/general-partner-choice.njk | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/views/general-partner-choice.njk b/src/views/general-partner-choice.njk index 303e48d..b5acfa5 100644 --- a/src/views/general-partner-choice.njk +++ b/src/views/general-partner-choice.njk @@ -1,9 +1,5 @@ {% extends "layout.njk" %} -{% block beforeContent %} - {% include "includes/back-link.njk" %} -{% endblock %} - {% block content %}
From a5fef06e7e4e13e75e62e5984ea85e177c1119c6 Mon Sep 17 00:00:00 2001 From: mattch1 Date: Tue, 10 Dec 2024 13:46:39 +0000 Subject: [PATCH 9/9] parameter value in post test --- .../integration/registration/general-partner-choice.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/presentation/test/integration/registration/general-partner-choice.test.ts b/src/presentation/test/integration/registration/general-partner-choice.test.ts index f526904..ee796c5 100644 --- a/src/presentation/test/integration/registration/general-partner-choice.test.ts +++ b/src/presentation/test/integration/registration/general-partner-choice.test.ts @@ -37,7 +37,7 @@ describe("General Partner Choice Page", () => { }); it("should redirect to next page when choice is selected", async () => { - const selectedType = "Person"; + const selectedType = "person"; const res = await request(app).post(GENERAL_PARTNER_CHOICE_URL).send({ pageType: RegistrationPageType.generalPartnerChoice, parameter: selectedType,