Skip to content

Commit 988dea3

Browse files
authored
Merge branch 'main' into dina/top-bar-component-hosted-content
2 parents b5d2704 + 374931a commit 988dea3

3 files changed

Lines changed: 50 additions & 2 deletions

File tree

dotcom-rendering/src/model/enhance-product-summary.test.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ describe('enhanceProductSummary', () => {
223223
const output = enhanceProductSummary({
224224
pageId: allowedPageId,
225225
serverSideABTests: { 'thefilter-at-a-glance-redesign': 'carousel' },
226+
renderingTarget: 'Web',
226227
})(input);
227228

228229
const carousel = findCarousel(output);
@@ -263,10 +264,52 @@ describe('enhanceProductSummary', () => {
263264
const output = enhanceProductSummary({
264265
pageId: allowedPageId,
265266
serverSideABTests: { 'thefilter-at-a-glance-redesign': 'stacked' },
267+
renderingTarget: 'Web',
266268
})(input);
267269

268270
const stacked = findStacked(output);
269271

270272
expect(stacked).toBeDefined();
271273
});
274+
275+
it('does not return stacked cards when the rendering target is apps', () => {
276+
const allowedPageId =
277+
'thefilter/test-article-example-for-product-summary';
278+
279+
const input = [
280+
atAGlanceHeading(),
281+
linkElement(
282+
'https://www.homebase.co.uk/en-uk/tower-airx-t17166-5l-grey-single-basket-air-fryer-digital-air-fryer/p/0757395',
283+
'Buy now',
284+
),
285+
linkElement(
286+
'https://www.lakeland.co.uk/27537/lakeland-slimline-air-fryer-black-8l',
287+
'Buy now',
288+
),
289+
linkElement(
290+
'https://ninjakitchen.co.uk/product/ninja-double-stack-xl-9-5l-air-fryer-sl400uk-zidSL400UK',
291+
'Buy now',
292+
),
293+
dividerElement(),
294+
productElement([
295+
'https://www.homebase.co.uk/en-uk/tower-airx-t17166-5l-grey-single-basket-air-fryer-digital-air-fryer/p/0757395',
296+
]),
297+
productElement([
298+
'https://www.lakeland.co.uk/27537/lakeland-slimline-air-fryer-black-8l',
299+
]),
300+
productElement([
301+
'https://ninjakitchen.co.uk/product/ninja-double-stack-xl-9-5l-air-fryer-sl400uk-zidSL400UK',
302+
]),
303+
];
304+
305+
const output = enhanceProductSummary({
306+
pageId: allowedPageId,
307+
serverSideABTests: { 'thefilter-at-a-glance-redesign': 'stacked' },
308+
renderingTarget: 'Apps',
309+
})(input);
310+
311+
const stacked = findStacked(output);
312+
313+
expect(stacked).toBeUndefined();
314+
});
272315
});

dotcom-rendering/src/model/enhance-product-summary.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { FEElement, ProductBlockElement } from '../types/content';
2+
import type { RenderingTarget } from '../types/renderingTarget';
23
import { generateId } from './enhance-H2s';
34

45
/**
@@ -156,19 +157,22 @@ export const enhanceProductSummary =
156157
({
157158
pageId,
158159
serverSideABTests,
160+
renderingTarget,
159161
}: {
160162
pageId: string;
161163
serverSideABTests?: Record<string, string>;
164+
renderingTarget: RenderingTarget;
162165
}) =>
163166
(elements: FEElement[]): FEElement[] => {
164167
const abTestVariant =
165168
serverSideABTests?.['thefilter-at-a-glance-redesign'];
166169

167-
// do nothing if article is not on allow list / not in the test / variant is 'control'
170+
// do nothing if article is not on allow list / not in the test / variant is 'control' / renderingTarget is Apps
168171
if (
169172
abTestVariant &&
170173
isCarouselOrStacked(abTestVariant) &&
171-
isEligibleForSummary(pageId)
174+
isEligibleForSummary(pageId) &&
175+
renderingTarget === 'Web'
172176
) {
173177
return insertSummaryPlaceholder(elements, abTestVariant);
174178
}

dotcom-rendering/src/model/enhanceBlocks.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ export const enhanceElements =
100100
enhanceProductSummary({
101101
pageId: options.pageId,
102102
serverSideABTests: options.serverSideABTests,
103+
renderingTarget: options.renderingTarget,
103104
}),
104105
].reduce(
105106
(enhancedBlocks, enhancer) => enhancer(enhancedBlocks),

0 commit comments

Comments
 (0)