From bd0e3ec622105f4b13c65bb825234c3ce33e6258 Mon Sep 17 00:00:00 2001 From: Nabeel Khan Date: Fri, 24 Jan 2025 13:11:00 +0000 Subject: [PATCH 1/7] added support for routes to have variants at the end --- src/app/routes/topic/index.js | 4 +- .../utils/constructPageFetchUrl/index.test.ts | 1 + src/app/routes/utils/regex/index.js | 3 + src/app/routes/utils/regex/index.test.js | 48 +++++++++ src/app/routes/utils/regex/utils/index.js | 5 + src/server/index.test.jsx | 97 +++++++++++++++++++ 6 files changed, 156 insertions(+), 2 deletions(-) diff --git a/src/app/routes/topic/index.js b/src/app/routes/topic/index.js index 5bf1cae9687..02a03b8009e 100644 --- a/src/app/routes/topic/index.js +++ b/src/app/routes/topic/index.js @@ -1,10 +1,10 @@ import { TopicPage } from '#pages'; -import { topicPath } from '#app/routes/utils/regex'; +import { topicPath, variantTopicPath } from '#app/routes/utils/regex'; import { TOPIC_PAGE } from '#app/routes/utils/pageTypes'; import getInitialData from './getInitialData'; export default { - path: [topicPath, '/persian/afghanistan'], + path: [topicPath, variantTopicPath, '/persian/afghanistan'], exact: true, component: TopicPage, getInitialData, diff --git a/src/app/routes/utils/constructPageFetchUrl/index.test.ts b/src/app/routes/utils/constructPageFetchUrl/index.test.ts index 3e9f5dbf045..d523b2a5953 100644 --- a/src/app/routes/utils/constructPageFetchUrl/index.test.ts +++ b/src/app/routes/utils/constructPageFetchUrl/index.test.ts @@ -122,6 +122,7 @@ describe('constructPageFetchUrl', () => { ${TOPIC_PAGE} | ${'persian'} | ${null} | ${'local'} | ${'/persian/topics/c00000000000t'} | ${'http://localhost/persian/topics/c00000000000t'} ${TOPIC_PAGE} | ${'persian'} | ${null} | ${'test'} | ${'/persian/topics/c00000000000t'} | ${'https://mock-bff-path/?id=c00000000000t&service=persian&pageType=topic&serviceEnv=test'} ${TOPIC_PAGE} | ${'persian'} | ${null} | ${'live'} | ${'/persian/topics/c00000000000t'} | ${'https://mock-bff-path/?id=c00000000000t&service=persian&pageType=topic&serviceEnv=live'} + ${TOPIC_PAGE} | ${'zhongwen'} | ${'trad'} | ${'live'} | ${'/cpydz21p02et'} | ${'https://mock-bff-path/?id=cpydz21p02et&service=zhongwen&pageType=topic&variant=trad&serviceEnv=live'} ${UGC_PAGE} | ${'mundo'} | ${null} | ${'local'} | ${'/u50853489'} | ${'http://localhost/api/local/mundo/send/u50853489'} ${TV_PAGE} | ${'hausa'} | ${null} | ${'local'} | ${'/hausa/bbc_hausa_tv/tv/w172yjj7rfhxp1p'} | ${'http://localhost/hausa/bbc_hausa_tv/tv/w172yjj7rfhxp1p'} ${TV_PAGE} | ${'hindi'} | ${null} | ${'local'} | ${'/hindi/bbc_hindi_tv/tv_programmes/w13xttlw'} | ${'http://localhost/hindi/bbc_hindi_tv/tv_programmes/w13xttlw'} diff --git a/src/app/routes/utils/regex/index.js b/src/app/routes/utils/regex/index.js index 18f9232ad09..13fb34f706d 100644 --- a/src/app/routes/utils/regex/index.js +++ b/src/app/routes/utils/regex/index.js @@ -15,6 +15,7 @@ import { getOnDemandRadioRegex, getOnDemandTvRegex, getTopicPageRegex, + getVariantTopicPageRegex, getErrorPageRegex, getLegacyAssetRegex, getMostReadPageRegex, @@ -65,6 +66,8 @@ export const onDemandTvDataPath = `${onDemandTvPath}.json`; export const topicPath = getTopicPageRegex(allServices); export const topicDataPath = `${topicPath}.json`; +export const variantTopicPath = getVariantTopicPageRegex(allServices); + export const errorPagePath = getErrorPageRegex(allServices); export const legacyAssetPagePath = getLegacyAssetRegex(allServices); diff --git a/src/app/routes/utils/regex/index.test.js b/src/app/routes/utils/regex/index.test.js index 0ea351f17b5..1689fcbcde1 100644 --- a/src/app/routes/utils/regex/index.test.js +++ b/src/app/routes/utils/regex/index.test.js @@ -22,6 +22,8 @@ import { secondaryColumnDataRegexPath, tipoHomeDataPath, tipoHomePath, + topicPath, + variantTopicPath, } from './index'; import serviceConfig from '../../../lib/config/services/loadableConfig'; @@ -603,3 +605,49 @@ describe('frontPage -> homePage migration', () => { shouldNotMatchInvalidRoutes(liveFrontPageRoutes, homePageRegex); }); }); + +describe('topicPath', () => { + const validRoutes = [ + '/zhongwen/trad/topics/cd6qem06z92t', + '/zhongwen/trad/topics/c1ez1k4emn0t', + '/serbian/lat/topics/cr50vdy9q6wt', + '/serbian/lat/topics/c2lej05e1eqt', + '/pidgin/topics/c2dwqd1zr92t' + ]; + shouldMatchValidRoutes(validRoutes, topicPath); + + const invalidRoutes = [ + '/serbian/topics/c2lej05e1eqt/lat', + '/serbian/topics/c2lej05qwesae1eqt/lat', + '/zhongwen/c1ez1k4emn0t', + '/zhongwen/trad/topics', + '/hindi/topic/c5jje4ejkqv', + '/mundo/topic/', + '/serbian/topic/c5jje4ejkqvo/foobar', + '/urdu/topic/c5jje4ejkqvo/.amp', + ]; + shouldNotMatchInvalidRoutes(invalidRoutes, topicPath); +}); + +describe('topicVariantPath', () => { + const validRoutes = [ + '/zhongwen/topics/cd6qem06z92t/trad', + '/zhongwen/topics/c1ez1k4emn0t/trad', + '/serbian/topics/cr50vdy9q6wt/lat', + '/serbian/topics/c2lej05e1eqt/lat', + '/pidgin/topics/c2dwqd1zr92t' + ]; + shouldMatchValidRoutes(validRoutes, variantTopicPath); + + const invalidRoutes = [ + '/serbian/lat/topics/c2lej05e1eqt', + '/serbian/lat/topics/c2lej05qwesae1eqt', + '/zhongwen/c1ez1k4emn0t', + '/zhongwen/trad/topics', + '/hindi/topic/c5jje4ejkqv', + '/mundo/topic/', + '/serbian/topic/c5jje4ejkqvo/foobar', + '/urdu/topic/c5jje4ejkqvo/.amp', + ]; + shouldNotMatchInvalidRoutes(invalidRoutes, variantTopicPath); +}); diff --git a/src/app/routes/utils/regex/utils/index.js b/src/app/routes/utils/regex/utils/index.js index e4bb1d49a7a..3bce6439f35 100644 --- a/src/app/routes/utils/regex/utils/index.js +++ b/src/app/routes/utils/regex/utils/index.js @@ -154,6 +154,11 @@ export const getTopicPageRegex = services => { return `/:service(${serviceRegex}):variant(${variantRegex})?/topics/:id(${topicIdRegex})?:lite(${liteRegex})?`; }; +export const getVariantTopicPageRegex = services => { + const serviceRegex = getServiceRegex(services); + return `/:service(${serviceRegex})/topics/:id(${topicIdRegex})?:variant(${variantRegex})?:lite(${liteRegex})?`; +}; + export const getErrorPageRegex = services => { const serviceRegex = getServiceRegex(services); return `/:service(${serviceRegex})/:errorCode(${errorCodeRegex}):variant(${variantRegex})?:lite(${liteRegex})?`; diff --git a/src/server/index.test.jsx b/src/server/index.test.jsx index 0fad3bf6760..1ae165d2dff 100644 --- a/src/server/index.test.jsx +++ b/src/server/index.test.jsx @@ -396,6 +396,100 @@ const testArticles = ({ platform, service, variant, queryString = '' }) => { }); }; +const testTopics = ({ service, variant, queryString = '' }) => { + describe(`Tipo Topic: /${service}/topics/tipoId/${variant}${queryString}`, () => { + const successDataResponse = { + data: { some: 'data' }, + service: 'someService', + status: 200, + }; + + const notFoundDataResponse = { + data: { some: 'data' }, + service: 'someService', + status: 404, + }; + + const id = `c0000000001o`; + const topicURL = `/${service}/topics/${id}/${variant}${queryString}`; + + describe('Successful render', () => { + describe('200 status code', () => { + beforeEach(() => { + mockRouteProps({ + id, + service, + dataResponse: successDataResponse, + variant, + }); + }); + + const configs = { + url: topicURL, + service, + successDataResponse, + variant, + }; + + it('should respond with rendered data', testRenderedData(configs)); + }); + + describe('404 status code', () => { + const pageType = 'topic'; + + beforeEach(() => { + mockRouteProps({ + id, + service, + dataResponse: notFoundDataResponse, + variant, + pageType, + }); + }); + + it('should respond with a rendered 404', async () => { + const { status, text } = await makeRequest(topicURL); + expect(status).toBe(404); + expect(text).toEqual( + '

Mock app

', + ); + }); + + assertNon200ResponseCustomMetrics({ + requestUrl: topicURL, + pageType, + statusCode: 404, + }); + }); + }); + + describe('Unknown error within the data fetch, react router or its dependencies', () => { + const pageType = 'topic'; + beforeEach(() => { + mockRouteProps({ + id, + service, + dataResponse: Error('Error!'), + responseType: 'reject', + variant, + pageType, + }); + }); + + it('should respond with a 500', async () => { + const { status, text } = await makeRequest(topicURL); + expect(status).toEqual(500); + expect(text).toEqual('Internal server error'); + }); + + assertNon200ResponseCustomMetrics({ + requestUrl: topicURL, + pageType, + }); + }); + }); +} + const testAssetPages = ({ platform, service, @@ -1201,6 +1295,9 @@ describe('Server', () => { queryString: QUERY_STRING, }); + testTopics({ service: 'zhongwen', variant: 'simp' }); + + testMediaPages({ platform: 'amp', service: 'korean', From a74e4cc47d32b987856567d8fca2bd2f36511275 Mon Sep 17 00:00:00 2001 From: louisearchibald Date: Fri, 24 Jan 2025 14:25:30 +0000 Subject: [PATCH 2/7] linting --- src/app/routes/utils/regex/index.test.js | 4 ++-- src/server/index.test.jsx | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/app/routes/utils/regex/index.test.js b/src/app/routes/utils/regex/index.test.js index 1689fcbcde1..ea554feba67 100644 --- a/src/app/routes/utils/regex/index.test.js +++ b/src/app/routes/utils/regex/index.test.js @@ -612,7 +612,7 @@ describe('topicPath', () => { '/zhongwen/trad/topics/c1ez1k4emn0t', '/serbian/lat/topics/cr50vdy9q6wt', '/serbian/lat/topics/c2lej05e1eqt', - '/pidgin/topics/c2dwqd1zr92t' + '/pidgin/topics/c2dwqd1zr92t', ]; shouldMatchValidRoutes(validRoutes, topicPath); @@ -635,7 +635,7 @@ describe('topicVariantPath', () => { '/zhongwen/topics/c1ez1k4emn0t/trad', '/serbian/topics/cr50vdy9q6wt/lat', '/serbian/topics/c2lej05e1eqt/lat', - '/pidgin/topics/c2dwqd1zr92t' + '/pidgin/topics/c2dwqd1zr92t', ]; shouldMatchValidRoutes(validRoutes, variantTopicPath); diff --git a/src/server/index.test.jsx b/src/server/index.test.jsx index 1ae165d2dff..4c226005783 100644 --- a/src/server/index.test.jsx +++ b/src/server/index.test.jsx @@ -396,7 +396,7 @@ const testArticles = ({ platform, service, variant, queryString = '' }) => { }); }; -const testTopics = ({ service, variant, queryString = '' }) => { +const testTopics = ({ service, variant, queryString = '' }) => { describe(`Tipo Topic: /${service}/topics/tipoId/${variant}${queryString}`, () => { const successDataResponse = { data: { some: 'data' }, @@ -488,7 +488,7 @@ const testTopics = ({ service, variant, queryString = '' }) => { }); }); }); -} +}; const testAssetPages = ({ platform, @@ -1297,7 +1297,6 @@ describe('Server', () => { testTopics({ service: 'zhongwen', variant: 'simp' }); - testMediaPages({ platform: 'amp', service: 'korean', From 4c46a57f545e76be65e4c7624fb5ab6a00a30dc6 Mon Sep 17 00:00:00 2001 From: louisearchibald Date: Fri, 24 Jan 2025 14:55:25 +0000 Subject: [PATCH 3/7] adds server tests for current topic pattern --- src/server/index.test.jsx | 98 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 97 insertions(+), 1 deletion(-) diff --git a/src/server/index.test.jsx b/src/server/index.test.jsx index 4c226005783..964cd4547c3 100644 --- a/src/server/index.test.jsx +++ b/src/server/index.test.jsx @@ -397,6 +397,100 @@ const testArticles = ({ platform, service, variant, queryString = '' }) => { }; const testTopics = ({ service, variant, queryString = '' }) => { + describe(`Tipo Topic: /${service}/${variant}/topics/tipoId${queryString}`, () => { + const successDataResponse = { + data: { some: 'data' }, + service: 'someService', + status: 200, + }; + + const notFoundDataResponse = { + data: { some: 'data' }, + service: 'someService', + status: 404, + }; + + const id = `c0000000001o`; + const topicURL = `/${service}/${variant}/topics/${id}${queryString}`; + + describe('Successful render', () => { + describe('200 status code', () => { + beforeEach(() => { + mockRouteProps({ + id, + service, + dataResponse: successDataResponse, + variant, + }); + }); + + const configs = { + url: topicURL, + service, + successDataResponse, + variant, + }; + + it('should respond with rendered data', testRenderedData(configs)); + }); + + describe('404 status code', () => { + const pageType = 'topic'; + + beforeEach(() => { + mockRouteProps({ + id, + service, + dataResponse: notFoundDataResponse, + variant, + pageType, + }); + }); + + it('should respond with a rendered 404', async () => { + const { status, text } = await makeRequest(topicURL); + expect(status).toBe(404); + expect(text).toEqual( + '

Mock app

', + ); + }); + + assertNon200ResponseCustomMetrics({ + requestUrl: topicURL, + pageType, + statusCode: 404, + }); + }); + }); + + describe('Unknown error within the data fetch, react router or its dependencies', () => { + const pageType = 'topic'; + beforeEach(() => { + mockRouteProps({ + id, + service, + dataResponse: Error('Error!'), + responseType: 'reject', + variant, + pageType, + }); + }); + + it('should respond with a 500', async () => { + const { status, text } = await makeRequest(topicURL); + expect(status).toEqual(500); + expect(text).toEqual('Internal server error'); + }); + + assertNon200ResponseCustomMetrics({ + requestUrl: topicURL, + pageType, + }); + }); + }); +}; + +const testVariantTopics = ({ service, variant, queryString = '' }) => { describe(`Tipo Topic: /${service}/topics/tipoId/${variant}${queryString}`, () => { const successDataResponse = { data: { some: 'data' }, @@ -1295,7 +1389,9 @@ describe('Server', () => { queryString: QUERY_STRING, }); - testTopics({ service: 'zhongwen', variant: 'simp' }); + testTopics({ service: 'pidgin' }); + + testVariantTopics({ service: 'zhongwen', variant: 'simp' }); testMediaPages({ platform: 'amp', From 6093c43a8c14fb56547b73a32ff51b536061cd9a Mon Sep 17 00:00:00 2001 From: Nabeel Khan Date: Fri, 24 Jan 2025 15:16:37 +0000 Subject: [PATCH 4/7] updated snapshots --- .../routes/utils/regex/utils/__snapshots__/index.test.js.snap | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/app/routes/utils/regex/utils/__snapshots__/index.test.js.snap b/src/app/routes/utils/regex/utils/__snapshots__/index.test.js.snap index 429d6a2fc63..95e9a443cc0 100644 --- a/src/app/routes/utils/regex/utils/__snapshots__/index.test.js.snap +++ b/src/app/routes/utils/regex/utils/__snapshots__/index.test.js.snap @@ -87,3 +87,7 @@ exports[`regex utils snapshots should create expected regex from getTipoHomeRege exports[`regex utils snapshots should create expected regex from getTopicPageRegex when isLive = false 1`] = `"/:service(afaanoromoo|afrique|amharic|arabic|archive|azeri|bengali|burmese|cymrufyw|gahuza|gujarati|hausa|hindi|igbo|indonesia|japanese|korean|kyrgyz|marathi|mundo|naidheachdan|nepali|news|newsround|pashto|persian|pidgin|portuguese|punjabi|russian|scotland|serbian|sinhala|somali|sport|swahili|tamil|telugu|thai|tigrinya|turkce|ukchina|ukrainian|urdu|uzbek|vietnamese|ws|yoruba|zhongwen):variant(/simp|/trad|/cyr|/lat)?/topics/:id([a-z0-9]+)?:lite(.lite)?"`; exports[`regex utils snapshots should create expected regex from getTopicPageRegex when isLive = true 1`] = `"/:service(afaanoromoo|afrique|amharic|arabic|archive|azeri|bengali|burmese|cymrufyw|gahuza|gujarati|hausa|hindi|igbo|indonesia|japanese|korean|kyrgyz|marathi|mundo|naidheachdan|nepali|news|newsround|pashto|persian|pidgin|portuguese|punjabi|russian|scotland|serbian|sinhala|somali|sport|swahili|tamil|telugu|thai|tigrinya|turkce|ukchina|ukrainian|urdu|uzbek|vietnamese|ws|yoruba|zhongwen):variant(/simp|/trad|/cyr|/lat)?/topics/:id([a-z0-9]+)?:lite(.lite)?"`; + +exports[`regex utils snapshots should create expected regex from getVariantTopicPageRegex when isLive = false 1`] = `"/:service(afaanoromoo|afrique|amharic|arabic|archive|azeri|bengali|burmese|cymrufyw|gahuza|gujarati|hausa|hindi|igbo|indonesia|japanese|korean|kyrgyz|marathi|mundo|naidheachdan|nepali|news|newsround|pashto|persian|pidgin|portuguese|punjabi|russian|scotland|serbian|sinhala|somali|sport|swahili|tamil|telugu|thai|tigrinya|turkce|ukchina|ukrainian|urdu|uzbek|vietnamese|ws|yoruba|zhongwen)/topics/:id([a-z0-9]+)?:variant(/simp|/trad|/cyr|/lat)?:lite(.lite)?"`; + +exports[`regex utils snapshots should create expected regex from getVariantTopicPageRegex when isLive = true 1`] = `"/:service(afaanoromoo|afrique|amharic|arabic|archive|azeri|bengali|burmese|cymrufyw|gahuza|gujarati|hausa|hindi|igbo|indonesia|japanese|korean|kyrgyz|marathi|mundo|naidheachdan|nepali|news|newsround|pashto|persian|pidgin|portuguese|punjabi|russian|scotland|serbian|sinhala|somali|sport|swahili|tamil|telugu|thai|tigrinya|turkce|ukchina|ukrainian|urdu|uzbek|vietnamese|ws|yoruba|zhongwen)/topics/:id([a-z0-9]+)?:variant(/simp|/trad|/cyr|/lat)?:lite(.lite)?"`; From a6cbd9ec92083430bd6b71973391d134822ac135 Mon Sep 17 00:00:00 2001 From: Nabeel Khan Date: Fri, 24 Jan 2025 16:13:54 +0000 Subject: [PATCH 5/7] added zhongwen simp variant for unit testing --- src/app/routes/utils/constructPageFetchUrl/index.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/routes/utils/constructPageFetchUrl/index.test.ts b/src/app/routes/utils/constructPageFetchUrl/index.test.ts index d523b2a5953..5319c0f0208 100644 --- a/src/app/routes/utils/constructPageFetchUrl/index.test.ts +++ b/src/app/routes/utils/constructPageFetchUrl/index.test.ts @@ -122,7 +122,8 @@ describe('constructPageFetchUrl', () => { ${TOPIC_PAGE} | ${'persian'} | ${null} | ${'local'} | ${'/persian/topics/c00000000000t'} | ${'http://localhost/persian/topics/c00000000000t'} ${TOPIC_PAGE} | ${'persian'} | ${null} | ${'test'} | ${'/persian/topics/c00000000000t'} | ${'https://mock-bff-path/?id=c00000000000t&service=persian&pageType=topic&serviceEnv=test'} ${TOPIC_PAGE} | ${'persian'} | ${null} | ${'live'} | ${'/persian/topics/c00000000000t'} | ${'https://mock-bff-path/?id=c00000000000t&service=persian&pageType=topic&serviceEnv=live'} - ${TOPIC_PAGE} | ${'zhongwen'} | ${'trad'} | ${'live'} | ${'/cpydz21p02et'} | ${'https://mock-bff-path/?id=cpydz21p02et&service=zhongwen&pageType=topic&variant=trad&serviceEnv=live'} + ${TOPIC_PAGE} | ${'zhongwen'} | ${'trad'} | ${'live'} | ${'/zhongwen/topics/cpydz21p02et/trad'} | ${'https://mock-bff-path/?id=cpydz21p02et&service=zhongwen&pageType=topic&variant=trad&serviceEnv=live'} + ${TOPIC_PAGE} | ${'zhongwen'} | ${'simp'} | ${'live'} | ${'/zhongwen/topics/c4vmr03pyn6t/simp'} | ${'https://mock-bff-path/?id=c4vmr03pyn6t&service=zhongwen&pageType=topic&variant=simp&serviceEnv=live'} ${UGC_PAGE} | ${'mundo'} | ${null} | ${'local'} | ${'/u50853489'} | ${'http://localhost/api/local/mundo/send/u50853489'} ${TV_PAGE} | ${'hausa'} | ${null} | ${'local'} | ${'/hausa/bbc_hausa_tv/tv/w172yjj7rfhxp1p'} | ${'http://localhost/hausa/bbc_hausa_tv/tv/w172yjj7rfhxp1p'} ${TV_PAGE} | ${'hindi'} | ${null} | ${'local'} | ${'/hindi/bbc_hindi_tv/tv_programmes/w13xttlw'} | ${'http://localhost/hindi/bbc_hindi_tv/tv_programmes/w13xttlw'} From 0a81f98d0e80e20f7c7ca484165d1c568ed98e22 Mon Sep 17 00:00:00 2001 From: Nabeel Khan Date: Mon, 27 Jan 2025 11:14:26 +0000 Subject: [PATCH 6/7] added mock paths for local and test environments --- src/app/routes/utils/constructPageFetchUrl/index.test.ts | 6 +++++- src/app/routes/utils/constructPageFetchUrl/index.ts | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/app/routes/utils/constructPageFetchUrl/index.test.ts b/src/app/routes/utils/constructPageFetchUrl/index.test.ts index 5319c0f0208..4a84eecfa90 100644 --- a/src/app/routes/utils/constructPageFetchUrl/index.test.ts +++ b/src/app/routes/utils/constructPageFetchUrl/index.test.ts @@ -110,7 +110,7 @@ describe('constructPageFetchUrl', () => { ${TOPIC_PAGE} | ${null} | ${null} | ${'local'} | ${'/ukrainian/topics/c0000000000t'} | ${'http://localhost/ukrainian/topics/c0000000000t'} ${TOPIC_PAGE} | ${null} | ${null} | ${'test'} | ${'/ukrainian/topics/c0000000000t'} | ${'https://mock-bff-path/?id=c0000000000t&service=ukrainian&pageType=topic&serviceEnv=test'} ${TOPIC_PAGE} | ${null} | ${null} | ${'live'} | ${'/ukrainian/topics/c0000000000t'} | ${'https://mock-bff-path/?id=c0000000000t&service=ukrainian&pageType=topic&serviceEnv=live'} - ${TOPIC_PAGE} | ${null} | ${'ru-UA'} | ${'local'} | ${'/ukrainian/topics/c0000000000t'} | ${'http://localhost/ukrainian/ru-UA/topics/c0000000000t'} + ${TOPIC_PAGE} | ${null} | ${'ru-UA'} | ${'local'} | ${'/ukrainian/topics/c0000000000t'} | ${'http://localhost/ukrainian/topics/c0000000000t/ru-UA'} ${TOPIC_PAGE} | ${null} | ${'ru-UA'} | ${'test'} | ${'/ukrainian/topics/c0000000000t'} | ${'https://mock-bff-path/?id=c0000000000t&service=ukrainian&pageType=topic&variant=ru-UA&serviceEnv=test'} ${TOPIC_PAGE} | ${null} | ${'ru-UA'} | ${'live'} | ${'/ukrainian/topics/c0000000000t'} | ${'https://mock-bff-path/?id=c0000000000t&service=ukrainian&pageType=topic&variant=ru-UA&serviceEnv=live'} ${TOPIC_PAGE} | ${'persian'} | ${null} | ${'local'} | ${'/persian/afghanistan'} | ${'http://localhost/persian/topics/crezq2dg9zwt'} @@ -124,6 +124,10 @@ describe('constructPageFetchUrl', () => { ${TOPIC_PAGE} | ${'persian'} | ${null} | ${'live'} | ${'/persian/topics/c00000000000t'} | ${'https://mock-bff-path/?id=c00000000000t&service=persian&pageType=topic&serviceEnv=live'} ${TOPIC_PAGE} | ${'zhongwen'} | ${'trad'} | ${'live'} | ${'/zhongwen/topics/cpydz21p02et/trad'} | ${'https://mock-bff-path/?id=cpydz21p02et&service=zhongwen&pageType=topic&variant=trad&serviceEnv=live'} ${TOPIC_PAGE} | ${'zhongwen'} | ${'simp'} | ${'live'} | ${'/zhongwen/topics/c4vmr03pyn6t/simp'} | ${'https://mock-bff-path/?id=c4vmr03pyn6t&service=zhongwen&pageType=topic&variant=simp&serviceEnv=live'} + ${TOPIC_PAGE} | ${'zhongwen'} | ${'trad'} | ${'local'} | ${'/zhongwen/topics/cpydz21p02et/trad'} | ${'http://localhost/zhongwen/topics/cpydz21p02et/trad'} + ${TOPIC_PAGE} | ${'zhongwen'} | ${'simp'} | ${'local'} | ${'/zhongwen/topics/c4vmr03pyn6t/simp'} | ${'http://localhost/zhongwen/topics/c4vmr03pyn6t/simp'} + ${TOPIC_PAGE} | ${'zhongwen'} | ${'trad'} | ${'test'} | ${'/zhongwen/topics/cpydz21p02et/trad'} | ${'https://mock-bff-path/?id=cpydz21p02et&service=zhongwen&pageType=topic&variant=trad&serviceEnv=test'} + ${TOPIC_PAGE} | ${'zhongwen'} | ${'simp'} | ${'test'} | ${'/zhongwen/topics/c4vmr03pyn6t/simp'} | ${'https://mock-bff-path/?id=c4vmr03pyn6t&service=zhongwen&pageType=topic&variant=simp&serviceEnv=test'} ${UGC_PAGE} | ${'mundo'} | ${null} | ${'local'} | ${'/u50853489'} | ${'http://localhost/api/local/mundo/send/u50853489'} ${TV_PAGE} | ${'hausa'} | ${null} | ${'local'} | ${'/hausa/bbc_hausa_tv/tv/w172yjj7rfhxp1p'} | ${'http://localhost/hausa/bbc_hausa_tv/tv/w172yjj7rfhxp1p'} ${TV_PAGE} | ${'hindi'} | ${null} | ${'local'} | ${'/hindi/bbc_hindi_tv/tv_programmes/w13xttlw'} | ${'http://localhost/hindi/bbc_hindi_tv/tv_programmes/w13xttlw'} diff --git a/src/app/routes/utils/constructPageFetchUrl/index.ts b/src/app/routes/utils/constructPageFetchUrl/index.ts index 812ad11b034..cb8730d54ee 100644 --- a/src/app/routes/utils/constructPageFetchUrl/index.ts +++ b/src/app/routes/utils/constructPageFetchUrl/index.ts @@ -250,7 +250,7 @@ const constructPageFetchUrl = ({ break; case TOPIC_PAGE: { const variantPath = variant ? `/${variant}` : ''; - fetchUrl = Url(`/${service}${variantPath}/topics/${id}`); + fetchUrl = Url(`/${service}/topics/${id}${variantPath}`); break; } case LIVE_PAGE: { From dbb4df9fe29848670685105306b5c545260fef1f Mon Sep 17 00:00:00 2001 From: Nabeel Khan Date: Mon, 27 Jan 2025 12:18:09 +0000 Subject: [PATCH 7/7] reorganised order to local,test, live --- src/app/routes/utils/constructPageFetchUrl/index.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/routes/utils/constructPageFetchUrl/index.test.ts b/src/app/routes/utils/constructPageFetchUrl/index.test.ts index 4a84eecfa90..0a0bed78f43 100644 --- a/src/app/routes/utils/constructPageFetchUrl/index.test.ts +++ b/src/app/routes/utils/constructPageFetchUrl/index.test.ts @@ -122,12 +122,12 @@ describe('constructPageFetchUrl', () => { ${TOPIC_PAGE} | ${'persian'} | ${null} | ${'local'} | ${'/persian/topics/c00000000000t'} | ${'http://localhost/persian/topics/c00000000000t'} ${TOPIC_PAGE} | ${'persian'} | ${null} | ${'test'} | ${'/persian/topics/c00000000000t'} | ${'https://mock-bff-path/?id=c00000000000t&service=persian&pageType=topic&serviceEnv=test'} ${TOPIC_PAGE} | ${'persian'} | ${null} | ${'live'} | ${'/persian/topics/c00000000000t'} | ${'https://mock-bff-path/?id=c00000000000t&service=persian&pageType=topic&serviceEnv=live'} - ${TOPIC_PAGE} | ${'zhongwen'} | ${'trad'} | ${'live'} | ${'/zhongwen/topics/cpydz21p02et/trad'} | ${'https://mock-bff-path/?id=cpydz21p02et&service=zhongwen&pageType=topic&variant=trad&serviceEnv=live'} - ${TOPIC_PAGE} | ${'zhongwen'} | ${'simp'} | ${'live'} | ${'/zhongwen/topics/c4vmr03pyn6t/simp'} | ${'https://mock-bff-path/?id=c4vmr03pyn6t&service=zhongwen&pageType=topic&variant=simp&serviceEnv=live'} ${TOPIC_PAGE} | ${'zhongwen'} | ${'trad'} | ${'local'} | ${'/zhongwen/topics/cpydz21p02et/trad'} | ${'http://localhost/zhongwen/topics/cpydz21p02et/trad'} ${TOPIC_PAGE} | ${'zhongwen'} | ${'simp'} | ${'local'} | ${'/zhongwen/topics/c4vmr03pyn6t/simp'} | ${'http://localhost/zhongwen/topics/c4vmr03pyn6t/simp'} ${TOPIC_PAGE} | ${'zhongwen'} | ${'trad'} | ${'test'} | ${'/zhongwen/topics/cpydz21p02et/trad'} | ${'https://mock-bff-path/?id=cpydz21p02et&service=zhongwen&pageType=topic&variant=trad&serviceEnv=test'} ${TOPIC_PAGE} | ${'zhongwen'} | ${'simp'} | ${'test'} | ${'/zhongwen/topics/c4vmr03pyn6t/simp'} | ${'https://mock-bff-path/?id=c4vmr03pyn6t&service=zhongwen&pageType=topic&variant=simp&serviceEnv=test'} + ${TOPIC_PAGE} | ${'zhongwen'} | ${'trad'} | ${'live'} | ${'/zhongwen/topics/cpydz21p02et/trad'} | ${'https://mock-bff-path/?id=cpydz21p02et&service=zhongwen&pageType=topic&variant=trad&serviceEnv=live'} + ${TOPIC_PAGE} | ${'zhongwen'} | ${'simp'} | ${'live'} | ${'/zhongwen/topics/c4vmr03pyn6t/simp'} | ${'https://mock-bff-path/?id=c4vmr03pyn6t&service=zhongwen&pageType=topic&variant=simp&serviceEnv=live'} ${UGC_PAGE} | ${'mundo'} | ${null} | ${'local'} | ${'/u50853489'} | ${'http://localhost/api/local/mundo/send/u50853489'} ${TV_PAGE} | ${'hausa'} | ${null} | ${'local'} | ${'/hausa/bbc_hausa_tv/tv/w172yjj7rfhxp1p'} | ${'http://localhost/hausa/bbc_hausa_tv/tv/w172yjj7rfhxp1p'} ${TV_PAGE} | ${'hindi'} | ${null} | ${'local'} | ${'/hindi/bbc_hindi_tv/tv_programmes/w13xttlw'} | ${'http://localhost/hindi/bbc_hindi_tv/tv_programmes/w13xttlw'}