Skip to content

Commit

Permalink
Merge pull request #10884 from bbc/WSTEAMA-439-route-kyrgyz-homepage
Browse files Browse the repository at this point in the history
WSTEAMA 439 Route Kyrgyz Homepage
  • Loading branch information
karinathomasbbc authored Jun 13, 2023
2 parents ddb037f + 8d0c06a commit ffbf4ec
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 93 deletions.
53 changes: 37 additions & 16 deletions src/app/routes/utils/regex/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ describe('articleDataPath', () => {

describe('frontPagePath', () => {
const validRoutes = [
'/news',
'/news.amp',
'/ukchina/simp',
'/ukchina/trad',
'/serbian/lat.amp',
Expand All @@ -120,14 +118,14 @@ describe('frontPagePath', () => {
'/iplayer',
'/news/foobar',
'/news/foobar.amp',
'/persian',
'/persian.amp',
'/kyrgyz',
'/kyrgyz.amp',
];
shouldNotMatchInvalidRoutes(invalidRoutes, frontPagePath);
});

describe('frontPageDataPath', () => {
const validRoutes = ['/news.json', '/serbian/cyr.json', '/ukchina/trad.json'];
const validRoutes = ['/serbian/cyr.json', '/ukchina/trad.json'];
shouldMatchValidRoutes(validRoutes, frontPageDataPath);

const invalidRoutes = [
Expand Down Expand Up @@ -529,8 +527,6 @@ describe('legacyAssetPageDataPath', () => {
describe('frontPage -> homePage migration', () => {
const services = Object.keys(serviceConfig);

const servicesWithVariants = ['serbian', 'ukchina', 'zhongwen'];

const servicesNotCoveredByWorldService = [
'sport',
'scotland',
Expand All @@ -541,13 +537,27 @@ describe('frontPage -> homePage migration', () => {
'archive',
];

const homePageServices = services.filter(
service =>
!servicesWithVariants.includes(service) &&
!servicesNotCoveredByWorldService.includes(service),
const worldServices = services.filter(
service => !servicesNotCoveredByWorldService.includes(service),
);

const homePageRoutes = homePageServices.map(service => `/${service}`);
const serviceToRoute = service => `/${service}`;

const servicesWithVariants = ['serbian', 'ukchina', 'zhongwen'];
const servicesWithVariantsRoutes = servicesWithVariants.map(serviceToRoute);

const servicesWithoutVariantsRoutes = worldServices
.filter(service => !servicesWithVariants.includes(service))
.map(serviceToRoute);

const migratedServices = ['kyrgyz'];
const migratedWorldServiceRoutes = migratedServices.map(serviceToRoute);

const liveFrontPageServices = worldServices.filter(
service => !migratedServices.includes(service),
);

const liveFrontPageRoutes = liveFrontPageServices.map(serviceToRoute);

const originalApplicationEnvironment = process.env.SIMORGH_APP_ENV;

Expand All @@ -562,7 +572,9 @@ describe('frontPage -> homePage migration', () => {

const homePageRegex = getHomePageRegex(services);

shouldMatchValidRoutes(homePageRoutes, homePageRegex);
shouldMatchValidRoutes(servicesWithoutVariantsRoutes, homePageRegex);

shouldNotMatchInvalidRoutes(servicesWithVariantsRoutes, homePageRegex);
},
);

Expand All @@ -573,7 +585,12 @@ describe('frontPage -> homePage migration', () => {

const frontPageRegex = getFrontPageRegex(services);

shouldNotMatchInvalidRoutes(homePageRoutes, frontPageRegex);
shouldMatchValidRoutes(servicesWithVariantsRoutes, frontPageRegex);

shouldNotMatchInvalidRoutes(
servicesWithoutVariantsRoutes,
frontPageRegex,
);
},
);

Expand All @@ -582,14 +599,18 @@ describe('frontPage -> homePage migration', () => {

const frontPageRegex = getFrontPageRegex(services);

shouldMatchValidRoutes(homePageRoutes, frontPageRegex);
shouldMatchValidRoutes(liveFrontPageRoutes, frontPageRegex);

shouldNotMatchInvalidRoutes(migratedWorldServiceRoutes, frontPageRegex);
});

describe(`homePage regex on the live environment`, () => {
process.env.SIMORGH_APP_ENV = 'live';

const homePageRegex = getHomePageRegex(services);

shouldNotMatchInvalidRoutes(homePageRoutes, homePageRegex);
shouldMatchValidRoutes(migratedWorldServiceRoutes, homePageRegex);

shouldNotMatchInvalidRoutes(liveFrontPageRoutes, homePageRegex);
});
});
Loading

0 comments on commit ffbf4ec

Please sign in to comment.