Skip to content

Commit dbb46fe

Browse files
committed
Rename EditorialTestData to FrontEditorialTestData in enahanceCards
1 parent 2179eee commit dbb46fe

2 files changed

Lines changed: 32 additions & 32 deletions

File tree

dotcom-rendering/src/model/enhanceCards.test.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
decideArticleMedia,
1212
decideReplacementMedia,
1313
getActiveMediaAtom,
14-
getEditorialTestData,
14+
getFrontEditorialTestData,
1515
getMediaMetadata,
1616
} from './enhanceCards';
1717

@@ -535,7 +535,7 @@ describe('Enhance Cards', () => {
535535
});
536536
});
537537

538-
describe('getEditorialTestData', () => {
538+
describe('getFrontEditorialTestData', () => {
539539
const cardWithNoEditorialTest = {
540540
properties: {
541541
isBreaking: false,
@@ -669,7 +669,7 @@ describe('Enhance Cards', () => {
669669

670670
it('returns undefined if no editorial test exists on the card, page is not in allowed fronts list, and user is not in a test bucket', () => {
671671
expect(
672-
getEditorialTestData(
672+
getFrontEditorialTestData(
673673
cardWithNoEditorialTest,
674674
{},
675675
true,
@@ -680,7 +680,7 @@ describe('Enhance Cards', () => {
680680

681681
it('returns undefined if editorial test exists and page is in allowed fronts list, but user is not in a test bucket', () => {
682682
expect(
683-
getEditorialTestData(
683+
getFrontEditorialTestData(
684684
cardWithEditorialTest,
685685
{},
686686
true,
@@ -691,7 +691,7 @@ describe('Enhance Cards', () => {
691691

692692
it('returns undefined if user is in a test bucket and page is in allowed fronts list, but editorial test does not exist', () => {
693693
expect(
694-
getEditorialTestData(
694+
getFrontEditorialTestData(
695695
cardWithNoEditorialTest,
696696
{
697697
'fronts-and-curation-editorial-test': 'a',
@@ -704,7 +704,7 @@ describe('Enhance Cards', () => {
704704

705705
it('returns undefined if editorial test exists and user is in a test bucket, but page is not in allowed fronts list', () => {
706706
expect(
707-
getEditorialTestData(
707+
getFrontEditorialTestData(
708708
cardWithEditorialTest,
709709
{
710710
'fronts-and-curation-editorial-test': 'a',
@@ -717,7 +717,7 @@ describe('Enhance Cards', () => {
717717

718718
it('returns undefined if editorial test exists, page is in allowed fronts list, user is in a variant bucket, but the feature switch is turned off ', () => {
719719
expect(
720-
getEditorialTestData(
720+
getFrontEditorialTestData(
721721
cardWithEditorialTest,
722722
{
723723
'fronts-and-curation-editorial-test': 'a',
@@ -730,7 +730,7 @@ describe('Enhance Cards', () => {
730730

731731
it('returns headline A & test uuid if editorial test exists, page is in allowed fronts list, and user is in bucket A', () => {
732732
expect(
733-
getEditorialTestData(
733+
getFrontEditorialTestData(
734734
cardWithEditorialTest,
735735
{
736736
'fronts-and-curation-editorial-test': 'a',
@@ -743,7 +743,7 @@ describe('Enhance Cards', () => {
743743

744744
it('returns headline B & test uuid if editorial test exists, page is in allowed fronts list, and user is in bucket B', () => {
745745
expect(
746-
getEditorialTestData(
746+
getFrontEditorialTestData(
747747
cardWithEditorialTest,
748748
{
749749
'fronts-and-curation-editorial-test': 'b',
@@ -756,7 +756,7 @@ describe('Enhance Cards', () => {
756756

757757
it('returns undefined if the bucket name does not match a variant meta id', () => {
758758
expect(
759-
getEditorialTestData(
759+
getFrontEditorialTestData(
760760
cardWithEditorialTest,
761761
{
762762
'fronts-and-curation-editorial-test': 'c',
@@ -769,7 +769,7 @@ describe('Enhance Cards', () => {
769769

770770
it('returns undefined if the variant headline is undefined', () => {
771771
expect(
772-
getEditorialTestData(
772+
getFrontEditorialTestData(
773773
cardWithEditorialTestWithUndefinedVariantMeta,
774774
{
775775
'fronts-and-curation-editorial-test': 'a',
@@ -782,7 +782,7 @@ describe('Enhance Cards', () => {
782782

783783
it('returns undefined if an editorial test has expired', () => {
784784
expect(
785-
getEditorialTestData(
785+
getFrontEditorialTestData(
786786
cardWithExpiredEditorialTest,
787787
{
788788
'fronts-and-curation-editorial-test': 'a',
@@ -795,7 +795,7 @@ describe('Enhance Cards', () => {
795795

796796
it('returns undefined if an editorial test has been manually ended', () => {
797797
expect(
798-
getEditorialTestData(
798+
getFrontEditorialTestData(
799799
cardWithManuallyEndedEditorialTest,
800800
{
801801
'fronts-and-curation-editorial-test': 'a',
@@ -808,7 +808,7 @@ describe('Enhance Cards', () => {
808808

809809
it('returns the variant headline & test uuid if an editorial test is present on a sublink', () => {
810810
expect(
811-
getEditorialTestData(
811+
getFrontEditorialTestData(
812812
cardWithSublinkWithEditorialTest
813813
.supportingContent[0] as FESupportingContent,
814814
{
@@ -822,7 +822,7 @@ describe('Enhance Cards', () => {
822822

823823
it('returns undefined for a sublink if an editorial test is expired on a sublink', () => {
824824
expect(
825-
getEditorialTestData(
825+
getFrontEditorialTestData(
826826
cardWithSublinkWithExpiredEditorialTest
827827
.supportingContent[0] as FESupportingContent,
828828
{

dotcom-rendering/src/model/enhanceCards.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ const decideVideoAtomImage = (
203203
* Checks if an editorial test is active by making sure it has not been manually ended,
204204
* that it has a valid expiry date, and that the expiry date is in the future
205205
*/
206-
const isActiveEditorialTest = (test: FrontEditorialTest) =>
206+
const isActiveFrontEditorialTest = (test: FrontEditorialTest) =>
207207
!test.hasManuallyEndedOnThisTrail &&
208208
!!test.expiryDate &&
209209
test.expiryDate > Date.now();
@@ -212,13 +212,13 @@ const isActiveEditorialTest = (test: FrontEditorialTest) =>
212212
* Looks through a list of editorial tests to see if there is an active test. If no active
213213
* test is found, return undefined
214214
*/
215-
const findActiveEditorialTest = (
215+
const findActiveFrontEditorialTest = (
216216
tests: FrontEditorialTest[] | undefined,
217217
): FrontEditorialTest | undefined => {
218-
return tests?.find((test) => isActiveEditorialTest(test));
218+
return tests?.find((test) => isActiveFrontEditorialTest(test));
219219
};
220220

221-
type EditorialTestData = {
221+
type FrontEditorialTestData = {
222222
headline: string;
223223
uuid: string;
224224
};
@@ -228,24 +228,24 @@ type EditorialTestData = {
228228
* the the testing switch is enabled, the page is in the test bucket, the test can run on the given front,
229229
* and that a valid variant headline is defined before returning the variant headline and test UUID.
230230
*/
231-
export const getEditorialTestData = (
231+
export const getFrontEditorialTestData = (
232232
faciaCard: FEFrontCard | FESupportingContent,
233233
serverSideABTests: Record<string, string>,
234234
isEditorialABTestingEnabled: boolean,
235235
pageId?: string,
236-
): EditorialTestData | undefined => {
237-
const activeEditorialTest = findActiveEditorialTest(
236+
): FrontEditorialTestData | undefined => {
237+
const activeFrontEditorialTest = findActiveFrontEditorialTest(
238238
faciaCard.properties.tests,
239239
);
240240

241241
// don't return data if there is no active test on the card or editorial testing is switched off
242-
if (!activeEditorialTest || !isEditorialABTestingEnabled) {
242+
if (!activeFrontEditorialTest || !isEditorialABTestingEnabled) {
243243
return undefined;
244244
}
245245

246246
const testCanRunOnPage =
247247
!isUndefined(pageId) &&
248-
activeEditorialTest.frontsThisTestCanRunOn.includes(pageId);
248+
activeFrontEditorialTest.frontsThisTestCanRunOn.includes(pageId);
249249

250250
// don't return data if test cannot run on the current front
251251
if (!testCanRunOnPage) return undefined;
@@ -257,7 +257,7 @@ export const getEditorialTestData = (
257257
return undefined;
258258
}
259259

260-
const variantMeta = activeEditorialTest.variantMeta.find(
260+
const variantMeta = activeFrontEditorialTest.variantMeta.find(
261261
(variant) => variant.id.toLowerCase() === testBucket,
262262
);
263263

@@ -266,7 +266,7 @@ export const getEditorialTestData = (
266266

267267
return {
268268
headline: variantMeta.meta.headline,
269-
uuid: activeEditorialTest.testUuid,
269+
uuid: activeFrontEditorialTest.testUuid,
270270
};
271271
};
272272

@@ -280,16 +280,16 @@ export const decideHeadline = (
280280
isEditorialABTestingEnabled: boolean,
281281
pageId?: string,
282282
): string => {
283-
const editorialTestData = getEditorialTestData(
283+
const frontEditorialTestData = getFrontEditorialTestData(
284284
faciaCard,
285285
serverSideABTests,
286286
isEditorialABTestingEnabled,
287287
pageId,
288288
);
289289

290-
if (isUndefined(editorialTestData)) return faciaCard.header.headline;
290+
if (isUndefined(frontEditorialTestData)) return faciaCard.header.headline;
291291

292-
return editorialTestData.headline;
292+
return frontEditorialTestData.headline;
293293
};
294294

295295
/**
@@ -301,16 +301,16 @@ export const findHeadlineTestUuid = (
301301
isEditorialABTestingEnabled: boolean,
302302
pageId?: string,
303303
): string | undefined => {
304-
const editorialTestData = getEditorialTestData(
304+
const frontEditorialTestData = getFrontEditorialTestData(
305305
faciaCard,
306306
serverSideABTests,
307307
isEditorialABTestingEnabled,
308308
pageId,
309309
);
310310

311-
if (isUndefined(editorialTestData)) return undefined;
311+
if (isUndefined(frontEditorialTestData)) return undefined;
312312

313-
return editorialTestData.uuid;
313+
return frontEditorialTestData.uuid;
314314
};
315315

316316
/**

0 commit comments

Comments
 (0)