diff --git a/src/app.constants.ts b/src/app.constants.ts index faad4960aa..73dab1f491 100644 --- a/src/app.constants.ts +++ b/src/app.constants.ts @@ -244,6 +244,7 @@ export enum JOURNEY_TYPE { export enum CHANNEL { WEB = "web", STRATEGIC_APP = "strategic_app", + GENERIC_APP = "generic_app", } export const ENVIRONMENT_NAME = { diff --git a/src/components/account-created/account-created-controller.ts b/src/components/account-created/account-created-controller.ts index d3e16cc882..bc15b232d3 100644 --- a/src/components/account-created/account-created-controller.ts +++ b/src/components/account-created/account-created-controller.ts @@ -7,7 +7,6 @@ export function accountCreatedGet(req: Request, res: Response): void { res.render("account-created/index.njk", { serviceType, name, - strategicAppChannel: res.locals.strategicAppChannel, }); } diff --git a/src/components/account-created/index.njk b/src/components/account-created/index.njk index e215eabc79..f06fa99e48 100644 --- a/src/components/account-created/index.njk +++ b/src/components/account-created/index.njk @@ -20,7 +20,7 @@ }) }} {% else %} - {% if strategicAppChannel === true %} + {% if isApp %}

{{'mobileAppPages.accountCreated.text' | translate}}

{% else %}

{{'pages.accountCreated.text' | translate}}

