Skip to content

Commit daf7cc2

Browse files
committed
Create AllBoosts AB test
1 parent efd76d4 commit daf7cc2

File tree

4 files changed

+65
-28
lines changed

4 files changed

+65
-28
lines changed

dotcom-rendering/src/components/DecideContainer.tsx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ type Props = {
4646
sectionId: string;
4747
frontId?: string;
4848
collectionId: number;
49+
isInAllBoostsTest?: boolean;
4950
containerLevel?: DCRContainerLevel;
5051
isInHideTrailsAbTest?: boolean;
5152
};
@@ -62,9 +63,38 @@ export const DecideContainer = ({
6263
sectionId,
6364
frontId,
6465
collectionId,
66+
isInAllBoostsTest,
6567
containerLevel,
6668
isInHideTrailsAbTest,
6769
}: Props) => {
70+
if (isInAllBoostsTest) {
71+
return (
72+
<FlexibleGeneral
73+
groupedTrails={
74+
containerType === 'flexible/general' ||
75+
containerType === 'flexible/special'
76+
? groupedTrails
77+
: {
78+
snap: [],
79+
huge: [],
80+
veryBig: [],
81+
big: [],
82+
splash: [],
83+
standard: trails,
84+
}
85+
}
86+
absoluteServerTimes={absoluteServerTimes}
87+
aspectRatio={aspectRatio}
88+
collectionId={collectionId}
89+
containerLevel={containerLevel}
90+
containerPalette={containerPalette}
91+
imageLoading={imageLoading}
92+
isInHideTrailsAbTest={!!isInHideTrailsAbTest}
93+
showAge={showAge}
94+
/>
95+
);
96+
}
97+
6898
switch (containerType) {
6999
case 'dynamic/fast':
70100
return (

dotcom-rendering/src/components/FlexibleGeneral.test.tsx

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,24 @@ const boostedCard = {
1414

1515
describe('FlexibleGeneral', () => {
1616
it('Should return a one card half width row layout if one standard card is provided', () => {
17-
expect(decideCardPositions([standardCard])).toEqual([
17+
expect(decideCardPositions([standardCard], false)).toEqual([
1818
{
1919
layout: 'oneCardHalfWidth',
2020
cards: [standardCard],
2121
},
2222
]);
2323
});
2424
it('Should return a one card full width row layout if one boosted card is provided', () => {
25-
expect(decideCardPositions([boostedCard])).toEqual([
25+
expect(decideCardPositions([boostedCard], false)).toEqual([
2626
{ layout: 'oneCardFullWidth', cards: [boostedCard] },
2727
]);
2828
});
2929
it('Should return a one card full width row layout if one immersive card is provided', () => {
3030
expect(
31-
decideCardPositions([{ ...standardCard, isImmersive: true }]),
31+
decideCardPositions(
32+
[{ ...standardCard, isImmersive: true }],
33+
false,
34+
),
3235
).toEqual([
3336
{
3437
layout: 'oneCardFullWidth',
@@ -37,17 +40,17 @@ describe('FlexibleGeneral', () => {
3740
]);
3841
});
3942
it('Should return a two card row layout if two standard cards are provided', () => {
40-
expect(decideCardPositions([standardCard, standardCard])).toEqual([
41-
{ layout: 'twoCard', cards: [standardCard, standardCard] },
42-
]);
43+
expect(
44+
decideCardPositions([standardCard, standardCard], false),
45+
).toEqual([{ layout: 'twoCard', cards: [standardCard, standardCard] }]);
4346
});
4447

4548
it('Should return a one card half width row layout if one card without boost level is provided', () => {
4649
const cardWithoutBoostLevel = {
4750
...standardCard,
4851
boostLevel: undefined,
4952
};
50-
expect(decideCardPositions([cardWithoutBoostLevel])).toEqual([
53+
expect(decideCardPositions([cardWithoutBoostLevel], false)).toEqual([
5154
{
5255
layout: 'oneCardHalfWidth',
5356
cards: [cardWithoutBoostLevel],
@@ -57,12 +60,10 @@ describe('FlexibleGeneral', () => {
5760

5861
it('Should return two rows of two card row layouts if four standard cards are provided', () => {
5962
expect(
60-
decideCardPositions([
61-
standardCard,
62-
standardCard,
63-
standardCard,
64-
standardCard,
65-
]),
63+
decideCardPositions(
64+
[standardCard, standardCard, standardCard, standardCard],
65+
false,
66+
),
6667
).toEqual([
6768
{ layout: 'twoCard', cards: [standardCard, standardCard] },
6869
{ layout: 'twoCard', cards: [standardCard, standardCard] },
@@ -71,12 +72,10 @@ describe('FlexibleGeneral', () => {
7172

7273
it('Should return three rows of expected row layouts if a boosted card and three standard cards are provided', () => {
7374
expect(
74-
decideCardPositions([
75-
boostedCard,
76-
standardCard,
77-
standardCard,
78-
standardCard,
79-
]),
75+
decideCardPositions(
76+
[boostedCard, standardCard, standardCard, standardCard],
77+
false,
78+
),
8079
).toEqual([
8180
{ layout: 'oneCardFullWidth', cards: [boostedCard] },
8281
{ layout: 'twoCard', cards: [standardCard, standardCard] },
@@ -86,12 +85,10 @@ describe('FlexibleGeneral', () => {
8685

8786
it('Should return three rows of expected row layouts if a standard, then boosted card and two standard cards are provided', () => {
8887
expect(
89-
decideCardPositions([
90-
standardCard,
91-
boostedCard,
92-
standardCard,
93-
standardCard,
94-
]),
88+
decideCardPositions(
89+
[standardCard, boostedCard, standardCard, standardCard],
90+
false,
91+
),
9592
).toEqual([
9693
{ layout: 'oneCardHalfWidth', cards: [standardCard] },
9794
{ layout: 'oneCardFullWidth', cards: [boostedCard] },

dotcom-rendering/src/components/FlexibleGeneral.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ type Props = {
3333
containerLevel?: DCRContainerLevel;
3434
collectionId: number;
3535
isInHideTrailsAbTest?: boolean;
36+
isInAllBoostsTest?: boolean;
3637
};
3738

3839
type RowLayout = 'oneCardHalfWidth' | 'oneCardFullWidth' | 'twoCard';
@@ -43,7 +44,10 @@ type GroupedRow = {
4344
};
4445
type GroupedCards = GroupedRow[];
4546

46-
export const decideCardPositions = (cards: DCRFrontCard[]): GroupedCards => {
47+
export const decideCardPositions = (
48+
cards: DCRFrontCard[],
49+
isInAllBoostsTest: boolean,
50+
): GroupedCards => {
4751
const createNewRow = (
4852
layout: RowLayout,
4953
card: DCRFrontCard,
@@ -61,7 +65,8 @@ export const decideCardPositions = (cards: DCRFrontCard[]): GroupedCards => {
6165
// Early return if the card is boosted or immersive since it takes up a whole row
6266
if (
6367
card.isImmersive ||
64-
(card.boostLevel && card.boostLevel !== 'default')
68+
!!(card.boostLevel && card.boostLevel !== 'default') ||
69+
isInAllBoostsTest
6570
) {
6671
return [...acc, createNewRow('oneCardFullWidth', card)];
6772
}
@@ -595,6 +600,7 @@ export const FlexibleGeneral = ({
595600
imageLoading,
596601
aspectRatio,
597602
containerLevel = 'Primary',
603+
isInAllBoostsTest = false,
598604
collectionId,
599605
isInHideTrailsAbTest,
600606
}: Props) => {
@@ -610,7 +616,7 @@ export const FlexibleGeneral = ({
610616
uniqueId: `collection-${collectionId}-standard-${i}`,
611617
}));
612618

613-
const groupedCards = decideCardPositions(cards);
619+
const groupedCards = decideCardPositions(cards, isInAllBoostsTest);
614620

615621
return (
616622
<>

dotcom-rendering/src/layouts/FrontLayout.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,10 @@ export const FrontLayout = ({ front, NAV }: Props) => {
590590
}
591591
sectionId={ophanName}
592592
collectionId={index + 1}
593+
isInAllBoostsTest={
594+
front.isNetworkFront &&
595+
abTests.allBoostsVariant === 'variant'
596+
}
593597
containerLevel={collection.containerLevel}
594598
isInHideTrailsAbTest={
595599
front.isNetworkFront &&

0 commit comments

Comments
 (0)