Skip to content

Commit dd3418e

Browse files
committed
AUT-4297: Add mobile channel
Accept 'mobile' as a valid channel on the FE and render the same mobile pages as the strategic app when res.locals.mobileChannel is true.
1 parent 533d60f commit dd3418e

10 files changed

Lines changed: 82 additions & 38 deletions

src/app.constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ export enum JOURNEY_TYPE {
244244
export enum CHANNEL {
245245
WEB = "web",
246246
STRATEGIC_APP = "strategic_app",
247+
MOBILE = "mobile",
247248
}
248249

249250
export const ENVIRONMENT_NAME = {

src/components/account-not-found/account-not-found-controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export function accountNotFoundGet(req: Request, res: Response): void {
1717
const template: string = getAccountNotFoundTemplate(
1818
clientIsOneLogin(req),
1919
req.session.client.serviceType,
20-
res.locals.strategicAppChannel
20+
res.locals.strategicAppChannel || res.locals.mobileChannel
2121
);
2222

2323
res.render(template, {

src/components/account-not-found/get-account-not-found-template.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { getChannelSpecificTemplate } from "../../utils/get-channel-specific-tem
66
export function getAccountNotFoundTemplate(
77
isOneLoginService: boolean,
88
serviceType: string,
9-
isStrategicAppChannel: boolean
9+
isMobileOrStrategicAppChannel: boolean
1010
): string {
1111
let webTemplate;
1212

@@ -20,7 +20,7 @@ export function getAccountNotFoundTemplate(
2020

2121
return getChannelSpecificTemplate(
2222
webTemplate,
23-
isStrategicAppChannel,
23+
isMobileOrStrategicAppChannel,
2424
WEB_TO_MOBILE_TEMPLATE_MAPPINGS
2525
);
2626
}

src/components/account-not-found/tests/account-not-found-controller.test.ts

Lines changed: 38 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe("account not found controller", () => {
2525
});
2626

2727
describe("accountNotFoundGet", () => {
28-
describe("when strategicAppChannel is not defined", () => {
28+
describe("when strategicAppChannel or mobileChannel is not defined", () => {
2929
it("should render the account not found mandatory view when serviceType undefined", () => {
3030
accountNotFoundGet(req, res);
3131

@@ -53,9 +53,10 @@ describe("account not found controller", () => {
5353
});
5454
});
5555

56-
describe("when strategicAppChannel is false", () => {
56+
describe("when strategicAppChannel and mobileChannel are false", () => {
5757
beforeEach(() => {
5858
res.locals.strategicAppChannel = false;
59+
res.locals.mobileChannel = false;
5960
});
6061

6162
it("should render the account not found mandatory view when serviceType undefined", () => {
@@ -85,35 +86,47 @@ describe("account not found controller", () => {
8586
});
8687
});
8788

88-
describe("when strategicAppChannel is true", () => {
89-
beforeEach(() => {
90-
res.locals.strategicAppChannel = true;
91-
});
89+
describe("when strategicAppChannel or mobileChannel are true", () => {
90+
const testCases = [
91+
{ strategicAppChannel: true, mobileChannel: false },
92+
{ strategicAppChannel: false, mobileChannel: true },
93+
];
9294

93-
it("should render the account not found mandatory view when serviceType undefined", () => {
94-
accountNotFoundGet(req, res);
95+
testCases.forEach((testCase) => {
96+
it("should render the account not found mandatory view when serviceType undefined", () => {
97+
res.locals.strategicAppChannel = testCase.strategicAppChannel;
98+
res.locals.mobileChannel = testCase.mobileChannel;
9599

96-
expect(res.render).to.have.calledWith(
97-
"account-not-found/index-mobile.njk"
98-
);
99-
});
100+
accountNotFoundGet(req, res);
100101

101-
it("should render the account not found optional view when serviceType optional", () => {
102-
req.session.client.serviceType = SERVICE_TYPE.OPTIONAL;
103-
accountNotFoundGet(req, res);
102+
expect(res.render).to.have.calledWith(
103+
"account-not-found/index-mobile.njk"
104+
);
105+
});
104106

105-
expect(res.render).to.have.calledWith(
106-
"account-not-found/index-mobile.njk"
107-
);
108-
});
107+
it("should render the account not found optional view when serviceType optional", () => {
108+
req.session.client.serviceType = SERVICE_TYPE.OPTIONAL;
109+
res.locals.strategicAppChannel = testCase.strategicAppChannel;
110+
res.locals.mobileChannel = testCase.mobileChannel;
109111

110-
it("should render the account not found optional view when the service is part of One Login", () => {
111-
req.session.client.isOneLoginService = true;
112-
accountNotFoundGet(req, res);
112+
accountNotFoundGet(req, res);
113113

114-
expect(res.render).to.have.calledWith(
115-
"account-not-found/index-mobile.njk"
116-
);
114+
expect(res.render).to.have.calledWith(
115+
"account-not-found/index-mobile.njk"
116+
);
117+
});
118+
119+
it("should render the account not found optional view when the service is part of One Login", () => {
120+
req.session.client.isOneLoginService = true;
121+
res.locals.strategicAppChannel = testCase.strategicAppChannel;
122+
res.locals.mobileChannel = testCase.mobileChannel;
123+
124+
accountNotFoundGet(req, res);
125+
126+
expect(res.render).to.have.calledWith(
127+
"account-not-found/index-mobile.njk"
128+
);
129+
});
117130
});
118131
});
119132
});

src/components/sign-in-or-create/sign-in-or-create-controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export async function signInOrCreateGet(
1616

1717
const template = getChannelSpecificTemplate(
1818
"sign-in-or-create/index.njk",
19-
res.locals.strategicAppChannel,
19+
res.locals.strategicAppChannel || res.locals.mobileChannel,
2020
WEB_TO_MOBILE_TEMPLATE_MAPPINGS
2121
);
2222

src/components/sign-in-or-create/tests/sign-in-or-create-controller.test.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,26 @@ describe("sign in or create controller", () => {
3333
});
3434

3535
describe("where the context is mobile", () => {
36-
it("should render the mobile template", async () => {
37-
res.locals.strategicAppChannel = true;
36+
const testCases = [
37+
{ strategicAppChannel: true, mobileChannel: false },
38+
{ strategicAppChannel: false, mobileChannel: true },
39+
];
3840

39-
signInOrCreateGet(req as Request, res as Response);
41+
testCases.forEach((testCase) => {
42+
it("should render the mobile template", async () => {
43+
res.locals.strategicAppChannel = testCase.strategicAppChannel;
44+
res.locals.mobileChannel = testCase.mobileChannel;
4045

41-
expect(res.render).to.have.calledWith(
42-
"sign-in-or-create/index-mobile.njk"
43-
);
46+
signInOrCreateGet(req as Request, res as Response);
47+
48+
expect(res.render).to.have.calledWith(
49+
"sign-in-or-create/index-mobile.njk"
50+
);
51+
});
4452
});
4553
});
4654
});
55+
4756
describe("signInOrCreatePost", () => {
4857
it("should redirect to enter email new create account", async () => {
4958
req.body.optionSelected = "create";

src/config.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,11 @@ export function supportHttpKeepAlive(): boolean {
176176
}
177177

178178
export function isValidChannel(channel: string): boolean {
179-
return channel === CHANNEL.WEB || channel === CHANNEL.STRATEGIC_APP;
179+
return (
180+
channel === CHANNEL.WEB ||
181+
channel === CHANNEL.STRATEGIC_APP ||
182+
channel === CHANNEL.MOBILE
183+
);
180184
}
181185

182186
export function showTestBanner(): boolean {

src/middleware/channel-middleware.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ export function channelMiddleware(
1919
function setChannelFlags(res: Response, channel?: string): void {
2020
res.locals.strategicAppChannel = channel === CHANNEL.STRATEGIC_APP;
2121
res.locals.webChannel = channel === CHANNEL.WEB;
22+
res.locals.mobileChannel = channel === CHANNEL.MOBILE;
2223
}

src/middleware/tests/channel-middleware.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ describe("session-middleware", () => {
2626

2727
expect(res.locals.strategicAppChannel).to.equal(true);
2828
expect(res.locals.webChannel).to.equal(false);
29+
expect(res.locals.mobileChannel).to.equal(false);
2930
expect(next).to.be.calledOnce;
3031
});
3132

@@ -37,6 +38,19 @@ describe("session-middleware", () => {
3738

3839
expect(res.locals.strategicAppChannel).to.equal(false);
3940
expect(res.locals.webChannel).to.equal(true);
41+
expect(res.locals.mobileChannel).to.equal(false);
42+
expect(next).to.be.calledOnce;
43+
});
44+
45+
it("should set mobile to true for mobile clients", () => {
46+
const req = mockRequest({
47+
session: { client: {}, user: { channel: "mobile" } },
48+
});
49+
channelMiddleware(req as Request, res as Response, next);
50+
51+
expect(res.locals.strategicAppChannel).to.equal(false);
52+
expect(res.locals.webChannel).to.equal(false);
53+
expect(res.locals.mobileChannel).to.equal(true);
4054
expect(next).to.be.calledOnce;
4155
});
4256

@@ -65,6 +79,7 @@ describe("session-middleware", () => {
6579

6680
expect(res.locals.strategicAppChannel).to.equal(true);
6781
expect(res.locals.webChannel).to.equal(false);
82+
expect(res.locals.mobileChannel).to.equal(false);
6883
expect(next).to.be.calledOnce;
6984
});
7085

@@ -75,6 +90,7 @@ describe("session-middleware", () => {
7590

7691
expect(res.locals.strategicAppChannel).to.equal(false);
7792
expect(res.locals.webChannel).to.equal(true);
93+
expect(res.locals.mobileChannel).to.equal(false);
7894
expect(next).to.be.calledOnce;
7995
});
8096
});

src/utils/get-channel-specific-template.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { logger } from "./logger.js";
22
export function getChannelSpecificTemplate(
33
webTemplateAndPath: string,
4-
isStrategicAppChannel: boolean,
4+
isMobileOrStrategicAppChannel: boolean,
55
templateMappings: Record<string, string>
66
): string {
7-
if (!isStrategicAppChannel) {
7+
if (!isMobileOrStrategicAppChannel) {
88
return webTemplateAndPath;
99
}
1010

0 commit comments

Comments
 (0)