Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add decideAdSlot to fronts fixed/video container #8112

Merged
merged 2 commits into from
Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 54 additions & 41 deletions dotcom-rendering/src/layouts/FrontLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -454,47 +454,60 @@ export const FrontLayout = ({ front, NAV }: Props) => {
const containerOverrides =
decideContainerOverrides(containerPalette);
return (
<Section
key={ophanName}
title={collection.displayName}
sectionId={`container-${ophanName}`}
ophanComponentName={ophanName}
ophanComponentLink={ophanComponentLink}
containerName={collection.collectionType}
fullWidth={true}
padBottom={true}
showSideBorders={
collection.collectionType !== 'fixed/video'
}
showTopBorder={index > 0}
padContent={false}
url={collection.href}
containerPalette={containerPalette}
showDateHeader={
collection.config.showDateHeader
}
editionId={front.editionId}
backgroundColour={
containerOverrides.background.containerOuter
}
innerBackgroundColour={
containerOverrides.background.container
}
hasPageSkin={hasPageSkin}
>
<Island deferUntil={'visible'}>
<Carousel
heading={collection.displayName}
trails={trails}
onwardsSource={'unknown-source'}
palette={containerPalette}
leftColSize={'compact'}
collectionType={
collection.collectionType
}
/>
</Island>
</Section>
<Fragment key={ophanName}>
<Section
title={collection.displayName}
sectionId={`container-${ophanName}`}
ophanComponentName={ophanName}
ophanComponentLink={ophanComponentLink}
containerName={collection.collectionType}
fullWidth={true}
padBottom={true}
showSideBorders={
collection.collectionType !==
'fixed/video'
}
showTopBorder={index > 0}
padContent={false}
url={collection.href}
containerPalette={containerPalette}
showDateHeader={
collection.config.showDateHeader
}
editionId={front.editionId}
backgroundColour={
containerOverrides.background
.containerOuter
}
innerBackgroundColour={
containerOverrides.background.container
}
hasPageSkin={hasPageSkin}
>
<Island deferUntil={'visible'}>
<Carousel
heading={collection.displayName}
trails={trails}
onwardsSource={'unknown-source'}
palette={containerPalette}
leftColSize={'compact'}
collectionType={
collection.collectionType
}
/>
</Island>
</Section>
{decideAdSlot(
renderAds,
index,
front.isNetworkFront,
front.pressedPage.collections.length,
front.pressedPage.frontProperties
.isPaidContent,
mobileAdPositions,
hasPageSkin,
)}
</Fragment>
);
}

Expand Down
34 changes: 34 additions & 0 deletions dotcom-rendering/src/lib/getAdPositions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,40 @@ describe('Mobile Ads', () => {
expect(mobileAdPositions).toEqual([0, 2, 6, 9, 12, 16, 18, 20, 22]);
});

// We used https://www.theguardian.com/international as a blueprint
it('International Network Front, with more than 4 collections, with thrashers at various places', () => {
const merchHighPosition = 3;
const testCollections: Pick<DCRCollectionType, 'collectionType'>[] = [
{ collectionType: 'dynamic/fast' }, // 0 headlines (top-above-nav)
{ collectionType: 'fixed/small/slow-IV' }, // 1 ukraine
{ collectionType: 'dynamic/slow' }, // 2 spotlight (m1)
{ collectionType: 'dynamic/slow-mpu' }, // 3 opinion (merch-high)
{ collectionType: 'dynamic/slow' }, // 4 sport
{ collectionType: 'fixed/thrasher' }, // 5 wordiply
{ collectionType: 'fixed/small/slow-IV' }, // 6 europe (mobile-2)
{ collectionType: 'dynamic/fast' }, // 7 world
{ collectionType: 'fixed/small/slow-IV' }, // 8 climate
{ collectionType: 'fixed/thrasher' }, // 9 tip us off (mobile-3)
{ collectionType: 'dynamic/slow-mpu' }, // 10 culture
{ collectionType: 'fixed/thrasher' }, // 11 cotton capital
{ collectionType: 'dynamic/slow-mpu' }, // 12 lifestyle
{ collectionType: 'fixed/thrasher' }, // 13 documentaries (mobile-4)
{ collectionType: 'dynamic/slow-mpu' }, // 14 explore
{ collectionType: 'fixed/small/slow-IV' }, // 15 take part (mobile-5)
{ collectionType: 'fixed/small/slow-IV' }, // 16 podcasts
{ collectionType: 'fixed/video' }, // 17 videos (mobile-6)
{ collectionType: 'fixed/medium/slow-VI' }, // 18 in pictures
{ collectionType: 'news/most-popular' }, // 19 most popular
];

const mobileAdPositions = getMobileAdPositions(
testCollections,
merchHighPosition,
);

expect(mobileAdPositions).toEqual([0, 2, 6, 9, 13, 15, 17]);
});

// We used https://www.theguardian.com/us as a blueprint
it('US Network Front, with more than 4 collections, with thrashers at various places', () => {
const merchHighPosition = 3;
Expand Down