Skip to content

Commit df81de1

Browse files
committed
Add headline test uuid to card links WIP
1 parent 9680460 commit df81de1

11 files changed

Lines changed: 79 additions & 0 deletions

File tree

dotcom-rendering/src/components/Card/Card.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ export type Props = {
164164
headlinePosition?: 'inner' | 'outer';
165165
starRatingSize?: RatingSizeType;
166166
contentSpacing?: 'small' | 'large';
167+
headlineTestUuid?: string;
167168
};
168169

169170
const waveformWrapper = (
@@ -410,6 +411,7 @@ export const Card = ({
410411
starRatingSize = 'small',
411412
articleMedia,
412413
contentSpacing,
414+
headlineTestUuid,
413415
}: Props) => {
414416
const ab = useAB();
415417
const isInLoopClickTestControl = Boolean(
@@ -830,6 +832,7 @@ export const Card = ({
830832
isExternalLink={isExternalLink}
831833
isLoopAndInLoopClickTest={isLoopAndInLoopClickTest}
832834
shouldRaiseZIndexForAbTest={false} // The z-index is raised in a new CardLink in the SelfHostedVideo island.
835+
headlineTestUuid={headlineTestUuid}
833836
/>
834837
{headlinePosition === 'outer' && (
835838
<div

dotcom-rendering/src/components/Card/components/CardLink.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,21 @@ type Props = {
3333
* Refers to the AB test with name: fronts-and-curation-loop-click-through
3434
*/
3535
shouldRaiseZIndexForAbTest: boolean;
36+
headlineTestUuid?: string;
3637
};
3738

3839
const InternalLink = ({
3940
linkTo,
4041
headlineText,
4142
dataLinkName,
4243
shouldRaiseZIndexForAbTest,
44+
headlineTestUuid,
4345
}: {
4446
linkTo: string;
4547
headlineText: string;
4648
dataLinkName?: string;
4749
shouldRaiseZIndexForAbTest: boolean;
50+
headlineTestUuid?: string;
4851
}) => {
4952
return (
5053
<a
@@ -54,6 +57,9 @@ const InternalLink = ({
5457
shouldRaiseZIndexForAbTest ? abTestZIndexStyles : zIndexStyles,
5558
]}
5659
data-link-name={dataLinkName}
60+
{...(headlineTestUuid != undefined && {
61+
'data-fronts-test-uuid': headlineTestUuid,
62+
})}
5763
aria-label={headlineText}
5864
/>
5965
);
@@ -64,11 +70,13 @@ const ExternalLink = ({
6470
headlineText,
6571
dataLinkName,
6672
shouldRaiseZIndexForAbTest,
73+
headlineTestUuid,
6774
}: {
6875
linkTo: string;
6976
headlineText: string;
7077
dataLinkName?: string;
7178
shouldRaiseZIndexForAbTest: boolean;
79+
headlineTestUuid?: string;
7280
}) => {
7381
return (
7482
<a
@@ -78,6 +86,9 @@ const ExternalLink = ({
7886
shouldRaiseZIndexForAbTest ? abTestZIndexStyles : zIndexStyles,
7987
]}
8088
data-link-name={dataLinkName}
89+
{...(headlineTestUuid != undefined && {
90+
'data-fronts-test-uuid': headlineTestUuid,
91+
})}
8192
aria-label={headlineText + ' (opens in new tab)'}
8293
target="_blank"
8394
rel="noreferrer"
@@ -92,6 +103,7 @@ export const CardLink = ({
92103
isExternalLink,
93104
isLoopAndInLoopClickTest,
94105
shouldRaiseZIndexForAbTest,
106+
headlineTestUuid,
95107
}: Props) => {
96108
/**
97109
* 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 = ({
109121
headlineText={headlineText}
110122
dataLinkName={clickThroughLinkName}
111123
shouldRaiseZIndexForAbTest={shouldRaiseZIndexForAbTest}
124+
headlineTestUuid={headlineTestUuid}
112125
/>
113126
)}
114127
{!isExternalLink && (
@@ -117,6 +130,7 @@ export const CardLink = ({
117130
headlineText={headlineText}
118131
dataLinkName={clickThroughLinkName}
119132
shouldRaiseZIndexForAbTest={shouldRaiseZIndexForAbTest}
133+
headlineTestUuid={headlineTestUuid}
120134
/>
121135
)}
122136
</>

dotcom-rendering/src/components/FeatureCard.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@ export type Props = {
407407
*/
408408
isImmersive?: boolean;
409409
starRatingSize: RatingSizeType;
410+
headlineTestUuid?: string;
410411
};
411412

412413
export const FeatureCard = ({
@@ -445,6 +446,7 @@ export const FeatureCard = ({
445446
isImmersive = false,
446447
starRatingSize,
447448
articleMedia,
449+
headlineTestUuid,
448450
}: Props) => {
449451
const ab = useAB();
450452
const isInLoopClickTestControl = Boolean(
@@ -546,6 +548,7 @@ export const FeatureCard = ({
546548
shouldRaiseZIndexForAbTest={
547549
isLoopAndInLoopClickTestVariant
548550
}
551+
headlineTestUuid={headlineTestUuid}
549552
/>
550553
)}
551554
<div css={contentStyles}>
@@ -769,6 +772,9 @@ export const FeatureCard = ({
769772
shouldRaiseZIndexForAbTest={
770773
isLoopAndInLoopClickTestVariant
771774
}
775+
headlineTestUuid={
776+
headlineTestUuid
777+
}
772778
/>
773779
)}
774780

dotcom-rendering/src/components/FlexibleGeneral.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ const ImmersiveCardLayout = ({
141141
isImmersive={true}
142142
starRatingSize="medium"
143143
articleMedia={card.articleMedia}
144+
headlineTestUuid={card.headlineTestUuid}
144145
/>
145146
</LI>
146147
</UL>

dotcom-rendering/src/components/FrontCard.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export const FrontCard = (props: Props) => {
5959
starRating: trail.starRating,
6060
uniqueId: trail.uniqueId,
6161
webPublicationDate: trail.webPublicationDate,
62+
headlineTestUuid: trail.headlineTestUuid,
6263
};
6364

6465
return Card({ ...defaultProps, ...cardProps });

dotcom-rendering/src/components/Masthead/HighlightsCard.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export type HighlightsCardProps = {
3737
byline?: string;
3838
isExternalLink: boolean;
3939
starRating?: Rating;
40+
headlineTestUuid?: string;
4041
};
4142

4243
const container = css`
@@ -135,6 +136,7 @@ export const HighlightsCard = ({
135136
isExternalLink,
136137
starRating,
137138
articleMedia,
139+
headlineTestUuid,
138140
}: HighlightsCardProps) => {
139141
const isMediaCard = isMedia(format);
140142

@@ -154,6 +156,7 @@ export const HighlightsCard = ({
154156
isExternalLink={isExternalLink}
155157
isLoopAndInLoopClickTest={false}
156158
shouldRaiseZIndexForAbTest={false}
159+
headlineTestUuid={headlineTestUuid}
157160
/>
158161

159162
<div css={[content, shouldJustifyContent && spaceBetween]}>

dotcom-rendering/src/components/ScrollableFeature.island.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ export const ScrollableFeature = ({
9191
showQuotes={card.showQuotedHeadline}
9292
starRatingSize={'small'}
9393
articleMedia={card.articleMedia}
94+
headlineTestUuid={card.headlineTestUuid}
9495
/>
9596
</ScrollableCarousel.Item>
9697
))}

dotcom-rendering/src/components/StaticFeatureTwo.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ export const StaticFeatureTwo = ({
8080
showQuotes={card.showQuotedHeadline}
8181
starRatingSize={'medium'}
8282
articleMedia={card.articleMedia}
83+
headlineTestUuid={card.headlineTestUuid}
8384
/>
8485
</LI>
8586
);

dotcom-rendering/src/components/SupportingContent.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,9 @@ export const SupportingContent = ({
186186
: verticalSublinkStyles,
187187
]}
188188
data-link-name={`sublinks | ${index + 1}`}
189+
{...(subLink.headlineTestUuid != undefined && {
190+
'data-fronts-test-uuid': subLink.headlineTestUuid,
191+
})}
189192
>
190193
<FormatBoundary format={subLinkFormat}>
191194
<ContainerOverrides

dotcom-rendering/src/model/enhanceCards.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ const enhanceSupportingContent = (
6262
url: decideUrl(subLink),
6363
kickerText:
6464
!kickerText && supportingContentIsLive ? 'Live' : kickerText,
65+
// headlineTestUuid: findHeadlineTestUuid(
66+
// subLink,
67+
// serverSideABTests,
68+
// isEditorialABTestingEnabled,
69+
// pageId,
70+
// ),
6571
};
6672
});
6773
};
@@ -254,6 +260,38 @@ export const decideHeadline = (
254260
return variantMeta.meta.headline;
255261
};
256262

263+
/**
264+
* Find the UUID of a headline test if one is running on the card
265+
*/
266+
export const findHeadlineTestUuid = (
267+
faciaCard: FEFrontCard,
268+
serverSideABTests: Record<string, string>,
269+
isEditorialABTestingEnabled: boolean,
270+
pageId?: string,
271+
): string | undefined => {
272+
const testBucket = serverSideABTests['fronts-and-curation-editorial-test'];
273+
274+
const activeEditorialTest = findActiveEditorialTest(
275+
faciaCard.properties.tests,
276+
);
277+
278+
if (
279+
!isEditorialABTestingEnabled ||
280+
isUndefined(testBucket) ||
281+
!activeEditorialTest
282+
) {
283+
return undefined;
284+
}
285+
286+
const testCanRunOnPage =
287+
!isUndefined(pageId) &&
288+
activeEditorialTest.frontsThisTestCanRunOn.includes(pageId);
289+
290+
if (!testCanRunOnPage) return undefined;
291+
292+
return activeEditorialTest.testUuid;
293+
};
294+
257295
/**
258296
* While the first Media Atom is *not* guaranteed to be the main media,
259297
* it *happens to be* correct in the majority of cases.
@@ -596,5 +634,11 @@ export const enhanceCards = (
596634
?.allImages[0]?.fields.altText ?? '',
597635
},
598636
}),
637+
headlineTestUuid: findHeadlineTestUuid(
638+
faciaCard,
639+
serverSideABTests,
640+
isEditorialABTestingEnabled,
641+
pageId,
642+
),
599643
};
600644
});

0 commit comments

Comments
 (0)