Skip to content

Commit

Permalink
Merge pull request #147 from companieshouse/lp-241-cya-page-template-…
Browse files Browse the repository at this point in the history
…routing

Lp 241 cya page template routing
  • Loading branch information
mattch1 authored Jan 20, 2025
2 parents 5ec9090 + 60edb1b commit f7c389b
Show file tree
Hide file tree
Showing 11 changed files with 239 additions and 4 deletions.
12 changes: 12 additions & 0 deletions locales/cy/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@
"saveAndContinue" : "WELSH - Save and continue"
},

"checkYourAnswersPage" : {
"title" : "WELSH - Check your answers before sending your application",
"lpInfo" : "WELSH - Limited partnership information",
"headingName" : "WELSH - Partnership Name",
"headingSic" : "WELSH - Standard Industrial Classification (SIC) code",
"headingEmail" : "WELSH - Registered email address",
"headingTerm" : "WELSH - Term of partnership",
"confirm" : "WELSH - Confirm this statement",
"futureLawful" : "WELSH - I confirm that the intended future activities of the limited partnership are lawful.",
"payment" : "WELSH - Continue to payment"
},

"emailPage" : {
"whatIsEmail" : "WELSH - What is the registered email address for the partnership?",
"emailHint" : "WELSH - Partners must be able to access emails that are sent to this address.",
Expand Down
12 changes: 12 additions & 0 deletions locales/en/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@
"saveAndContinue" : "Save and continue"
},

"checkYourAnswersPage" : {
"title" : "Check your answers before sending your application",
"lpInfo" : "Limited partnership information",
"headingName" : "Partnership Name",
"headingSic" : "Standard Industrial Classification (SIC) code",
"headingEmail" : "Registered email address",
"headingTerm" : "Term of partnership",
"confirm" : "Confirm this statement",
"futureLawful" : "I confirm that the intended future activities of the limited partnership are lawful.",
"payment" : "Continue to payment"
},

