Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/app.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export function accountCreatedGet(req: Request, res: Response): void {
res.render("account-created/index.njk", {
serviceType,
name,
Comment thread
GHSwallow marked this conversation as resolved.
strategicAppChannel: res.locals.strategicAppChannel,
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/account-created/index.njk
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
}) }}
{% else %}

{% if strategicAppChannel === true %}
{% if isApp %}
<p class="govuk-body">{{'mobileAppPages.accountCreated.text' | translate}}</p>
{% else %}
<p class="govuk-body">{{'pages.accountCreated.text' | translate}}</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -20,7 +20,7 @@ export function getAccountNotFoundTemplate(

return getChannelSpecificTemplate(
webTemplate,
isStrategicAppChannel,
isApp,
WEB_TO_MOBILE_TEMPLATE_MAPPINGS
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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", () => {
Expand Down Expand Up @@ -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", () => {
Expand All @@ -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(
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/errors/session-expired.njk
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<p class="govuk-body">{{ 'error.timeoutError.content.paragraph1' | translate }}</p>
<p class="govuk-heading-m">{{ 'error.timeoutError.content.whatYouCanDo' | translate }}</p>

{% if strategicAppChannel === true %}
{% if isApp %}
<p class="govuk-body">{{ 'mobileAppError.timeoutError.content.paragraph2' | translate }}</p>
{% else %}
<p class="govuk-body">{{ 'error.timeoutError.content.paragraph2' | translate }}</p>
Expand Down
8 changes: 4 additions & 4 deletions src/components/common/layout/base.njk
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

{% from "../header/macro.njk" import strategicAppHeader %}

{% if strategicAppChannel == true %}
{% if isApp %}
Comment thread
GHSwallow marked this conversation as resolved.
{% set htmlClasses = 'govuk-template__mobile' %}
{% endif %}

Expand Down Expand Up @@ -53,7 +53,7 @@
{% set phaseBannerClasses = "test-banner" if showTestBanner %}

{% block header %}
{% if strategicAppChannel %}
{% if isApp %}
{{ strategicAppHeader({
useTudorCrown: true,
classes: phaseBannerClasses
Expand Down Expand Up @@ -90,7 +90,7 @@

{% block main %}
<div class="govuk-width-container {{ containerClasses }}">
{% if strategicAppChannel === true %}
{% if isApp %}
{% else %}
{{ govukPhaseBanner({
tag: {
Expand Down Expand Up @@ -140,7 +140,7 @@
{% endblock %}

{% block footer %}
{% if strategicAppChannel === true %}
{% if isApp %}

{% else %}
{{ govukFooter({
Expand Down
65 changes: 36 additions & 29 deletions src/components/common/layout/tests/base-integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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;
});
});
});
});
Expand Down
10 changes: 3 additions & 7 deletions src/components/enter-email/enter-email-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
);

Expand Down
2 changes: 1 addition & 1 deletion src/components/enter-email/index-create-account.njk
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

<p class="govuk-body">{{'pages.createPassword.termsOfUse.paragraph1' | translate}}</p>

{% if strategicAppChannel %}
{% if isApp %}
{% set bullet1LinkText = 'pages.createPassword.termsOfUse.bullet1LinkTextApp' %}
{% set bullet2LinkText = 'pages.createPassword.termsOfUse.bullet2LinkTextApp' %}
{% else %}
Expand Down
4 changes: 2 additions & 2 deletions src/components/enter-email/index-re-enter-email-account.njk
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
<form action="/enter-email" method="post" novalidate>

<input type="hidden" name="_csrf" value="{{csrfToken}}"/>
<input type="hidden" name="isStrategicAppReauth" value="{{isStrategicAppReauth}}"/>
<input type="hidden" name="isApp" value="{{isApp}}"/>

<h1 class="govuk-heading-l">
{{ 'pages.reEnterEmailAccount.header' | translate }}
</h1>

{% if isStrategicAppReauth %}
{% if isApp %}
<p class="govuk-body">{{'mobileAppPages.reEnterEmailAccount.paragraph1' | translate}}</p>
{% else %}
<p class="govuk-body">{{'pages.reEnterEmailAccount.paragraph1' | translate}}</p>
Expand Down
20 changes: 8 additions & 12 deletions src/components/enter-email/tests/enter-email-controller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/components/enter-password/index-account-locked.njk
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<p class="govuk-body">{{'pages.accountLocked.bulletPointSection.title' | translate}}</p>
<ul class="govuk-list govuk-list--bullet">
<li><a href="/reset-password-request" class="govuk-link">{{'pages.accountLocked.bulletPointSection.first' | translate}}</a></li>
{% if strategicAppChannel === true %}
{% if isApp %}
<li>{{'mobileAppPages.accountLocked.bulletPointSection.second' | translate}}</li>
{% else %}
<li>{{'pages.accountLocked.bulletPointSection.second' | translate}}</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<p class="govuk-body">{{'pages.signInRetryBlocked.paragraph' | translate}}</p>

<h2 class="govuk-heading-m">{{'pages.signInRetryBlocked.subHeader' | translate}}</h2>
{% if strategicAppChannel === true %}
{% if isApp %}
<p class="govuk-body strategic-app-retry-options">
<a href="/reset-password-request" class="govuk-link">{{ 'mobileAppPages.signInRetryBlocked.whatCanYouDo.resetYourPassword' | translate }}</a>
<span class="govuk-visually-hidden">.</span><br>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function mfaResetWithIpvGet(
);
}

if (res.locals.strategicAppChannel === true) {
if (res.locals.isApp) {
Comment thread
alhcomer marked this conversation as resolved.
const redirectPath = await getNextPathAndUpdateJourney(
req,
req.path,
Expand Down
Loading
Loading