diff --git a/src/components/account-created/tests/account-created-controller.test.ts b/src/components/account-created/tests/account-created-controller.test.ts index 4cc3162e3c..a7e9077d37 100644 --- a/src/components/account-created/tests/account-created-controller.test.ts +++ b/src/components/account-created/tests/account-created-controller.test.ts @@ -34,21 +34,8 @@ describe("account created controller", () => { expect(res.render).to.have.been.calledWith("account-created/index.njk"); }); - - it("should pass through the strategicAppChannel", () => { - req.session.client.serviceType = "MANDATORY"; - req.session.client.name = "test client name"; - res.locals.strategicAppChannel = true; - - accountCreatedGet(req as Request, res as Response); - - expect(res.render).to.have.been.calledWith("account-created/index.njk", { - serviceType: "MANDATORY", - name: "test client name", - strategicAppChannel: true, - }); - }); }); + describe("accountCreatedPost", () => { it("should redirect to auth code", async () => { await accountCreatedPost(req as Request, res as Response); diff --git a/src/components/account-not-found/account-not-found-controller.ts b/src/components/account-not-found/account-not-found-controller.ts index f10ace29d2..ee52739ad8 100644 --- a/src/components/account-not-found/account-not-found-controller.ts +++ b/src/components/account-not-found/account-not-found-controller.ts @@ -17,7 +17,7 @@ export function accountNotFoundGet(req: Request, res: Response): void { const template: string = getAccountNotFoundTemplate( clientIsOneLogin(req), req.session.client.serviceType, - res.locals.strategicAppChannel + res.locals.isApp ); res.render(template, { diff --git a/src/components/account-not-found/get-account-not-found-template.ts b/src/components/account-not-found/get-account-not-found-template.ts index c8f0a7d898..990c8d130a 100644 --- a/src/components/account-not-found/get-account-not-found-template.ts +++ b/src/components/account-not-found/get-account-not-found-template.ts @@ -6,7 +6,7 @@ import { getChannelSpecificTemplate } from "../../utils/get-channel-specific-tem export function getAccountNotFoundTemplate( isOneLoginService: boolean, serviceType: string, - isStrategicAppChannel: boolean + isApp: boolean ): string { let webTemplate; @@ -20,7 +20,7 @@ export function getAccountNotFoundTemplate( return getChannelSpecificTemplate( webTemplate, - isStrategicAppChannel, + isApp, WEB_TO_MOBILE_TEMPLATE_MAPPINGS ); } diff --git a/src/components/account-not-found/tests/account-not-found-controller.test.ts b/src/components/account-not-found/tests/account-not-found-controller.test.ts index 49d5091945..dab62e1099 100644 --- a/src/components/account-not-found/tests/account-not-found-controller.test.ts +++ b/src/components/account-not-found/tests/account-not-found-controller.test.ts @@ -25,7 +25,7 @@ describe("account not found controller", () => { }); describe("accountNotFoundGet", () => { - describe("when strategicAppChannel is not defined", () => { + describe("when isApp is not defined", () => { it("should render the account not found mandatory view when serviceType undefined", () => { accountNotFoundGet(req, res); @@ -53,9 +53,9 @@ describe("account not found controller", () => { }); }); - describe("when strategicAppChannel is false", () => { + describe("when isApp is false", () => { beforeEach(() => { - res.locals.strategicAppChannel = false; + res.locals.isApp = false; }); it("should render the account not found mandatory view when serviceType undefined", () => { @@ -85,9 +85,9 @@ describe("account not found controller", () => { }); }); - describe("when strategicAppChannel is true", () => { + describe("when isApp is true", () => { beforeEach(() => { - res.locals.strategicAppChannel = true; + res.locals.isApp = true; }); it("should render the account not found mandatory view when serviceType undefined", () => { @@ -100,6 +100,7 @@ describe("account not found controller", () => { it("should render the account not found optional view when serviceType optional", () => { req.session.client.serviceType = SERVICE_TYPE.OPTIONAL; + accountNotFoundGet(req, res); expect(res.render).to.have.calledWith( @@ -109,6 +110,7 @@ describe("account not found controller", () => { it("should render the account not found optional view when the service is part of One Login", () => { req.session.client.isOneLoginService = true; + accountNotFoundGet(req, res); expect(res.render).to.have.calledWith( diff --git a/src/components/account-not-found/tests/get-account-not-found-template.test.ts b/src/components/account-not-found/tests/get-account-not-found-template.test.ts index 53e648d7ff..2a41f5ce9b 100644 --- a/src/components/account-not-found/tests/get-account-not-found-template.test.ts +++ b/src/components/account-not-found/tests/get-account-not-found-template.test.ts @@ -3,7 +3,7 @@ import { describe } from "mocha"; import { getAccountNotFoundTemplate } from "../get-account-not-found-template.js"; import { SERVICE_TYPE } from "../../../app.constants.js"; describe("getAccountNotFoundWebTemplate", () => { - describe("when isStrategicApp is false", () => { + describe("when isApp is false", () => { describe("when isOneLoginService is true", () => { it("should always return 'account-not-found/index-one-login.njk'", () => { [SERVICE_TYPE.OPTIONAL, SERVICE_TYPE.MANDATORY].forEach((i) => { @@ -31,7 +31,7 @@ describe("getAccountNotFoundWebTemplate", () => { }); }); - describe("when isStrategicApp is true", () => { + describe("when isApp is true", () => { describe("when isOneLoginService is true", () => { it("should always return 'account-not-found/index-mobile.njk'", () => { [SERVICE_TYPE.OPTIONAL, SERVICE_TYPE.MANDATORY].forEach((i) => { diff --git a/src/components/common/errors/session-expired.njk b/src/components/common/errors/session-expired.njk index 647333235f..35396e974e 100644 --- a/src/components/common/errors/session-expired.njk +++ b/src/components/common/errors/session-expired.njk @@ -9,7 +9,7 @@

{{ 'error.timeoutError.content.paragraph1' | translate }}

{{ 'error.timeoutError.content.whatYouCanDo' | translate }}

- {% if strategicAppChannel === true %} + {% if isApp %}

{{ 'mobileAppError.timeoutError.content.paragraph2' | translate }}

{% else %}

{{ 'error.timeoutError.content.paragraph2' | translate }}

diff --git a/src/components/common/layout/base.njk b/src/components/common/layout/base.njk index 9944e5dfd0..262fa135cd 100644 --- a/src/components/common/layout/base.njk +++ b/src/components/common/layout/base.njk @@ -6,7 +6,7 @@ {% from "../header/macro.njk" import strategicAppHeader %} -{% if strategicAppChannel == true %} +{% if isApp %} {% set htmlClasses = 'govuk-template__mobile' %} {% endif %} @@ -53,7 +53,7 @@ {% set phaseBannerClasses = "test-banner" if showTestBanner %} {% block header %} - {% if strategicAppChannel %} + {% if isApp %} {{ strategicAppHeader({ useTudorCrown: true, classes: phaseBannerClasses @@ -90,7 +90,7 @@ {% block main %}
- {% if strategicAppChannel === true %} + {% if isApp %} {% else %} {{ govukPhaseBanner({ tag: { @@ -140,7 +140,7 @@ {% endblock %} {% block footer %} -{% if strategicAppChannel === true %} +{% if isApp %} {% else %} {{ govukFooter({ diff --git a/src/components/common/layout/tests/base-integration.test.ts b/src/components/common/layout/tests/base-integration.test.ts index 81294c42bf..147d884925 100644 --- a/src/components/common/layout/tests/base-integration.test.ts +++ b/src/components/common/layout/tests/base-integration.test.ts @@ -43,8 +43,11 @@ describe("Integration:: base page ", () => { res.locals.sessionId = "tDy103saszhcxbQq0-mjdzU854"; if (channel === CHANNEL.WEB) { res.locals.webChannel = true; - } else if (channel === CHANNEL.STRATEGIC_APP) { - res.locals.strategicAppChannel = true; + } else if ( + channel === CHANNEL.STRATEGIC_APP || + channel === CHANNEL.GENERIC_APP + ) { + res.locals.isApp = true; } req.session.client = { @@ -132,41 +135,45 @@ describe("Integration:: base page ", () => { }); }); - describe("Strategic App channel", () => { + describe("App (strategic app and generic app) channels", () => { + const testCases = [CHANNEL.STRATEGIC_APP, CHANNEL.GENERIC_APP]; let $: any; - before(async () => { - await setupApp(CHANNEL.STRATEGIC_APP, true); - const response = await request(app).get(PATH_NAMES.SIGN_IN_OR_CREATE); - expect(response.status).to.equal(200); - $ = cheerio.load(response.text); - }); - - it("should render the custom header with no links", async () => { - expect($("a.govuk-header__link").length).to.equal(0); - expect($(".strategic-app-header").length).to.equal(1); - }); - it("should not render the footer", async () => { - expect($(".govuk-footer").length).to.equal(0); - }); - - describe("when in a non-production environment", () => { - it("should render the test phase header css", async () => { - expect($(".govuk-header").hasClass("test-banner")).to.be.true; - }); - }); - - describe("when in a production environment", () => { - let $: any; + testCases.forEach((channel) => { before(async () => { - await setupApp(CHANNEL.STRATEGIC_APP, false); + await setupApp(channel, true); const response = await request(app).get(PATH_NAMES.SIGN_IN_OR_CREATE); expect(response.status).to.equal(200); $ = cheerio.load(response.text); }); - it("should not render the test phase header css", async () => { - expect($(".govuk-header").hasClass("test-banner")).to.be.false; + it("should render the custom header with no links", async () => { + expect($("a.govuk-header__link").length).to.equal(0); + expect($(".strategic-app-header").length).to.equal(1); + }); + + it("should not render the footer", async () => { + expect($(".govuk-footer").length).to.equal(0); + }); + + describe("when in a non-production environment", () => { + it("should render the test phase header css", async () => { + expect($(".govuk-header").hasClass("test-banner")).to.be.true; + }); + }); + + describe("when in a production environment", () => { + let $: any; + before(async () => { + await setupApp(CHANNEL.STRATEGIC_APP, false); + const response = await request(app).get(PATH_NAMES.SIGN_IN_OR_CREATE); + expect(response.status).to.equal(200); + $ = cheerio.load(response.text); + }); + + it("should not render the test phase header css", async () => { + expect($(".govuk-header").hasClass("test-banner")).to.be.false; + }); }); }); }); diff --git a/src/components/enter-email/enter-email-controller.ts b/src/components/enter-email/enter-email-controller.ts index 8941246592..6b7b98dc60 100644 --- a/src/components/enter-email/enter-email-controller.ts +++ b/src/components/enter-email/enter-email-controller.ts @@ -48,18 +48,14 @@ export function enterEmailGet(req: Request, res: Response): void { if (isLocked(req.session.user.wrongEmailEnteredLock)) { return res.render(BLOCKED_TEMPLATE); } - return res.render(RE_ENTER_EMAIL_TEMPLATE, { - isStrategicAppReauth: res.locals.strategicAppChannel, - }); + return res.render(RE_ENTER_EMAIL_TEMPLATE); } return res.render(ENTER_EMAIL_TEMPLATE); } export function enterEmailCreateGet(req: Request, res: Response): void { - return res.render("enter-email/index-create-account.njk", { - strategicAppChannel: res.locals.strategicAppChannel, - }); + return res.render("enter-email/index-create-account.njk"); } export async function enterEmailCreateRequestGet( @@ -103,7 +99,7 @@ export function enterEmailPost( const CHANNEL_SPECIFIC_EMAIL_ERROR_KEY = getChannelSpecificErrorMessage( EMAIL_ERROR_KEY, - req.body.isStrategicAppReauth === "true", + res.locals.isApp, WEB_TO_MOBILE_ERROR_MESSAGE_MAPPINGS ); diff --git a/src/components/enter-email/index-create-account.njk b/src/components/enter-email/index-create-account.njk index 19b413c7d9..a57d7d3892 100644 --- a/src/components/enter-email/index-create-account.njk +++ b/src/components/enter-email/index-create-account.njk @@ -36,7 +36,7 @@

{{'pages.createPassword.termsOfUse.paragraph1' | translate}}

-{% if strategicAppChannel %} +{% if isApp %} {% set bullet1LinkText = 'pages.createPassword.termsOfUse.bullet1LinkTextApp' %} {% set bullet2LinkText = 'pages.createPassword.termsOfUse.bullet2LinkTextApp' %} {% else %} diff --git a/src/components/enter-email/index-re-enter-email-account.njk b/src/components/enter-email/index-re-enter-email-account.njk index 2675f7e823..697c02de4c 100644 --- a/src/components/enter-email/index-re-enter-email-account.njk +++ b/src/components/enter-email/index-re-enter-email-account.njk @@ -14,13 +14,13 @@
- +

{{ 'pages.reEnterEmailAccount.header' | translate }}

- {% if isStrategicAppReauth %} + {% if isApp %}

{{'mobileAppPages.reEnterEmailAccount.paragraph1' | translate}}

{% else %}

{{'pages.reEnterEmailAccount.paragraph1' | translate}}

diff --git a/src/components/enter-email/tests/enter-email-controller.test.ts b/src/components/enter-email/tests/enter-email-controller.test.ts index 776de80e8c..00a9cb1c45 100644 --- a/src/components/enter-email/tests/enter-email-controller.test.ts +++ b/src/components/enter-email/tests/enter-email-controller.test.ts @@ -55,19 +55,14 @@ describe("enter email controller", () => { req.session.user = { email }; }); - it("should render enter email create account view with the strategic app channel passed through when user selected create account", () => { - const STRATEGIC_APP_VALUES = [true, false]; - STRATEGIC_APP_VALUES.forEach((strategicAppChannel) => { - res.locals.strategicAppChannel = strategicAppChannel; - req.query.type = JOURNEY_TYPE.CREATE_ACCOUNT; + it("should render enter email create account view", () => { + req.query.type = JOURNEY_TYPE.CREATE_ACCOUNT; - enterEmailCreateGet(req as Request, res as Response); + enterEmailCreateGet(req as Request, res as Response); - expect(res.render).to.have.calledWith( - "enter-email/index-create-account.njk", - { strategicAppChannel: strategicAppChannel } - ); - }); + expect(res.render).to.have.calledWith( + "enter-email/index-create-account.njk" + ); }); it("should render enter email view when supportReauthentication flag is switched off", async () => { @@ -112,12 +107,13 @@ describe("enter email controller", () => { it("should render enter password view when isReautheticationRequired is true and check service returns successfully", async () => { process.env.SUPPORT_REAUTHENTICATION = "1"; + req.session.user = { email, reauthenticate: "12345", }; - await enterEmailGet(req as Request, res as Response); + enterEmailGet(req as Request, res as Response); expect(res.render).to.have.calledWith( "enter-email/index-re-enter-email-account.njk" diff --git a/src/components/enter-password/index-account-locked.njk b/src/components/enter-password/index-account-locked.njk index 02f8afc198..3f75e99c6a 100644 --- a/src/components/enter-password/index-account-locked.njk +++ b/src/components/enter-password/index-account-locked.njk @@ -17,7 +17,7 @@

{{'pages.accountLocked.bulletPointSection.title' | translate}}