From c326deb0c8e9ca4469c471a784e12f6eb0eaac51 Mon Sep 17 00:00:00 2001 From: Isabella Mitchell Date: Fri, 15 Nov 2024 10:52:51 +0000 Subject: [PATCH 1/4] WSTEAM1-1408: Adds lite as platform and appType for analytics --- src/app/contexts/RequestContext/index.test.tsx | 2 +- src/app/contexts/RequestContext/index.tsx | 2 ++ src/app/lib/analyticsUtils/index.js | 2 ++ src/app/lib/analyticsUtils/index.test.js | 5 +++++ src/app/models/types/global.ts | 2 +- 5 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/app/contexts/RequestContext/index.test.tsx b/src/app/contexts/RequestContext/index.test.tsx index ef56e343057..a64f7536509 100644 --- a/src/app/contexts/RequestContext/index.test.tsx +++ b/src/app/contexts/RequestContext/index.test.tsx @@ -204,7 +204,7 @@ describe('RequestContext', () => { isAmp: false, isApp: false, isLite: true, - platform: 'canonical', + platform: 'lite', }); }); diff --git a/src/app/contexts/RequestContext/index.tsx b/src/app/contexts/RequestContext/index.tsx index dcacc3205eb..f7f01b8c36f 100644 --- a/src/app/contexts/RequestContext/index.tsx +++ b/src/app/contexts/RequestContext/index.tsx @@ -100,6 +100,8 @@ export const RequestContextProvider = ({ return 'app'; case isAmp: return 'amp'; + case isLite: + return 'lite'; default: return 'canonical'; } diff --git a/src/app/lib/analyticsUtils/index.js b/src/app/lib/analyticsUtils/index.js index 72c5f15d48d..5e8928a5496 100644 --- a/src/app/lib/analyticsUtils/index.js +++ b/src/app/lib/analyticsUtils/index.js @@ -78,6 +78,8 @@ export const getAppType = platform => { return 'amp'; case 'app': return 'mobile-app'; + case 'lite': + return 'lite'; case 'canonical': return 'responsive'; default: diff --git a/src/app/lib/analyticsUtils/index.test.js b/src/app/lib/analyticsUtils/index.test.js index 9452955930c..1e2112788f7 100644 --- a/src/app/lib/analyticsUtils/index.test.js +++ b/src/app/lib/analyticsUtils/index.test.js @@ -129,6 +129,11 @@ describe('getAppType', () => { expected: 'mobile-app', summary: 'should return mobile-app for app', }, + { + platform: 'lite', + expected: 'lite', + summary: 'should return lite for lite', + }, { platform: 'canonical', expected: 'responsive', diff --git a/src/app/models/types/global.ts b/src/app/models/types/global.ts index b04ae5ec1a8..765ccf5c788 100644 --- a/src/app/models/types/global.ts +++ b/src/app/models/types/global.ts @@ -2,7 +2,7 @@ import * as PAGE_TYPES from '../../routes/utils/pageTypes'; export type Environments = 'local' | 'test' | 'live'; -export type Platforms = 'amp' | 'canonical' | 'app'; +export type Platforms = 'amp' | 'canonical' | 'app' | 'lite'; export type Direction = 'rtl' | 'ltr'; From 0ce37dc2d9f872570b3ace2608b34a590799769e Mon Sep 17 00:00:00 2001 From: Isabella Mitchell Date: Fri, 15 Nov 2024 10:53:26 +0000 Subject: [PATCH 2/4] WSTEAM1-1408: Refactor Integration platform check --- src/integration/integrationTestEnvironment.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/integration/integrationTestEnvironment.js b/src/integration/integrationTestEnvironment.js index 9cf33fa4cde..0c69b56c7a7 100644 --- a/src/integration/integrationTestEnvironment.js +++ b/src/integration/integrationTestEnvironment.js @@ -18,7 +18,21 @@ class IntegrationTestEnvironment extends JsdomEnvironment { } = context.docblockPragmas; const pageType = getPageTypeFromTestPath(context.testPath); - const platformForPath = platform === 'canonical' ? '' : `.${platform}`; + let platformForPath = ''; + + switch (platform) { + case 'canonical': + platformForPath = ''; + break; + case 'amp': + platformForPath = '.amp'; + break; + case 'lite': + platformForPath = '.lite'; + break; + default: + platformForPath = ''; + } this.pageType = camelCaseToText(pageType); this.service = service; From 3bcac44a17963f1bb17986ee7caf7fdb5825f1ca Mon Sep 17 00:00:00 2001 From: Isabella Mitchell <98817636+Isabella-Mitchell@users.noreply.github.com> Date: Fri, 15 Nov 2024 12:05:40 +0000 Subject: [PATCH 3/4] Update src/integration/integrationTestEnvironment.js Co-authored-by: Karina Thomas <58214768+karinathomasbbc@users.noreply.github.com> --- src/integration/integrationTestEnvironment.js | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/src/integration/integrationTestEnvironment.js b/src/integration/integrationTestEnvironment.js index 0c69b56c7a7..655aa92b839 100644 --- a/src/integration/integrationTestEnvironment.js +++ b/src/integration/integrationTestEnvironment.js @@ -18,21 +18,7 @@ class IntegrationTestEnvironment extends JsdomEnvironment { } = context.docblockPragmas; const pageType = getPageTypeFromTestPath(context.testPath); - let platformForPath = ''; - - switch (platform) { - case 'canonical': - platformForPath = ''; - break; - case 'amp': - platformForPath = '.amp'; - break; - case 'lite': - platformForPath = '.lite'; - break; - default: - platformForPath = ''; - } + const platformForPath = ['amp', 'lite'].includes(platform) ? `.${platform}` : ''; this.pageType = camelCaseToText(pageType); this.service = service; From 3f0524628a89292a26bd45c3768d5d2dcb33037b Mon Sep 17 00:00:00 2001 From: Isabella Mitchell Date: Fri, 15 Nov 2024 12:33:04 +0000 Subject: [PATCH 4/4] WSTEAM1-1408: Lint --- src/integration/integrationTestEnvironment.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/integration/integrationTestEnvironment.js b/src/integration/integrationTestEnvironment.js index 655aa92b839..8d7f8e7b6de 100644 --- a/src/integration/integrationTestEnvironment.js +++ b/src/integration/integrationTestEnvironment.js @@ -18,7 +18,9 @@ class IntegrationTestEnvironment extends JsdomEnvironment { } = context.docblockPragmas; const pageType = getPageTypeFromTestPath(context.testPath); - const platformForPath = ['amp', 'lite'].includes(platform) ? `.${platform}` : ''; + const platformForPath = ['amp', 'lite'].includes(platform) + ? `.${platform}` + : ''; this.pageType = camelCaseToText(pageType); this.service = service;