Skip to content

Commit 0bc1728

Browse files
Merge branch 'main' into gallery-onwards-upper
2 parents 0d8c1cc + 7f3fdd5 commit 0bc1728

34 files changed

+567
-223
lines changed

dotcom-rendering/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@
129129
"eslint-plugin-ssr-friendly": "1.3.0",
130130
"eslint-plugin-unicorn": "48.0.1",
131131
"eslint-stats": "1.0.1",
132-
"execa": "5.1.1",
133132
"express": "5.1.0",
134133
"find": "0.3.0",
135134
"he": "1.2.0",
Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
1-
const execa = require('execa');
1+
const { execFileSync } = require('node:child_process');
22
const { warn } = require('../../../scripts/log');
33

4-
execa('find', ['src', '-type', 'f', '-name', '*index*.ts*'])
5-
.then(({ stdout }) => {
6-
if (stdout !== '') {
7-
warn(
8-
'The following files contain “index” in them and should be renamed:\n\n' +
9-
stdout +
10-
'\n',
11-
);
12-
process.exit(1);
13-
}
14-
})
15-
.catch(() => {
4+
try {
5+
const stdout = execFileSync(
6+
'find',
7+
['src', '-type', 'f', '-name', '*index*.ts*'],
8+
{
9+
encoding: 'utf8',
10+
},
11+
);
12+
if (stdout !== '') {
13+
warn(
14+
'The following files contain "index" in them and should be renamed:\n\n' +
15+
stdout +
16+
'\n',
17+
);
1618
process.exit(1);
17-
});
19+
}
20+
} catch (error) {
21+
console.log('Error finding index files', error);
22+
process.exit(1);
23+
}

