Skip to content

Commit

Permalink
AUT-3779: Introduce mobile landing page
Browse files Browse the repository at this point in the history
Phase 2 of the strategic app introduces a mobile specific landing
pages. This commit introduces the page, making use of a new constant
that holds the mappings between web and mobile templates.
  • Loading branch information
gtvj committed Nov 4, 2024
1 parent ce03c80 commit e2dc593
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/app.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,3 +295,7 @@ const DYNATRACE_RUM_COOKIES = [
"rxvt",
];
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",
};
28 changes: 28 additions & 0 deletions src/components/sign-in-or-create/index-mobile.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{% extends "common/layout/base.njk" %}
{% from "govuk/components/button/macro.njk" import govukButton %}

{% set pageTitleName = 'mobileAppPages.signIn.title' | translate %}

{% block content %}

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

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

<form action="/sign-in-or-create" method="post" novalidate="novalidate">

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

{{ govukButton({
text: 'mobileAppPages.signIn.button' | translate,
classes: "govuk-button--primary",
attributes: {
"id": "sign-in-button"
}
}) }}

</form>

{{ga4OnPageLoad({ nonce: scriptNonce, statusCode: "200", englishPageTitle: pageTitleName, taxonomyLevel1: "authentication", taxonomyLevel2: "Home", contentId: "9cd55996-3f12-4e79-adf3-0ec3c4faf7ce", loggedInStatus: false, dynamic: true })}}
{% endblock %}
11 changes: 10 additions & 1 deletion src/components/sign-in-or-create/sign-in-or-create-controller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Request, Response } from "express";
import { getNextPathAndUpdateJourney } from "../common/constants";
import { USER_JOURNEY_EVENTS } from "../common/state-machine/state-machine";
import { getChannelSpecificTemplate } from "../../utils/get-channel-specific-template";
import { WEB_TO_MOBILE_TEMPLATE_MAPPINGS } from "../../app.constants";

export async function signInOrCreateGet(
req: Request,
Expand All @@ -12,7 +14,14 @@ export async function signInOrCreateGet(
if (req.query.redirectPost) {
return await signInOrCreatePost(req, res);
}
res.render("sign-in-or-create/index.njk", {

const template = getChannelSpecificTemplate(
"sign-in-or-create/index.njk",
res.locals.strategicAppChannel,
WEB_TO_MOBILE_TEMPLATE_MAPPINGS
);

res.render(template, {
serviceType: req.session.client.serviceType,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ describe("sign in or create controller", () => {

expect(res.render).to.have.calledWith("sign-in-or-create/index.njk");
});

describe("where the context is mobile", () => {
it("should render the mobile template", async () => {
res.locals.strategicAppChannel = true;

signInOrCreateGet(req as Request, res as Response);

expect(res.render).to.have.calledWith(
"sign-in-or-create/index-mobile.njk"
);
});
});
});
describe("signInOrCreatePost", () => {
it("should redirect to enter email new create account", async () => {
Expand Down

0 comments on commit e2dc593

Please sign in to comment.