Skip to content

Commit

Permalink
AUT-3779: Add mobile "Account not found" page
Browse files Browse the repository at this point in the history
  • Loading branch information
gtvj committed Nov 7, 2024
1 parent f28e845 commit 84cfd24
Show file tree
Hide file tree
Showing 8 changed files with 214 additions and 76 deletions.
3 changes: 3 additions & 0 deletions src/app.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,4 +298,7 @@ export const ANALYTICS_COOKIES = [...GA_COOKIES, ...DYNATRACE_RUM_COOKIES];

export const WEB_TO_MOBILE_TEMPLATE_MAPPINGS: Record<string, string> = {
"sign-in-or-create/index.njk": "sign-in-or-create/index-mobile.njk",
"account-not-found/index-one-login.njk": "account-not-found/index-mobile.njk",
"account-not-found/index-optional.njk": "account-not-found/index-mobile.njk",
"account-not-found/index-mandatory.njk": "account-not-found/index-mobile.njk",
};
16 changes: 6 additions & 10 deletions src/components/account-not-found/account-not-found-controller.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import { Request, Response } from "express";
import {
JOURNEY_TYPE,
NOTIFICATION_TYPE,
SERVICE_TYPE,
} from "../../app.constants";
import { JOURNEY_TYPE, NOTIFICATION_TYPE } from "../../app.constants";
import { ExpressRouteFunc } from "../../types";
import { SendNotificationServiceInterface } from "../common/send-notification/types";
import { sendNotificationService } from "../common/send-notification/send-notification-service";
Expand All @@ -15,16 +11,16 @@ import {
import { USER_JOURNEY_EVENTS } from "../common/state-machine/state-machine";
import xss from "xss";
import { getServiceSignInLink } from "../../config";
import { getChannelSpecificTemplate } from "../../utils/get-channel-specific-template";
import { getAccountNotFoundWebTemplate } from "./get-account-not-found-web-template";
import { getAccountNotFoundTemplate } from "./get-account-not-found-template";

export function accountNotFoundGet(req: Request, res: Response): void {
const webTemplate: string = getAccountNotFoundWebTemplate(
const template: string = getAccountNotFoundTemplate(
req.session.client.isOneLoginService,
req.session.client.serviceType
req.session.client.serviceType,
res.locals.strategicAppChannel
);

res.render(webTemplate, {
res.render(template, {
email: req.session.user.email,
});
}
Expand Down
27 changes: 27 additions & 0 deletions src/components/account-not-found/get-account-not-found-template.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {
SERVICE_TYPE,
WEB_TO_MOBILE_TEMPLATE_MAPPINGS,
} from "../../app.constants";
import { getChannelSpecificTemplate } from "../../utils/get-channel-specific-template";

export function getAccountNotFoundTemplate(
isOneLoginService: boolean,
serviceType: string,
isStrategicAppChannel: boolean
): string {
let webTemplate;

if (isOneLoginService === true) {
webTemplate = "account-not-found/index-one-login.njk";
} else if (serviceType === SERVICE_TYPE.OPTIONAL) {
webTemplate = "account-not-found/index-optional.njk";
} else {
webTemplate = "account-not-found/index-mandatory.njk";
}

return getChannelSpecificTemplate(
webTemplate,
isStrategicAppChannel,
WEB_TO_MOBILE_TEMPLATE_MAPPINGS
);
}

This file was deleted.

32 changes: 32 additions & 0 deletions src/components/account-not-found/index-mobile.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{% extends "common/layout/base.njk" %}
{% from "govuk/components/button/macro.njk" import govukButton %}
{% from "govuk/components/inset-text/macro.njk" import govukInsetText %}
{% set showBack = true %}
{% set hrefBack = 'enter-email' %}
{% set pageTitleName = 'mobileAppPages.accountNotFound.title' | translate %}

{% block content %}

{% include "common/errors/errorSummary.njk" %}

<h1 class="govuk-heading-l govuk-!-margin-top-0 govuk-!-margin-bottom-3">{{ 'mobileAppPages.accountNotFound.header' | translate }}</h1>

<p class="govuk-body">
{{ 'mobileAppPages.accountNotFound.paragraph1' | translate }}
<span class="govuk-body govuk-!-font-weight-bold">{{ email }}</span>.
</p>

<p class="govuk-body">{{ 'mobileAppPages.accountNotFound.paragraph2' | translate }}</p>

<p class="govuk-body">
<a href="/enter-email" class="govuk-link"
rel="noreferrer noopener">{{ 'mobileAppPages.accountNotFound.tryAnotherLinkText' | translate }}</a>
</p>

<p class="govuk-body">
<a href="https://www.gov.uk/using-your-gov-uk-one-login" class="govuk-link"
rel="noreferrer noopener">{{ 'mobileAppPages.accountNotFound.findOutMoreLinkText' | translate }}</a>
</p>

{{ ga4OnPageLoad({ nonce: scriptNonce, statusCode: "200", englishPageTitle: pageTitleName, taxonomyLevel1: "authentication", taxonomyLevel2: "sign in", contentId: "10e1b70b-e208-4db8-8863-3679a675b51d", loggedInStatus: false, dynamic: false }) }}
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,96 @@ describe("account not found controller", () => {
});

describe("accountNotFoundGet", () => {
it("should render the account not found mandatory view when serviceType undefined", () => {
accountNotFoundGet(req, res);

expect(res.render).to.have.calledWith(
"account-not-found/index-mandatory.njk"
);
describe("when strategicAppChannel is not defined", () => {
it("should render the account not found mandatory view when serviceType undefined", () => {
accountNotFoundGet(req, res);

expect(res.render).to.have.calledWith(
"account-not-found/index-mandatory.njk"
);
});

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(
"account-not-found/index-optional.njk"
);
});

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(
"account-not-found/index-one-login.njk"
);
});
});

it("should render the account not found optional view when serviceType optional", () => {
req.session.client.serviceType = SERVICE_TYPE.OPTIONAL;
accountNotFoundGet(req, res);
describe("when strategicAppChannel is false", () => {
beforeEach(() => {
res.locals.strategicAppChannel = false;
});

expect(res.render).to.have.calledWith(
"account-not-found/index-optional.njk"
);
it("should render the account not found mandatory view when serviceType undefined", () => {
accountNotFoundGet(req, res);

expect(res.render).to.have.calledWith(
"account-not-found/index-mandatory.njk"
);
});

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(
"account-not-found/index-optional.njk"
);
});

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(
"account-not-found/index-one-login.njk"
);
});
});

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);
describe("when strategicAppChannel is true", () => {
beforeEach(() => {
res.locals.strategicAppChannel = true;
});

expect(res.render).to.have.calledWith(
"account-not-found/index-one-login.njk"
);
it("should render the account not found mandatory view when serviceType undefined", () => {
accountNotFoundGet(req, res);

expect(res.render).to.have.calledWith(
"account-not-found/index-mobile.njk"
);
});

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(
"account-not-found/index-mobile.njk"
);
});

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(
"account-not-found/index-mobile.njk"
);
});
});
});

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { expect } from "chai";
import { describe } from "mocha";
import { getAccountNotFoundTemplate } from "../get-account-not-found-template";
import { SERVICE_TYPE } from "../../../app.constants";

