-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #90 from companieshouse/lp-239-lp-person-or-legal-…
…entity LP-239 Add the limited partner choice page
- Loading branch information
Showing
11 changed files
with
173 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
src/presentation/test/integration/registration/limited-partner-choice.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import request from "supertest"; | ||
import { LocalesService } from "@companieshouse/ch-node-utils"; | ||
import * as constants from "../../../../config/constants"; | ||
import { appDevDependencies } from "../../../../config"; | ||
import enTranslationText from "../../../../../locales/en/translations.json"; | ||
import cyTranslationText from "../../../../../locales/cy/translations.json"; | ||
import app from "../app"; | ||
import { | ||
LIMITED_PARTNER_CHOICE_URL, | ||
NEXT_URL, | ||
registrationRoutingLimitedPartnerChoice, | ||
} from "../../../controller/registration/Routing"; | ||
import RegistrationPageType from "../../../controller/registration/PageType"; | ||
|
||
describe("Limited Partner Choice Page", () => { | ||
beforeEach(() => { | ||
setLocalesEnabled(false); | ||
}); | ||
|
||
const setLocalesEnabled = (bool: boolean) => { | ||
jest.spyOn(constants, "isLocalesEnabled").mockReturnValue(bool); | ||
LocalesService.getInstance().enabled = bool; | ||
}; | ||
|
||
it("should load the limited partner choice page with Welsh text", async () => { | ||
setLocalesEnabled(true); | ||
const res = await request(app).get(LIMITED_PARTNER_CHOICE_URL + "?lang=cy"); | ||
|
||
expect(res.status).toBe(200); | ||
expect(res.text).toContain(cyTranslationText.limitedPartnerChoicePage.isPersonOrLegalEntity); | ||
}); | ||
|
||
it("should load the limited partner choice page with English text", async () => { | ||
setLocalesEnabled(true); | ||
const res = await request(app).get(LIMITED_PARTNER_CHOICE_URL + "?lang=en"); | ||
|
||
expect(res.status).toBe(200); | ||
expect(res.text).toContain(enTranslationText.limitedPartnerChoicePage.isPersonOrLegalEntity); | ||
}); | ||
|
||
it("should pass the limited partner choice as a url query param to next page", async () => { | ||
const transactionId = "3664373"; | ||
const submissionId = "1543454"; | ||
const selectedChoice = "person"; | ||
|
||
const url = appDevDependencies.registrationController.insertIdsInUrl( | ||
LIMITED_PARTNER_CHOICE_URL, | ||
transactionId, | ||
submissionId | ||
); | ||
|
||
const res = await request(app) | ||
.post(url) | ||
.send({ | ||
pageType: registrationRoutingLimitedPartnerChoice.pageType, | ||
parameter: selectedChoice, | ||
}); | ||
|
||
expect(res.status).toBe(302); | ||
const nextPageUrl = appDevDependencies.registrationController.insertIdsInUrl( | ||
NEXT_URL, | ||
transactionId, | ||
submissionId | ||
) + `?${RegistrationPageType.limitedPartnerChoice}=${selectedChoice}`; | ||
expect(res.header.location).toEqual(nextPageUrl); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{% extends "layout.njk" %} | ||
|
||
{% block content %} | ||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds"> | ||
|
||
<form class="form" action="{{ props.currentUrl }}" method="post"> | ||
<input type="hidden" name="pageType" value={{ props.pageType }}> | ||
{% include "includes/csrf_token.njk" %} | ||
|
||
{{ govukRadios({ | ||
name: "parameter", | ||
value: props.data.limitedPartnership.limited_partner, | ||
fieldset: { | ||
legend: { | ||
text: i18n.limitedPartnerChoicePage.isPersonOrLegalEntity, | ||
isPageHeading: true, | ||
classes: "govuk-fieldset__legend--xl" | ||
} | ||
}, | ||
hint: { | ||
text: i18n.limitedPartnerChoicePage.isPersonOrLegalEntityHint | ||
}, | ||
items: [ | ||
{ | ||
value: "person", | ||
text: i18n.limitedPartnerChoicePage.person, | ||
attributes : { | ||
required : true | ||
} | ||
}, | ||
{ | ||
value: "legal_entity", | ||
text: i18n.limitedPartnerChoicePage.legalEntity, | ||
attributes : { | ||
required : true | ||
} | ||
} | ||
] | ||
}) }} | ||
|
||
{% include "includes/save-and-continue-button.njk" %} | ||
</form> | ||
</div> | ||
</div> | ||
{% endblock %} |