"emailPage" : {
"whatIsEmail" : "What is the registered email address for the partnership?",
"emailHint" : "Partners must be able to access emails that are sent to this address.",
Expand Down
1 change: 1 addition & 0 deletions src/presentation/controller/registration/PageType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ enum RegistrationPageType {
limitedPartners = "limited-partners",
generalPartnerChoice = "general-partner-choice",
limitedPartnerChoice = "limited-partner-choice",
checkYourAnswers = "check-your-answers",
next = "next"
}

Expand Down
12 changes: 10 additions & 2 deletions src/presentation/controller/registration/Routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,19 @@ const registrationRoutingLimitedPartners = {
export const registrationRoutingLimitedPartnerChoice = {
previousUrl: url.LIMITED_PARTNERS_URL,
currentUrl: url.LIMITED_PARTNER_CHOICE_URL,
nextUrl: url.NEXT_URL,
nextUrl: url.CHECK_YOUR_ANSWERS_URL,
pageType: RegistrationPageType.limitedPartnerChoice
};

const registrationRoutingNext = {
export const registrationRoutingCheckYourAnswers = {
previousUrl: url.LIMITED_PARTNER_CHOICE_URL,
currentUrl: url.CHECK_YOUR_ANSWERS_URL,
nextUrl: url.NEXT_URL,
pageType: RegistrationPageType.checkYourAnswers,
};

const registrationRoutingNext = {
previousUrl: url.CHECK_YOUR_ANSWERS_URL,
currentUrl: url.NEXT_URL,
nextUrl: "/",
pageType: RegistrationPageType.next
Expand All @@ -71,6 +78,7 @@ const list = [
registrationRoutingLimitedPartners,
registrationRoutingGeneralPartnerChoice,
registrationRoutingLimitedPartnerChoice,
registrationRoutingCheckYourAnswers,
registrationRoutingNext
];

Expand Down
1 change: 1 addition & 0 deletions src/presentation/controller/registration/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ export const GENERAL_PARTNER_CHOICE_TEMPLATE =
RegistrationPageType.generalPartnerChoice;
export const LIMITED_PARTNER_CHOICE_TEMPLATE =
RegistrationPageType.limitedPartnerChoice;
export const CHECK_YOUR_ANSWERS_TEMPLATE = RegistrationPageType.checkYourAnswers;
export const NEXT_TEMPLATE = RegistrationPageType.next;
1 change: 1 addition & 0 deletions src/presentation/controller/registration/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ export const GENERAL_PARTNER_CHOICE_URL = `${BASE_WITH_IDS_URL}/${template.GENER

export const LIMITED_PARTNERS_URL = `${BASE_WITH_IDS_URL}/${template.LIMITED_PARTNERS_TEMPLATE}`;
export const LIMITED_PARTNER_CHOICE_URL = `${BASE_WITH_IDS_URL}/${template.LIMITED_PARTNER_CHOICE_TEMPLATE}`;
export const CHECK_YOUR_ANSWERS_URL = `${BASE_WITH_IDS_URL}/${template.CHECK_YOUR_ANSWERS_TEMPLATE}`;
export const NEXT_URL = `${BASE_WITH_IDS_URL}/${template.NEXT_TEMPLATE}`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import request from "supertest";
import app from "../app";
import { CHECK_YOUR_ANSWERS_URL } from "../../../controller/registration/url";
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 { appDevDependencies } from "../../../../config/dev-dependencies";
import LimitedPartnershipBuilder from "../../builder/LimitedPartnershipBuilder";

describe("Check Your Answers Page", () => {
const setLocalesEnabled = (bool: boolean) => {
jest.spyOn(config, "isLocalesEnabled").mockReturnValue(bool);
LocalesService.getInstance().enabled = bool;
};

it("should GET Check Your Answers Page English text", async () => {
setLocalesEnabled(true);
const res = await request(app).get(CHECK_YOUR_ANSWERS_URL + "?lang=en");

expect(res.status).toBe(200);
expect(res.text).toContain(enTranslationText.checkYourAnswersPage.title);
expect(res.text).toContain(enTranslationText.checkYourAnswersPage.lpInfo);
expect(res.text).toContain(enTranslationText.checkYourAnswersPage.headingName);
expect(res.text).toContain(enTranslationText.checkYourAnswersPage.headingSic);
expect(res.text).toContain(enTranslationText.checkYourAnswersPage.headingEmail);
expect(res.text).toContain(enTranslationText.checkYourAnswersPage.headingTerm);
expect(res.text).toContain(enTranslationText.checkYourAnswersPage.confirm);
expect(res.text).toContain(enTranslationText.checkYourAnswersPage.futureLawful);
expect(res.text).toContain(enTranslationText.checkYourAnswersPage.payment);
expect(res.text).not.toContain("WELSH -");
});

it("should GET Check Your Answers Page Welsh text", async () => {
setLocalesEnabled(true);
const res = await request(app).get(CHECK_YOUR_ANSWERS_URL + "?lang=cy");

expect(res.status).toBe(200);
expect(res.text).toContain(cyTranslationText.checkYourAnswersPage.title);
expect(res.text).toContain(cyTranslationText.checkYourAnswersPage.lpInfo);
expect(res.text).toContain(cyTranslationText.checkYourAnswersPage.headingName);
expect(res.text).toContain(cyTranslationText.checkYourAnswersPage.headingSic);
expect(res.text).toContain(cyTranslationText.checkYourAnswersPage.headingEmail);
expect(res.text).toContain(cyTranslationText.checkYourAnswersPage.headingTerm);
expect(res.text).toContain(cyTranslationText.checkYourAnswersPage.confirm);
expect(res.text).toContain(cyTranslationText.checkYourAnswersPage.futureLawful);
expect(res.text).toContain(cyTranslationText.checkYourAnswersPage.payment);
expect(res.text).toContain("WELSH -");
});

it("should load the check your answers page with data from api", async () => {
const limitedPartnership = new LimitedPartnershipBuilder().build();
appDevDependencies.limitedPartnershipGateway.feedLimitedPartnerships([
limitedPartnership
]);
const res = await request(app).get(CHECK_YOUR_ANSWERS_URL);

expect(res.status).toBe(200);
expect(res.text).toContain(limitedPartnership?.data?.partnership_name);
expect(res.text).toContain(limitedPartnership?.data?.email);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import cyTranslationText from "../../../../../locales/cy/translations.json";
import app from "../app";
import {
LIMITED_PARTNER_CHOICE_URL,
NEXT_URL
CHECK_YOUR_ANSWERS_URL
} from "../../../controller/registration/url";
import { registrationRoutingLimitedPartnerChoice } from "../../../controller/registration/Routing";
import RegistrationPageType from "../../../controller/registration/PageType";
Expand Down Expand Up @@ -77,7 +77,7 @@ describe("Limited Partner Choice Page", () => {
expect(res.status).toBe(302);
const nextPageUrl =
appDevDependencies.registrationController.insertIdsInUrl(
NEXT_URL,
CHECK_YOUR_ANSWERS_URL,
transactionId,
submissionId
);
Expand Down
13 changes: 13 additions & 0 deletions src/routes/registration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
GENERAL_PARTNERS_URL,
GENERAL_PARTNER_CHOICE_URL,
LIMITED_PARTNER_CHOICE_URL,
CHECK_YOUR_ANSWERS_URL,
NAME_WITH_IDS_URL
} from "../presentation/controller/registration/url";

Expand Down Expand Up @@ -101,6 +102,18 @@ export const registrationEndpoints = (
dependencies.registrationController.redirectAndCacheSelection()
);

router.get(
CHECK_YOUR_ANSWERS_URL,
authentication,
dependencies.registrationController.getPageRouting()
);

router.post(
CHECK_YOUR_ANSWERS_URL,
authentication,
dependencies.registrationController.redirectAndCacheSelection()
);

router.get(
NEXT_URL,
authentication,
Expand Down
123 changes: 123 additions & 0 deletions src/views/check-your-answers.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
{% extends "layout.njk" %}

{% set pageTitle = title %}

{% block content %}

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds-from-desktop">
<h1 class="govuk-heading-l">{{ i18n.checkYourAnswersPage.title }}</h1>
<h2 class="govuk-heading-m">{{ i18n.checkYourAnswersPage.lpInfo }}</h2>
{{ govukSummaryList({
classes: "govuk-!-margin-bottom-9",
rows: [
{
key: {
text: i18n.checkYourAnswersPage.headingName
},
value: {
text: props.data.limitedPartnership.data.partnership_name
},
actions: {
items: [
{
href: "javascript:void(0)",
text: "Change",
visuallyHiddenText: "Name"
}
]
}
},
{
key: {
text: i18n.checkYourAnswersPage.headingSic
},
value: {
text: "62012 - Business and domestic software development"
},
actions: {
items: [
{
href: "javascript:void(0)",
text: "Change",
visuallyHiddenText: "Standard Industrial Classification code"
}
]
}
},
{
key: {
text: i18n.checkYourAnswersPage.headingEmail
},
value: {
text: props.data.limitedPartnership.data.email
},
actions: {
items: [
{
href: "javascript:void(0)",
text: "Change",
visuallyHiddenText: "registered email address"
}
]
}
},
{
key: {
text: i18n.checkYourAnswersPage.headingTerm
},
value: {
text: data['term-of-partners'] or "Term will be decided by some or all of the partners"
},
actions: {
items: [
{
href: "javascript:void(0)",
text: "Change",
visuallyHiddenText: "term of partnership"
}
]
}
}
]
}) }}

<br>
<div class="govuk-button-group">
<form class="form" action={{ props.currentUrl }} method="post">
<input type="hidden" name="pageType" value={{ props.pageType }}>
{% include "includes/csrf_token.njk" %}

{{ govukCheckboxes({
name: "lpStatement",
fieldset: {
legend: {
text: i18n.checkYourAnswersPage.confirm,
isPageHeading: false,
classes: "govuk-visually-hidden"
}
},
items: [
{
value: "lp-statement",
text: i18n.checkYourAnswersPage.futureLawful,
attributes: {
required: true
}
}
]
}) }}

{{ govukButton({
text: i18n.checkYourAnswersPage.payment,
attributes: {
"id": "submit",
"data-event-id": "check-your-answers-continue-to-payment-page-button"
}
}) }}
</form>
</div>
</div>
</div>

{% endblock %}
2 changes: 2 additions & 0 deletions src/views/layout.njk
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

{% from "govuk/components/back-link/macro.njk" import govukBackLink %}
{% from "govuk/components/button/macro.njk" import govukButton %}
{% from "govuk/components/checkboxes/macro.njk" import govukCheckboxes %}
{% from "govuk/components/error-summary/macro.njk" import govukErrorSummary %}
{% from "govuk/components/input/macro.njk" import govukInput %}
{% from "govuk/components/inset-text/macro.njk" import govukInsetText %}
{% from "govuk/components/phase-banner/macro.njk" import govukPhaseBanner %}
{% from "govuk/components/radios/macro.njk" import govukRadios %}
{% from "web-security-node/components/csrf-token-input/macro.njk" import csrfTokenInput %}
{% from "govuk/components/summary-list/macro.njk" import govukSummaryList %}

{% import "ch-node-utils/templates/add-lang-to-url.njk" as lang2url %}

Expand Down

0 comments on commit f7c389b

Please sign in to comment.