dotcom-rendering/scripts/jest/setup.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,6 @@ const windowGuardian = {
4848
functions: {
4949
import: (url: string) => import(url),
5050
},
51-
automat: {
52-
react: undefined,
53-
preact: undefined,
54-
emotion: undefined,
55-
emotionCore: undefined,
56-
emotionTheming: undefined,
57-
},
5851
readerRevenue: {
5952
changeGeolocation: () => {},
6053
showMeTheEpic: () => {},

dotcom-rendering/scripts/test-data/gen-fixtures.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/* eslint-disable no-console -- script */
22
/* eslint-disable @typescript-eslint/unbound-method -- path.resolve */
33

4+
const { execFileSync } = require('node:child_process');
45
const fs = require('node:fs/promises');
56
const { resolve } = require('node:path');
6-
const execa = require('execa');
77
const { config } = require('../../fixtures/config');
88
const { configOverrides } = require('../../fixtures/config-overrides');
99
const { switchOverrides } = require('../../fixtures/switch-overrides');
@@ -304,7 +304,7 @@ requests.push(
304304
// Write the new fixture data
305305
const contents = `${HEADER}
306306
import type { FEStoryPackage } from '../../src/frontend/feArticle';
307-
307+
308308
export const storyPackage: FEStoryPackage = ${JSON.stringify(json, null, 4)}`;
309309
return fs.writeFile(
310310
`${root}/fixtures/generated/story-package.ts`,
@@ -427,19 +427,19 @@ Promise.allSettled(requests)
427427
}
428428

429429
console.log('Generation complete, formatting successful fixtures...');
430-
execa('prettier', [
431-
'./fixtures/**/*',
432-
'--write',
433-
'--log-level',
434-
'error',
435-
])
436-
.then(() => {
437-
console.log('✅ Formatting complete.');
438-
})
439-
.catch((err) => {
440-
console.error('\n❌ Failed to format fixtures:\n', err);
441-
process.exitCode = 1;
442-
});
430+
431+
try {
432+
execFileSync('prettier', [
433+
'./fixtures/**/*',
434+
'--write',
435+
'--log-level',
436+
'error',
437+
]);
438+
console.log('✅ Formatting complete.');
439+
} catch (err) {
440+
console.error('\n❌ Failed to format fixtures:\n', err);
441+
process.exitCode = 1;
442+
}
443443
})
444444
.catch((err) => {
445445
console.error('❌ Unexpected error occurred:\n', err);

dotcom-rendering/src/client/userFeatures/user-features.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,10 @@ const persistResponse = (userBenefitsResponse: UserBenefits) => {
5353
if (userBenefitsResponse.allowRejectAll) {
5454
createOrRenewCookie(ALLOW_REJECT_ALL_COOKIE);
5555
}
56+
// Ad free cookie has an expiry of 2 days from now
57+
// See https://github.com/guardian/gateway/blob/52f810a88fa9ce23c6a794916251748718742c3d/src/server/lib/user-features.ts#L111-L115
5658
if (userBenefitsResponse.adFree) {
57-
createOrRenewCookie(AD_FREE_USER_COOKIE);
59+
createOrRenewCookie(AD_FREE_USER_COOKIE, 2);
5860
}
5961
};
6062

dotcom-rendering/src/components/ArticlePage.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { useConfig } from './ConfigContext';
1414
import { DarkModeMessage } from './DarkModeMessage';
1515
import { EnhanceAffiliateLinks } from './EnhanceAffiliateLinks.importable';
1616
import { FocusStyles } from './FocusStyles.importable';
17+
import { GoogleOneTap, isGoogleOneTapEnabled } from './GoogleOneTap.importable';
1718
import { Island } from './Island';
1819
import { Lightbox } from './Lightbox';
1920
import { Metrics } from './Metrics.importable';
@@ -139,6 +140,17 @@ export const ArticlePage = (props: WebProps | AppProps) => {
139140
}
140141
/>
141142
</Island>
143+
{isGoogleOneTapEnabled(
144+
frontendData.config.abTests,
145+
frontendData.config.switches,
146+
) && (
147+
<Island
148+
priority="enhancement"
149+
defer={{ until: 'idle' }}
150+
>
151+
<GoogleOneTap />
152+
</Island>
153+
)}
142154
</>
143155
)}
144156
{renderingTarget === 'Web' ? (

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

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ export type Props = {
153153
showKickerImage?: boolean;
154154
/** Determines if the headline should be positioned within the content or outside the content */
155155
headlinePosition?: 'inner' | 'outer';
156+
isInHideTrailsAbTest?: boolean;
156157
};
157158

158159
const starWrapper = (cardHasImage: boolean) => css`
@@ -390,6 +391,7 @@ export const Card = ({
390391
trailTextSize,
391392
showKickerImage = false,
392393
headlinePosition = 'inner',
394+
isInHideTrailsAbTest = false,
393395
}: Props) => {
394396
const hasSublinks = supportingContent && supportingContent.length > 0;
395397
const sublinkPosition = decideSublinkPosition(
@@ -1090,14 +1092,16 @@ export const Card = ({
10901092
</HeadlineWrapper>
10911093
)}
10921094

1093-
{!!trailText && media?.type !== 'podcast' && (
1094-
<TrailText
1095-
trailText={trailText}
1096-
trailTextSize={trailTextSize}
1097-
padTop={headlinePosition === 'inner'}
1098-
hideUntil={hideTrailTextUntil()}
1099-
/>
1100-
)}
1095+
{!!trailText &&
1096+
media?.type !== 'podcast' &&
1097+
!isInHideTrailsAbTest && (
1098+
<TrailText
1099+
trailText={trailText}
1100+
trailTextSize={trailTextSize}
1101+
padTop={headlinePosition === 'inner'}
1102+
hideUntil={hideTrailTextUntil()}
1103+
/>
1104+
)}
11011105

11021106
{!isOpinionCardWithAvatar && (
11031107
<>

dotcom-rendering/src/components/DecideContainer.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ type Props = {
4747
frontId?: string;
4848
collectionId: number;
4949
containerLevel?: DCRContainerLevel;
50-
isInOpinionNoAvatarVariant?: boolean;
50+
isInHideTrailsAbTest?: boolean;
5151
};
5252

5353
export const DecideContainer = ({
@@ -63,7 +63,7 @@ export const DecideContainer = ({
6363
frontId,
6464
collectionId,
6565
containerLevel,
66-
isInOpinionNoAvatarVariant,
66+
isInHideTrailsAbTest,
6767
}: Props) => {
6868
switch (containerType) {
6969
case 'dynamic/fast':
@@ -246,6 +246,7 @@ export const DecideContainer = ({
246246
imageLoading={imageLoading}
247247
aspectRatio={aspectRatio}
248248
collectionId={collectionId}
249+
isInHideTrailsAbTest={!!isInHideTrailsAbTest}
249250
/>
250251
);
251252
case 'flexible/general':
@@ -259,7 +260,7 @@ export const DecideContainer = ({
259260
aspectRatio={aspectRatio}
260261
containerLevel={containerLevel}
261262
collectionId={collectionId}
262-
isInOpinionNoAvatarVariant={isInOpinionNoAvatarVariant}
263+
isInHideTrailsAbTest={!!isInHideTrailsAbTest}
263264
/>
264265
);
265266
case 'scrollable/small':
@@ -274,6 +275,7 @@ export const DecideContainer = ({
274275
absoluteServerTimes={absoluteServerTimes}
275276
aspectRatio={aspectRatio}
276277
sectionId={sectionId}
278+
isInHideTrailsAbTest={!!isInHideTrailsAbTest}
277279
/>
278280
</Island>
279281
);
@@ -289,7 +291,7 @@ export const DecideContainer = ({
289291
absoluteServerTimes={absoluteServerTimes}
290292
aspectRatio={aspectRatio}
291293
sectionId={sectionId}
292-
isInOpinionNoAvatarVariant={isInOpinionNoAvatarVariant}
294+
isInHideTrailsAbTest={!!isInHideTrailsAbTest}
293295
/>
294296
</Island>
295297
);
@@ -302,6 +304,7 @@ export const DecideContainer = ({
302304
absoluteServerTimes={absoluteServerTimes}
303305
imageLoading={imageLoading}
304306
aspectRatio={aspectRatio}
307+
isInHideTrailsAbTest={!!isInHideTrailsAbTest}
305308
/>
306309
);
307310
case 'scrollable/feature':
@@ -314,6 +317,7 @@ export const DecideContainer = ({
314317
absoluteServerTimes={absoluteServerTimes}
315318
aspectRatio={aspectRatio}
316319
collectionId={collectionId}
320+
isInHideTrailsAbTest={!!isInHideTrailsAbTest}
317321
/>
318322
</Island>
319323
);
@@ -326,6 +330,7 @@ export const DecideContainer = ({
326330
imageLoading={imageLoading}
327331
aspectRatio={aspectRatio}
328332
collectionId={collectionId}
333+
isInHideTrailsAbTest={!!isInHideTrailsAbTest}
329334
/>
330335
);
331336
default:

dotcom-rendering/src/components/FeatureCard.tsx

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ export type Props = {
335335
*/
336336
isImmersive?: boolean;
337337
showVideo?: boolean;
338+
isInHideTrailsAbTest?: boolean;
338339
};
339340

340341
export const FeatureCard = ({
@@ -370,6 +371,7 @@ export const FeatureCard = ({
370371
isNewsletter = false,
371372
isImmersive = false,
372373
showVideo = false,
374+
isInHideTrailsAbTest = false,
373375
}: Props) => {
374376
const hasSublinks = supportingContent && supportingContent.length > 0;
375377

@@ -460,6 +462,9 @@ export const FeatureCard = ({
460462
isImmersive={isImmersive}
461463
byline={byline}
462464
showByline={showByline}
465+
isInHideTrailsAbTest={
466+
isInHideTrailsAbTest
467+
}
463468
/>
464469
</Island>
465470
</div>
@@ -623,18 +628,19 @@ export const FeatureCard = ({
623628
</div>
624629
) : null}
625630

626-
{!!trailText && (
627-
<div css={trailTextWrapper}>
628-
<TrailText
629-
trailText={trailText}
630-
trailTextColour={palette(
631-
'--feature-card-trail-text',
632-
)}
633-
trailTextSize="regular"
634-
padBottom={false}
635-
/>
636-
</div>
637-
)}
631+
{!!trailText &&
632+
!isInHideTrailsAbTest && (
633+
<div css={trailTextWrapper}>
634+
<TrailText
635+
trailText={trailText}
636+
trailTextColour={palette(
637+
'--feature-card-trail-text',
638+
)}
639+
trailTextSize="regular"
640+
padBottom={false}
641+
/>
642+
</div>
643+
)}
638644

639645
<CardFooter
640646
format={format}

0 commit comments

Comments
 (0)