Skip to content

Commit f0d994f

Browse files
authored
Merge branch 'main' into jm/feat-prevent-banner-and-sign-in-gate-together
2 parents 70b36fb + d629dfc commit f0d994f

File tree

17 files changed

+440
-172
lines changed

17 files changed

+440
-172
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/FrontPage.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { BrazeMessaging } from './BrazeMessaging.importable';
1212
import { useConfig } from './ConfigContext';
1313
import { DarkModeMessage } from './DarkModeMessage';
1414
import { FocusStyles } from './FocusStyles.importable';
15-
import { GoogleOneTap, isInGoogleOneTapTest } from './GoogleOneTap.importable';
15+
import { GoogleOneTap, isGoogleOneTapEnabled } from './GoogleOneTap.importable';
1616
import { Island } from './Island';
1717
import { Metrics } from './Metrics.importable';
1818
import { ReaderRevenueDev } from './ReaderRevenueDev.importable';
@@ -93,7 +93,10 @@ export const FrontPage = ({ front, NAV }: Props) => {
9393
<Island priority="feature" defer={{ until: 'idle' }}>
9494
<ReaderRevenueDev shouldHideReaderRevenue={false} />
9595
</Island>
96-
{isInGoogleOneTapTest(front.config.abTests) && (
96+
{isGoogleOneTapEnabled(
97+
front.config.abTests,
98+
front.config.switches,
99+
) && (
97100
<Island priority="enhancement" defer={{ until: 'idle' }}>
98101
<GoogleOneTap />
99102
</Island>

0 commit comments

Comments
 (0)