describe("getAccountNotFoundWebTemplate", () => {
describe("when isStrategicApp 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) => {
expect(getAccountNotFoundTemplate(true, i, false)).to.equal(
"account-not-found/index-one-login.njk"
);
});
});
});

describe("when isOneLoginService is false", () => {
it("should return 'account-not-found/index-optional.njk' when serviceType is equal to SERVICE_TYPE.OPTIONAL", () => {
expect(
getAccountNotFoundTemplate(false, SERVICE_TYPE.OPTIONAL, false)
).to.equal("account-not-found/index-optional.njk");
});

it("should return 'account-not-found/index-mandatory.njk' when serviceType is not equal to SERVICE_TYPE.OPTIONAL", () => {
[SERVICE_TYPE.MANDATORY, ""].forEach((i) => {
expect(getAccountNotFoundTemplate(false, i, false)).to.equal(
"account-not-found/index-mandatory.njk"
);
});
});
});
});

describe("when isStrategicApp 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) => {
expect(getAccountNotFoundTemplate(true, i, true)).to.equal(
"account-not-found/index-mobile.njk"
);
});
});
});

describe("when isOneLoginService is false", () => {
it("should return 'account-not-found/index-mobile.njk' when serviceType is equal to SERVICE_TYPE.OPTIONAL", () => {
expect(
getAccountNotFoundTemplate(false, SERVICE_TYPE.OPTIONAL, true)
).to.equal("account-not-found/index-mobile.njk");
});

it("should return 'account-not-found/index-mobile.njk' when serviceType is not equal to SERVICE_TYPE.OPTIONAL", () => {
[SERVICE_TYPE.MANDATORY, ""].forEach((i) => {
expect(getAccountNotFoundTemplate(false, i, true)).to.equal(
"account-not-found/index-mobile.njk"
);
});
});
});
});
});

This file was deleted.

0 comments on commit 84cfd24

Please sign in to comment.