-
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.
- Loading branch information
Showing
10 changed files
with
295 additions
and
7 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
50 changes: 50 additions & 0 deletions
50
src/presentation/test/integration/registration/general-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,50 @@ | ||
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, | ||
NEXT_URL, | ||
} from "../../../controller/registration/Routing"; | ||
import RegistrationPageType from "../../../../presentation/controller/registration/PageType"; | ||
|
||
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); | ||
}); | ||
|
||
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); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{% 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({ | ||
classes: "govuk-radios", | ||
name: "parameter", | ||
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, | ||
id: "person", | ||
name: "person", | ||
attributes: { | ||
required: true | ||
} | ||
}, | ||
{ | ||
value: "legalEntity", | ||
text: i18n.generalPartnerChoicePage.legalEntity, | ||
id: "legal_entity", | ||
name: "legal_entity", | ||
attributes: { | ||
required: true | ||
} | ||
} | ||
] | ||
}) }} | ||
|
||
{% include "includes/continue-button.njk" %} | ||
</form> | ||
</div> | ||
</div> | ||
{% endblock %} |
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
Oops, something went wrong.