From df81de189f5cd7b33fb71370cc14833f090028c0 Mon Sep 17 00:00:00 2001 From: Emma Imber Date: Wed, 9 Sep 2026 17:07:10 +0100 Subject: [PATCH 1/6] Add headline test uuid to card links WIP --- dotcom-rendering/src/components/Card/Card.tsx | 3 ++ .../components/Card/components/CardLink.tsx | 14 ++++++ .../src/components/FeatureCard.tsx | 6 +++ .../src/components/FlexibleGeneral.tsx | 1 + dotcom-rendering/src/components/FrontCard.tsx | 1 + .../components/Masthead/HighlightsCard.tsx | 3 ++ .../components/ScrollableFeature.island.tsx | 1 + .../src/components/StaticFeatureTwo.tsx | 1 + .../src/components/SupportingContent.tsx | 3 ++ dotcom-rendering/src/model/enhanceCards.ts | 44 +++++++++++++++++++ dotcom-rendering/src/types/front.ts | 2 + 11 files changed, 79 insertions(+) diff --git a/dotcom-rendering/src/components/Card/Card.tsx b/dotcom-rendering/src/components/Card/Card.tsx index c85c10761d2..0284c8c0356 100644 --- a/dotcom-rendering/src/components/Card/Card.tsx +++ b/dotcom-rendering/src/components/Card/Card.tsx @@ -164,6 +164,7 @@ export type Props = { headlinePosition?: 'inner' | 'outer'; starRatingSize?: RatingSizeType; contentSpacing?: 'small' | 'large'; + headlineTestUuid?: string; }; const waveformWrapper = ( @@ -410,6 +411,7 @@ export const Card = ({ starRatingSize = 'small', articleMedia, contentSpacing, + headlineTestUuid, }: Props) => { const ab = useAB(); const isInLoopClickTestControl = Boolean( @@ -830,6 +832,7 @@ export const Card = ({ isExternalLink={isExternalLink} isLoopAndInLoopClickTest={isLoopAndInLoopClickTest} shouldRaiseZIndexForAbTest={false} // The z-index is raised in a new CardLink in the SelfHostedVideo island. + headlineTestUuid={headlineTestUuid} /> {headlinePosition === 'outer' && (
{ return ( ); @@ -64,11 +70,13 @@ const ExternalLink = ({ headlineText, dataLinkName, shouldRaiseZIndexForAbTest, + headlineTestUuid, }: { linkTo: string; headlineText: string; dataLinkName?: string; shouldRaiseZIndexForAbTest: boolean; + headlineTestUuid?: string; }) => { return ( { /** * If we are in the loop click through test, we add a unique string to the data link name @@ -109,6 +121,7 @@ export const CardLink = ({ headlineText={headlineText} dataLinkName={clickThroughLinkName} shouldRaiseZIndexForAbTest={shouldRaiseZIndexForAbTest} + headlineTestUuid={headlineTestUuid} /> )} {!isExternalLink && ( @@ -117,6 +130,7 @@ export const CardLink = ({ headlineText={headlineText} dataLinkName={clickThroughLinkName} shouldRaiseZIndexForAbTest={shouldRaiseZIndexForAbTest} + headlineTestUuid={headlineTestUuid} /> )} diff --git a/dotcom-rendering/src/components/FeatureCard.tsx b/dotcom-rendering/src/components/FeatureCard.tsx index f2c069c24fa..f5339105d20 100644 --- a/dotcom-rendering/src/components/FeatureCard.tsx +++ b/dotcom-rendering/src/components/FeatureCard.tsx @@ -407,6 +407,7 @@ export type Props = { */ isImmersive?: boolean; starRatingSize: RatingSizeType; + headlineTestUuid?: string; }; export const FeatureCard = ({ @@ -445,6 +446,7 @@ export const FeatureCard = ({ isImmersive = false, starRatingSize, articleMedia, + headlineTestUuid, }: Props) => { const ab = useAB(); const isInLoopClickTestControl = Boolean( @@ -546,6 +548,7 @@ export const FeatureCard = ({ shouldRaiseZIndexForAbTest={ isLoopAndInLoopClickTestVariant } + headlineTestUuid={headlineTestUuid} /> )}
@@ -769,6 +772,9 @@ export const FeatureCard = ({ shouldRaiseZIndexForAbTest={ isLoopAndInLoopClickTestVariant } + headlineTestUuid={ + headlineTestUuid + } /> )} diff --git a/dotcom-rendering/src/components/FlexibleGeneral.tsx b/dotcom-rendering/src/components/FlexibleGeneral.tsx index 82e2bee2faa..cde38b02a64 100644 --- a/dotcom-rendering/src/components/FlexibleGeneral.tsx +++ b/dotcom-rendering/src/components/FlexibleGeneral.tsx @@ -141,6 +141,7 @@ const ImmersiveCardLayout = ({ isImmersive={true} starRatingSize="medium" articleMedia={card.articleMedia} + headlineTestUuid={card.headlineTestUuid} /> diff --git a/dotcom-rendering/src/components/FrontCard.tsx b/dotcom-rendering/src/components/FrontCard.tsx index ea9bad0d677..930629a12e6 100644 --- a/dotcom-rendering/src/components/FrontCard.tsx +++ b/dotcom-rendering/src/components/FrontCard.tsx @@ -59,6 +59,7 @@ export const FrontCard = (props: Props) => { starRating: trail.starRating, uniqueId: trail.uniqueId, webPublicationDate: trail.webPublicationDate, + headlineTestUuid: trail.headlineTestUuid, }; return Card({ ...defaultProps, ...cardProps }); diff --git a/dotcom-rendering/src/components/Masthead/HighlightsCard.tsx b/dotcom-rendering/src/components/Masthead/HighlightsCard.tsx index 57279975859..786f2a43e41 100644 --- a/dotcom-rendering/src/components/Masthead/HighlightsCard.tsx +++ b/dotcom-rendering/src/components/Masthead/HighlightsCard.tsx @@ -37,6 +37,7 @@ export type HighlightsCardProps = { byline?: string; isExternalLink: boolean; starRating?: Rating; + headlineTestUuid?: string; }; const container = css` @@ -135,6 +136,7 @@ export const HighlightsCard = ({ isExternalLink, starRating, articleMedia, + headlineTestUuid, }: HighlightsCardProps) => { const isMediaCard = isMedia(format); @@ -154,6 +156,7 @@ export const HighlightsCard = ({ isExternalLink={isExternalLink} isLoopAndInLoopClickTest={false} shouldRaiseZIndexForAbTest={false} + headlineTestUuid={headlineTestUuid} />
diff --git a/dotcom-rendering/src/components/ScrollableFeature.island.tsx b/dotcom-rendering/src/components/ScrollableFeature.island.tsx index 4a23a22de8f..9df79e8452c 100644 --- a/dotcom-rendering/src/components/ScrollableFeature.island.tsx +++ b/dotcom-rendering/src/components/ScrollableFeature.island.tsx @@ -91,6 +91,7 @@ export const ScrollableFeature = ({ showQuotes={card.showQuotedHeadline} starRatingSize={'small'} articleMedia={card.articleMedia} + headlineTestUuid={card.headlineTestUuid} /> ))} diff --git a/dotcom-rendering/src/components/StaticFeatureTwo.tsx b/dotcom-rendering/src/components/StaticFeatureTwo.tsx index 05d73a0c092..dd8e149d611 100644 --- a/dotcom-rendering/src/components/StaticFeatureTwo.tsx +++ b/dotcom-rendering/src/components/StaticFeatureTwo.tsx @@ -80,6 +80,7 @@ export const StaticFeatureTwo = ({ showQuotes={card.showQuotedHeadline} starRatingSize={'medium'} articleMedia={card.articleMedia} + headlineTestUuid={card.headlineTestUuid} /> ); diff --git a/dotcom-rendering/src/components/SupportingContent.tsx b/dotcom-rendering/src/components/SupportingContent.tsx index 5c5a6f75e4e..db25e9c49c6 100644 --- a/dotcom-rendering/src/components/SupportingContent.tsx +++ b/dotcom-rendering/src/components/SupportingContent.tsx @@ -186,6 +186,9 @@ export const SupportingContent = ({ : verticalSublinkStyles, ]} data-link-name={`sublinks | ${index + 1}`} + {...(subLink.headlineTestUuid != undefined && { + 'data-fronts-test-uuid': subLink.headlineTestUuid, + })} > , + isEditorialABTestingEnabled: boolean, + pageId?: string, +): string | undefined => { + const testBucket = serverSideABTests['fronts-and-curation-editorial-test']; + + const activeEditorialTest = findActiveEditorialTest( + faciaCard.properties.tests, + ); + + if ( + !isEditorialABTestingEnabled || + isUndefined(testBucket) || + !activeEditorialTest + ) { + return undefined; + } + + const testCanRunOnPage = + !isUndefined(pageId) && + activeEditorialTest.frontsThisTestCanRunOn.includes(pageId); + + if (!testCanRunOnPage) return undefined; + + return activeEditorialTest.testUuid; +}; + /** * While the first Media Atom is *not* guaranteed to be the main media, * it *happens to be* correct in the majority of cases. @@ -596,5 +634,11 @@ export const enhanceCards = ( ?.allImages[0]?.fields.altText ?? '', }, }), + headlineTestUuid: findHeadlineTestUuid( + faciaCard, + serverSideABTests, + isEditorialABTestingEnabled, + pageId, + ), }; }); diff --git a/dotcom-rendering/src/types/front.ts b/dotcom-rendering/src/types/front.ts index d69e654cd0c..79cc7c114bb 100644 --- a/dotcom-rendering/src/types/front.ts +++ b/dotcom-rendering/src/types/front.ts @@ -106,6 +106,7 @@ export type DCRFrontCard = { uniqueId?: string; serverTime?: number; articleMedia?: ArticleMedia; + headlineTestUuid?: string; }; export type DCRSlideshowImage = { @@ -153,6 +154,7 @@ export type DCRSupportingContent = { url?: string; kickerText?: string; format: ArticleFormat; + headlineTestUuid?: string; }; export type TreatType = { From e75e2b7f8937d10c0cd6940f1d1a2b0c7c5f2bff Mon Sep 17 00:00:00 2001 From: Emma Imber Date: Fri, 11 Sep 2026 15:54:30 +0100 Subject: [PATCH 2/6] Pass headlineTestUuid into hightlight cards --- dotcom-rendering/src/components/ScrollableHighlights.island.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/dotcom-rendering/src/components/ScrollableHighlights.island.tsx b/dotcom-rendering/src/components/ScrollableHighlights.island.tsx index e98a44673ed..65f33f9a4c9 100644 --- a/dotcom-rendering/src/components/ScrollableHighlights.island.tsx +++ b/dotcom-rendering/src/components/ScrollableHighlights.island.tsx @@ -341,6 +341,7 @@ export const ScrollableHighlights = ({ trails, frontId }: Props) => { mainMedia={trail.mainMedia} starRating={trail.starRating} articleMedia={trail.articleMedia} + headlineTestUuid={trail.headlineTestUuid} /> )} From da83bf20e56ae615a48102d813f72dc239f666dc Mon Sep 17 00:00:00 2001 From: Emma Imber Date: Mon, 14 Sep 2026 15:24:01 +0100 Subject: [PATCH 3/6] Add fronts test UUID to sublinks --- dotcom-rendering/src/model/enhanceCards.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/dotcom-rendering/src/model/enhanceCards.ts b/dotcom-rendering/src/model/enhanceCards.ts index b6b1ea5cdb7..db69e08cbbb 100644 --- a/dotcom-rendering/src/model/enhanceCards.ts +++ b/dotcom-rendering/src/model/enhanceCards.ts @@ -62,12 +62,12 @@ const enhanceSupportingContent = ( url: decideUrl(subLink), kickerText: !kickerText && supportingContentIsLive ? 'Live' : kickerText, - // headlineTestUuid: findHeadlineTestUuid( - // subLink, - // serverSideABTests, - // isEditorialABTestingEnabled, - // pageId, - // ), + headlineTestUuid: findHeadlineTestUuid( + subLink, + serverSideABTests, + isEditorialABTestingEnabled, + pageId, + ), }; }); }; @@ -264,7 +264,7 @@ export const decideHeadline = ( * Find the UUID of a headline test if one is running on the card */ export const findHeadlineTestUuid = ( - faciaCard: FEFrontCard, + faciaCard: FEFrontCard | FESupportingContent, serverSideABTests: Record, isEditorialABTestingEnabled: boolean, pageId?: string, From 6caad7a1fa7197cee54b6053a508edc2362f57ea Mon Sep 17 00:00:00 2001 From: Emma Imber Date: Mon, 14 Sep 2026 16:25:30 +0100 Subject: [PATCH 4/6] Refactor test validity logic to share between functions, and amend testing to cover uuid as well as headline --- .../src/model/enhanceCards.test.ts | 87 +++++++++--------- dotcom-rendering/src/model/enhanceCards.ts | 91 ++++++++++++------- 2 files changed, 102 insertions(+), 76 deletions(-) diff --git a/dotcom-rendering/src/model/enhanceCards.test.ts b/dotcom-rendering/src/model/enhanceCards.test.ts index abc78edf251..81134270851 100644 --- a/dotcom-rendering/src/model/enhanceCards.test.ts +++ b/dotcom-rendering/src/model/enhanceCards.test.ts @@ -9,9 +9,9 @@ import type { EditorialTest, VariantMeta } from '../types/front'; import type { MainMedia } from '../types/mainMedia'; import { decideArticleMedia, - decideHeadline, decideReplacementMedia, getActiveMediaAtom, + getEditorialTestData, getMediaMetadata, } from './enhanceCards'; @@ -535,7 +535,7 @@ describe('Enhance Cards', () => { }); }); - describe('decideHeadline', () => { + describe('getEditorialTestData', () => { const cardWithNoEditorialTest = { properties: { isBreaking: false, @@ -667,26 +667,31 @@ describe('Enhance Cards', () => { supportingContent: [cardWithExpiredEditorialTest], }; - it('returns the default headline if no editorial test exists on the card, page is not in allowed fronts list, and user is not in a test bucket', () => { + 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', () => { expect( - decideHeadline( + getEditorialTestData( cardWithNoEditorialTest, {}, true, 'invalid-test-front', ), - ).toEqual('Headline'); + ).toEqual(undefined); }); - it('returns the default headline if editorial test exists and page is in allowed fronts list, but user is not in a test bucket', () => { + it('returns undefined if editorial test exists and page is in allowed fronts list, but user is not in a test bucket', () => { expect( - decideHeadline(cardWithEditorialTest, {}, true, 'test-front'), - ).toEqual('Headline'); + getEditorialTestData( + cardWithEditorialTest, + {}, + true, + 'test-front', + ), + ).toEqual(undefined); }); - it('returns the default headline if user is in a test bucket and page is in allowed fronts list, but editorial test does not exist', () => { + it('returns undefined if user is in a test bucket and page is in allowed fronts list, but editorial test does not exist', () => { expect( - decideHeadline( + getEditorialTestData( cardWithNoEditorialTest, { 'fronts-and-curation-editorial-test': 'a', @@ -694,12 +699,12 @@ describe('Enhance Cards', () => { true, 'test-front', ), - ).toEqual('Headline'); + ).toEqual(undefined); }); - it('returns the default headline if editorial test exists and user is in a test bucket, but page is not in allowed fronts list', () => { + it('returns undefined if editorial test exists and user is in a test bucket, but page is not in allowed fronts list', () => { expect( - decideHeadline( + getEditorialTestData( cardWithEditorialTest, { 'fronts-and-curation-editorial-test': 'a', @@ -707,12 +712,12 @@ describe('Enhance Cards', () => { true, 'invalid-test-front', ), - ).toEqual('Headline'); + ).toEqual(undefined); }); - it('returns the default headline if editorial test exists, page is in allowed fronts list, user is in a variant bucket, but the feature switch is turned off ', () => { + 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 ', () => { expect( - decideHeadline( + getEditorialTestData( cardWithEditorialTest, { 'fronts-and-curation-editorial-test': 'a', @@ -720,12 +725,12 @@ describe('Enhance Cards', () => { false, 'test-front', ), - ).toEqual('Headline'); + ).toEqual(undefined); }); - it('returns headline A if editorial test exists, page is in allowed fronts list, and user is in bucket A', () => { + it('returns headline A & test uuid if editorial test exists, page is in allowed fronts list, and user is in bucket A', () => { expect( - decideHeadline( + getEditorialTestData( cardWithEditorialTest, { 'fronts-and-curation-editorial-test': 'a', @@ -733,12 +738,12 @@ describe('Enhance Cards', () => { true, 'test-front', ), - ).toEqual('Headline A'); + ).toEqual({ headline: 'Headline A', uuid: 'uuid' }); }); - it('returns headline B if editorial test exists, page is in allowed fronts list, and user is in bucket B', () => { + it('returns headline B & test uuid if editorial test exists, page is in allowed fronts list, and user is in bucket B', () => { expect( - decideHeadline( + getEditorialTestData( cardWithEditorialTest, { 'fronts-and-curation-editorial-test': 'b', @@ -746,12 +751,12 @@ describe('Enhance Cards', () => { true, 'test-front', ), - ).toEqual('Headline B'); + ).toEqual({ headline: 'Headline B', uuid: 'uuid' }); }); - it('returns the default headline if the bucket name does not match a variant meta id', () => { + it('returns undefined if the bucket name does not match a variant meta id', () => { expect( - decideHeadline( + getEditorialTestData( cardWithEditorialTest, { 'fronts-and-curation-editorial-test': 'c', @@ -759,12 +764,12 @@ describe('Enhance Cards', () => { true, 'test-front', ), - ).toEqual('Headline'); + ).toEqual(undefined); }); - it('returns the default headline if the variant headline is undefined', () => { + it('returns undefined if the variant headline is undefined', () => { expect( - decideHeadline( + getEditorialTestData( cardWithEditorialTestWithUndefinedVariantMeta, { 'fronts-and-curation-editorial-test': 'a', @@ -772,12 +777,12 @@ describe('Enhance Cards', () => { true, 'test-front', ), - ).toEqual('Headline'); + ).toEqual(undefined); }); - it('returns the default headline if an editorial test has expired', () => { + it('returns undefined if an editorial test has expired', () => { expect( - decideHeadline( + getEditorialTestData( cardWithExpiredEditorialTest, { 'fronts-and-curation-editorial-test': 'a', @@ -785,12 +790,12 @@ describe('Enhance Cards', () => { true, 'test-front', ), - ).toEqual('Headline'); + ).toEqual(undefined); }); - it('returns the default headline if an editorial test has been manually ended', () => { + it('returns undefined if an editorial test has been manually ended', () => { expect( - decideHeadline( + getEditorialTestData( cardWithManuallyEndedEditorialTest, { 'fronts-and-curation-editorial-test': 'a', @@ -798,12 +803,12 @@ describe('Enhance Cards', () => { true, 'test-front', ), - ).toEqual('Headline'); + ).toEqual(undefined); }); - it('returns the variant headline if an editorial test is present on a sublink', () => { + it('returns the variant headline & test uuid if an editorial test is present on a sublink', () => { expect( - decideHeadline( + getEditorialTestData( cardWithSublinkWithEditorialTest .supportingContent[0] as FESupportingContent, { @@ -812,12 +817,12 @@ describe('Enhance Cards', () => { true, 'test-front', ), - ).toEqual('Headline A'); + ).toEqual({ headline: 'Headline A', uuid: 'uuid' }); }); - it('returns the default headline for a sublink if an editorial test is expired on a sublink', () => { + it('returns undefined for a sublink if an editorial test is expired on a sublink', () => { expect( - decideHeadline( + getEditorialTestData( cardWithSublinkWithExpiredEditorialTest .supportingContent[0] as FESupportingContent, { @@ -826,7 +831,7 @@ describe('Enhance Cards', () => { true, 'test-front', ), - ).toEqual('Headline'); + ).toEqual(undefined); }); }); }); diff --git a/dotcom-rendering/src/model/enhanceCards.ts b/dotcom-rendering/src/model/enhanceCards.ts index db69e08cbbb..1de86bb4647 100644 --- a/dotcom-rendering/src/model/enhanceCards.ts +++ b/dotcom-rendering/src/model/enhanceCards.ts @@ -218,46 +218,78 @@ const findActiveEditorialTest = ( return tests?.find((test) => isActiveEditorialTest(test)); }; +type TestData = { + headline: string; + uuid: string; +}; + /** - * Decide the headline to be shown for a given card. If there is an active editorial test on a card, - * return the variant headline matching the user test group. Otherwise, return the default headline + * Centralises the logic used by both the decideHeadline and findHeadlineTestUuid functions. Makes sure that + * the the testing switch is enabled, the page is in the test bucket, the test can run on the given front, + * and that a valid variant headline is defined before returning the variant headline and test UUID. */ -export const decideHeadline = ( +export const getEditorialTestData = ( faciaCard: FEFrontCard | FESupportingContent, serverSideABTests: Record, isEditorialABTestingEnabled: boolean, pageId?: string, -): string => { - const defaultHeadline = faciaCard.header.headline; - - const testBucket = serverSideABTests['fronts-and-curation-editorial-test']; - +): TestData | undefined => { const activeEditorialTest = findActiveEditorialTest( faciaCard.properties.tests, ); - if ( - !isEditorialABTestingEnabled || - isUndefined(testBucket) || - !activeEditorialTest - ) { - return defaultHeadline; + // don't return data if there is no active test on the card or editorial testing is switched off + if (!activeEditorialTest || !isEditorialABTestingEnabled) { + return undefined; } const testCanRunOnPage = !isUndefined(pageId) && activeEditorialTest.frontsThisTestCanRunOn.includes(pageId); - if (!testCanRunOnPage) return defaultHeadline; + // don't return data if test cannot run on the current front + if (!testCanRunOnPage) return undefined; + + const testBucket = serverSideABTests['fronts-and-curation-editorial-test']; + + // don't return data if the pageview is not in the editorial test bucket + if (isUndefined(testBucket)) { + return undefined; + } const variantMeta = activeEditorialTest.variantMeta.find( (variant) => variant.id.toLowerCase() === testBucket, ); // make sure the variant headline isn't undefined and that it is of type string - if (typeof variantMeta?.meta.headline !== 'string') return defaultHeadline; + if (typeof variantMeta?.meta.headline !== 'string') return undefined; - return variantMeta.meta.headline; + return { + headline: variantMeta.meta.headline, + uuid: activeEditorialTest.testUuid, + }; +}; + +/** + * Decide the headline to be shown for a given card. If there is an active editorial test on a card, + * return the variant headline matching the user test group. Otherwise, return the default headline + */ +export const decideHeadline = ( + faciaCard: FEFrontCard | FESupportingContent, + serverSideABTests: Record, + isEditorialABTestingEnabled: boolean, + pageId?: string, +): string => { + const testData = getEditorialTestData( + faciaCard, + serverSideABTests, + isEditorialABTestingEnabled, + pageId, + ); + + if (isUndefined(testData)) return faciaCard.header.headline; + + return testData.headline; }; /** @@ -269,27 +301,16 @@ export const findHeadlineTestUuid = ( isEditorialABTestingEnabled: boolean, pageId?: string, ): string | undefined => { - const testBucket = serverSideABTests['fronts-and-curation-editorial-test']; - - const activeEditorialTest = findActiveEditorialTest( - faciaCard.properties.tests, + const testData = getEditorialTestData( + faciaCard, + serverSideABTests, + isEditorialABTestingEnabled, + pageId, ); - if ( - !isEditorialABTestingEnabled || - isUndefined(testBucket) || - !activeEditorialTest - ) { - return undefined; - } - - const testCanRunOnPage = - !isUndefined(pageId) && - activeEditorialTest.frontsThisTestCanRunOn.includes(pageId); - - if (!testCanRunOnPage) return undefined; + if (isUndefined(testData)) return undefined; - return activeEditorialTest.testUuid; + return testData.uuid; }; /** From 22f48a86c9225cf02c278d31e90c929e5abb69a5 Mon Sep 17 00:00:00 2001 From: Emma Imber Date: Mon, 14 Sep 2026 16:44:27 +0100 Subject: [PATCH 5/6] More specific naming to avoid confusion with other tests --- dotcom-rendering/src/model/enhanceCards.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/dotcom-rendering/src/model/enhanceCards.ts b/dotcom-rendering/src/model/enhanceCards.ts index 1de86bb4647..5dde8bf48f1 100644 --- a/dotcom-rendering/src/model/enhanceCards.ts +++ b/dotcom-rendering/src/model/enhanceCards.ts @@ -218,7 +218,7 @@ const findActiveEditorialTest = ( return tests?.find((test) => isActiveEditorialTest(test)); }; -type TestData = { +type EditorialTestData = { headline: string; uuid: string; }; @@ -233,7 +233,7 @@ export const getEditorialTestData = ( serverSideABTests: Record, isEditorialABTestingEnabled: boolean, pageId?: string, -): TestData | undefined => { +): EditorialTestData | undefined => { const activeEditorialTest = findActiveEditorialTest( faciaCard.properties.tests, ); @@ -280,16 +280,16 @@ export const decideHeadline = ( isEditorialABTestingEnabled: boolean, pageId?: string, ): string => { - const testData = getEditorialTestData( + const editorialTestData = getEditorialTestData( faciaCard, serverSideABTests, isEditorialABTestingEnabled, pageId, ); - if (isUndefined(testData)) return faciaCard.header.headline; + if (isUndefined(editorialTestData)) return faciaCard.header.headline; - return testData.headline; + return editorialTestData.headline; }; /** @@ -301,16 +301,16 @@ export const findHeadlineTestUuid = ( isEditorialABTestingEnabled: boolean, pageId?: string, ): string | undefined => { - const testData = getEditorialTestData( + const editorialTestData = getEditorialTestData( faciaCard, serverSideABTests, isEditorialABTestingEnabled, pageId, ); - if (isUndefined(testData)) return undefined; + if (isUndefined(editorialTestData)) return undefined; - return testData.uuid; + return editorialTestData.uuid; }; /** From 3338d0ceb51e7d2e8d13b0e9a47328c859dea327 Mon Sep 17 00:00:00 2001 From: Emma Imber Date: Tue, 15 Sep 2026 10:20:49 +0100 Subject: [PATCH 6/6] Simplify syntax of data-fronts-test-uuid attribute assignment --- .../src/components/Card/components/CardLink.tsx | 8 ++------ dotcom-rendering/src/components/SupportingContent.tsx | 4 +--- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/dotcom-rendering/src/components/Card/components/CardLink.tsx b/dotcom-rendering/src/components/Card/components/CardLink.tsx index 09c356e4ca5..8f72f173ad1 100644 --- a/dotcom-rendering/src/components/Card/components/CardLink.tsx +++ b/dotcom-rendering/src/components/Card/components/CardLink.tsx @@ -57,9 +57,7 @@ const InternalLink = ({ shouldRaiseZIndexForAbTest ? abTestZIndexStyles : zIndexStyles, ]} data-link-name={dataLinkName} - {...(headlineTestUuid != undefined && { - 'data-fronts-test-uuid': headlineTestUuid, - })} + data-fronts-test-uuid={headlineTestUuid} aria-label={headlineText} /> ); @@ -86,9 +84,7 @@ const ExternalLink = ({ shouldRaiseZIndexForAbTest ? abTestZIndexStyles : zIndexStyles, ]} data-link-name={dataLinkName} - {...(headlineTestUuid != undefined && { - 'data-fronts-test-uuid': headlineTestUuid, - })} + data-fronts-test-uuid={headlineTestUuid} aria-label={headlineText + ' (opens in new tab)'} target="_blank" rel="noreferrer" diff --git a/dotcom-rendering/src/components/SupportingContent.tsx b/dotcom-rendering/src/components/SupportingContent.tsx index db25e9c49c6..db040c2f679 100644 --- a/dotcom-rendering/src/components/SupportingContent.tsx +++ b/dotcom-rendering/src/components/SupportingContent.tsx @@ -186,9 +186,7 @@ export const SupportingContent = ({ : verticalSublinkStyles, ]} data-link-name={`sublinks | ${index + 1}`} - {...(subLink.headlineTestUuid != undefined && { - 'data-fronts-test-uuid': subLink.headlineTestUuid, - })} + data-fronts-test-uuid={subLink.headlineTestUuid} >