diff --git a/dotcom-rendering/src/components/DecideFrontsAdSlots.tsx b/dotcom-rendering/src/components/DecideFrontsAdSlots.tsx index 74d5c8e2c8..87ac95e909 100644 --- a/dotcom-rendering/src/components/DecideFrontsAdSlots.tsx +++ b/dotcom-rendering/src/components/DecideFrontsAdSlots.tsx @@ -31,6 +31,7 @@ export const decideMerchHighAndMobileAdSlots = ( return (
+ {index}
+ {index} [] = [ - ...Array(12), -].map(() => ({ - collectionType: 'fixed/large/slow-XIV', -})); +const defaultTestCollections: AdCandidate[] = [...Array(12)].map( + () => ({ collectionType: 'fixed/large/slow-XIV' }), +); describe('Mobile Ads', () => { it(`Should not insert ad after container if it's the first one and it's a thrasher`, () => { - const testCollections = [...defaultTestCollections]; - testCollections.unshift({ collectionType: 'fixed/thrasher' }); + const testCollections = [ + { collectionType: 'fixed/thrasher' }, + ...defaultTestCollections, + ] satisfies AdCandidate[]; const mobileAdPositions = getMobileAdPositions(testCollections); @@ -223,6 +224,82 @@ describe('Mobile Ads', () => { expect(mobileAdPositions).toEqual([1, 4, 6, 8, 10, 12]); }); + + it('Europe Network Front, with beta containers and more than 4 collections, with thrashers in various places', () => { + const testCollections: AdCandidate[] = [ + { collectionType: 'flexible/general', containerLevel: 'Primary' }, // Ad position 0 + { collectionType: 'scrollable/small', containerLevel: 'Secondary' }, + { collectionType: 'scrollable/small', containerLevel: 'Secondary' }, + { + collectionType: 'scrollable/medium', + containerLevel: 'Secondary', + }, + { + collectionType: 'scrollable/feature', + containerLevel: 'Secondary', + }, // Ad position 4 + { collectionType: 'static/feature/2', containerLevel: 'Primary' }, + { + collectionType: 'scrollable/medium', + containerLevel: 'Secondary', + }, // Ad position 6 + { collectionType: 'flexible/special', containerLevel: 'Primary' }, + { collectionType: 'fixed/thrasher' }, // Ad position 8 + { collectionType: 'flexible/general', containerLevel: 'Primary' }, + { collectionType: 'scrollable/small', containerLevel: 'Secondary' }, // Ad position 10 + { collectionType: 'static/feature/2', containerLevel: 'Primary' }, + { collectionType: 'scrollable/small', containerLevel: 'Secondary' }, + { collectionType: 'scrollable/small', containerLevel: 'Secondary' }, + { collectionType: 'scrollable/small', containerLevel: 'Secondary' }, // Ad position 14 + { collectionType: 'static/feature/2', containerLevel: 'Primary' }, + { + collectionType: 'scrollable/medium', + containerLevel: 'Secondary', + }, + { + collectionType: 'scrollable/medium', + containerLevel: 'Secondary', + }, + { collectionType: 'scrollable/small', containerLevel: 'Secondary' }, + { collectionType: 'fixed/thrasher' }, // Ad position 19 + { collectionType: 'static/feature/2', containerLevel: 'Primary' }, + { + collectionType: 'scrollable/medium', + containerLevel: 'Secondary', + }, + { collectionType: 'scrollable/small', containerLevel: 'Secondary' }, + { collectionType: 'scrollable/small', containerLevel: 'Secondary' }, + { + collectionType: 'scrollable/medium', + containerLevel: 'Secondary', + }, + { + collectionType: 'scrollable/medium', + containerLevel: 'Secondary', + }, + { collectionType: 'scrollable/small', containerLevel: 'Secondary' }, + { + collectionType: 'scrollable/medium', + containerLevel: 'Secondary', + }, // Ad position 27 + { collectionType: 'flexible/general', containerLevel: 'Primary' }, + { + collectionType: 'scrollable/medium', + containerLevel: 'Secondary', + }, + { collectionType: 'scrollable/small', containerLevel: 'Secondary' }, // Ad position 30 + { collectionType: 'flexible/general', containerLevel: 'Primary' }, + { + collectionType: 'scrollable/feature', + containerLevel: 'Secondary', + }, + { collectionType: 'news/most-popular' }, + ]; + + const mobileAdPositions = getMobileAdPositions(testCollections); + + expect(mobileAdPositions).toEqual([0, 4, 6, 8, 10, 14, 19, 27, 30, 32]); + }); }); describe('Standard fronts fronts-banner ad slots', () => {