@newskit-render/core 1.14.1 → 1.24.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +5 -1
- package/.eslintrc +1 -1
- package/CHANGELOG.md +212 -0
- package/Dockerfile +1 -1
- package/__tests__/pages/[articleSlug].test.tsx +1 -1
- package/__tests__/pages/__snapshots__/home.test.tsx.snap +175 -324
- package/__tests__/pages/home.test.tsx +1 -0
- package/applitools.config.js +9 -0
- package/components/article/__tests__/__snapshots__/index.test.tsx.snap +279 -517
- package/components/footer/__snapshots__/index.test.tsx.snap +7 -11
- package/components/header/index.test.tsx +1 -1
- package/components/header/index.tsx +60 -30
- package/components/section/__tests__/ArticleSlice.test.tsx +32 -24
- package/components/section/layouts/__tests__/__snapshots__/Lead.test.tsx.snap +30 -50
- package/components/section/layouts/__tests__/__snapshots__/SectionRow.test.tsx.snap +205 -358
- package/cypress/config/config.e2e.json +14 -0
- package/cypress/config/config.visual.json +8 -0
- package/cypress/e2e/account/SkipToContent.spec.js +12 -0
- package/cypress/e2e/account/accessibility.spec.js +69 -0
- package/cypress/e2e/account/account-page.spec.js +339 -0
- package/cypress/e2e/account/commenting-notifications.spec.js +44 -0
- package/cypress/e2e/account/main-api.spec.js +93 -0
- package/cypress/e2e/account/payment-page.spec.js +42 -0
- package/cypress/{integration → e2e/core}/home-page.spec.js +0 -0
- package/cypress/plugins/index.js +31 -0
- package/cypress/support/commands.js +48 -25
- package/cypress/support/index.js +2 -0
- package/cypress/visual/account/visual-regression.spec.js +31 -0
- package/helpers/a11y.ts +8 -6
- package/helpers/mocks/articleMock.ts +8 -4
- package/helpers/mocks/getRadioPostMock.ts +4 -2
- package/helpers/mocks/getUniversalArticleMock.ts +8 -4
- package/infrastructure/.circleci/config.yml +3 -3
- package/package.json +61 -55
- package/pages/[section]/[articleId]/[articleSlug].tsx +1 -0
- package/pages/[section]/index.tsx +1 -0
- package/pages/_app.tsx +44 -13
- package/pages/_document.tsx +27 -14
- package/pages/checkout/account-creation/index.tsx +9 -1
- package/pages/index.tsx +1 -0
- package/public/MyAccount/no-subscription.svg +15 -0
- package/public/MyAccount/previous-subscription.svg +15 -0
- package/public/MyAccount/primary-navigation-logo-white.svg +6 -0
- package/public/prebid.min.js +1 -0
- package/temp/_document.tsx +1 -1
- package/theme/colours.json +4 -0
- package/theme/render-custom-theme.ts +5 -2
- package/tsconfig.json +4 -1
- package/helpers/articleUtil.ts +0 -4
|
@@ -1,25 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
Cypress.Commands.add('mockConsentAndVisit', (url) => {
|
|
2
|
+
cy.setCookie('nukt_sp_consent', 'JABCDEFGHI')
|
|
3
|
+
cy.setCookie('consentUUID', '28cfcd1e-6916-4488-9d84-54f2618eaa14')
|
|
4
|
+
cy.visit(url)
|
|
5
|
+
})
|
|
6
|
+
|
|
7
|
+
Cypress.Commands.add('GetAcsSession', () => {
|
|
8
|
+
cy.request({
|
|
9
|
+
method: 'POST',
|
|
10
|
+
url: 'https://login.staging-thesun.co.uk/services/session',
|
|
11
|
+
headers: {
|
|
12
|
+
'Content-Type': 'application/vnd.newsuk.acs.createsession-v1+json',
|
|
13
|
+
},
|
|
14
|
+
body: {
|
|
15
|
+
rememberMe: false,
|
|
16
|
+
gotoUrl: 'https://login.staging-thesun.co.uk/',
|
|
17
|
+
sso: false,
|
|
18
|
+
authCredentials: {
|
|
19
|
+
username: 'temp.account@tempaccount.com',
|
|
20
|
+
password: 'asdasd1A',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
}).then((response) => {
|
|
24
|
+
const acs_ngn = response.body.acsCookies.cookies[0].value
|
|
25
|
+
cy.setCookie('acs_ngn', acs_ngn)
|
|
26
|
+
})
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
Cypress.Commands.add('createNewEmail', () => {
|
|
30
|
+
const newEmail =
|
|
31
|
+
Cypress.env('MAIN_USER_EMAIL').split('@')[0].split('').reverse().join('') +
|
|
32
|
+
'@' +
|
|
33
|
+
Cypress.env('MAIN_USER_EMAIL').split('@')[1]
|
|
34
|
+
Cypress.env('newEmail', newEmail)
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
Cypress.Commands.add('getZuoraElement', (selector) => {
|
|
38
|
+
if (Cypress.config('chromeWebSecurity')) {
|
|
39
|
+
throw new Error('To get Zuora element `chromeWebSecurity` must be disabled')
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return cy
|
|
43
|
+
.get('iframe')
|
|
44
|
+
.its('0.contentDocument.body')
|
|
45
|
+
.should('not.be.empty')
|
|
46
|
+
.then(cy.wrap)
|
|
47
|
+
.find(selector)
|
|
48
|
+
})
|
package/cypress/support/index.js
CHANGED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const pages = [
|
|
2
|
+
{ url: '/account', pageName: 'Personal Details' },
|
|
3
|
+
{ url: '/account/edit/name', pageName: 'Name form' },
|
|
4
|
+
{ url: '/account/edit/email', pageName: 'Email form' },
|
|
5
|
+
{ url: '/account/edit/password', pageName: 'Password from' },
|
|
6
|
+
{ url: '/account/edit/mobile', pageName: 'Mobile phone from' },
|
|
7
|
+
{ url: '/account/edit/address', pageName: 'Address form' },
|
|
8
|
+
{
|
|
9
|
+
url: '/account/subscription-and-billing',
|
|
10
|
+
pageName: 'Subscription and Billing',
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
url: '/account/newsletters-and-alerts',
|
|
14
|
+
pageName: 'Newsletters and Alerts',
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
url: '/account/edit/commenting-notifications',
|
|
18
|
+
pageName: 'Commenting Notifications form',
|
|
19
|
+
},
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
describe('Visual regression', () => {
|
|
23
|
+
pages.forEach(({ url, pageName }) => {
|
|
24
|
+
it(`should pass regression: ${pageName}`, () => {
|
|
25
|
+
cy.mockConsentAndVisit(url)
|
|
26
|
+
cy.eyesOpen()
|
|
27
|
+
cy.eyesCheckWindow(`${pageName} page`)
|
|
28
|
+
cy.eyesClose()
|
|
29
|
+
})
|
|
30
|
+
})
|
|
31
|
+
})
|
package/helpers/a11y.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
export const handleEnterKeyPress =
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export const handleEnterKeyPress = (onClick: () => void) => ({
|
|
2
|
+
key,
|
|
3
|
+
}: {
|
|
4
|
+
key: string
|
|
5
|
+
}) => {
|
|
6
|
+
if (key === 'Enter') {
|
|
7
|
+
onClick()
|
|
7
8
|
}
|
|
9
|
+
}
|
|
@@ -26,25 +26,29 @@ export const relatedArticles = [
|
|
|
26
26
|
{
|
|
27
27
|
title: 'Prince Harry',
|
|
28
28
|
tag: 'NEWS',
|
|
29
|
-
text:
|
|
29
|
+
text:
|
|
30
|
+
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut a sodales leo. Cras egestas nisl libero, vitae viverra justo gravida quis.',
|
|
30
31
|
href: imagePlaceholderHref('70x50'),
|
|
31
32
|
},
|
|
32
33
|
{
|
|
33
34
|
title: 'Meghan Markle',
|
|
34
35
|
tag: 'SPORT',
|
|
35
|
-
text:
|
|
36
|
+
text:
|
|
37
|
+
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut a sodales leo. Cras egestas nisl libero, vitae viverra justo gravida quis.',
|
|
36
38
|
href: imagePlaceholderHref('70x50'),
|
|
37
39
|
},
|
|
38
40
|
{
|
|
39
41
|
title: 'Royal Family',
|
|
40
42
|
tag: 'CULTURE',
|
|
41
|
-
text:
|
|
43
|
+
text:
|
|
44
|
+
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut a sodales leo. Cras egestas nisl libero, vitae viverra justo gravida quis.',
|
|
42
45
|
href: imagePlaceholderHref('70x50'),
|
|
43
46
|
},
|
|
44
47
|
{
|
|
45
48
|
title: 'Royal Family',
|
|
46
49
|
tag: 'CORONAVIRUS',
|
|
47
|
-
text:
|
|
50
|
+
text:
|
|
51
|
+
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut a sodales leo. Cras egestas nisl libero, vitae viverra justo gravida quis.',
|
|
48
52
|
href: imagePlaceholderHref('70x50'),
|
|
49
53
|
},
|
|
50
54
|
]
|
|
@@ -29,7 +29,8 @@ export default [
|
|
|
29
29
|
italic: false,
|
|
30
30
|
underline: false,
|
|
31
31
|
monospace: false,
|
|
32
|
-
text:
|
|
32
|
+
text:
|
|
33
|
+
'Proin eget tortor risus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; ',
|
|
33
34
|
},
|
|
34
35
|
{
|
|
35
36
|
type: 'text',
|
|
@@ -45,7 +46,8 @@ export default [
|
|
|
45
46
|
italic: false,
|
|
46
47
|
underline: false,
|
|
47
48
|
monospace: false,
|
|
48
|
-
text:
|
|
49
|
+
text:
|
|
50
|
+
', auctor sit amet aliquam vel, ullamcorper sit amet ligula. Donec rutrum congue leo eget malesuada. Proin eget tortor risus. Sed porttitor lectus nibh. Donec sollicitudin molestie malesuada.',
|
|
49
51
|
},
|
|
50
52
|
],
|
|
51
53
|
},
|
|
@@ -51,17 +51,21 @@ export default [
|
|
|
51
51
|
summary: {
|
|
52
52
|
children: [
|
|
53
53
|
{
|
|
54
|
-
text:
|
|
54
|
+
text:
|
|
55
|
+
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis eget lorem vel nunc feugiat malesuada ut ac nisi. Morbi odio ipsum, dignissim nec turpis vel, laoreet condimentum tortor. Duis laoreet tincidunt ullamcorper.',
|
|
55
56
|
},
|
|
56
57
|
{
|
|
57
|
-
text:
|
|
58
|
+
text:
|
|
59
|
+
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis eget lorem vel nunc feugiat malesuada ut ac nisi. Morbi odio ipsum, dignissim nec turpis vel, laoreet condimentum tortor. Duis laoreet tincidunt ullamcorper.',
|
|
58
60
|
},
|
|
59
61
|
{
|
|
60
62
|
url: 'http://this-is-a-url/',
|
|
61
|
-
text:
|
|
63
|
+
text:
|
|
64
|
+
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis eget lorem vel nunc feugiat malesuada ut ac nisi. Morbi odio ipsum, dignissim nec turpis vel, laoreet condimentum tortor. Duis laoreet tincidunt ullamcorper.',
|
|
62
65
|
},
|
|
63
66
|
{
|
|
64
|
-
text:
|
|
67
|
+
text:
|
|
68
|
+
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis eget lorem vel nunc feugiat malesuada ut ac nisi. Morbi odio ipsum, dignissim nec turpis vel, laoreet condimentum tortor. Duis laoreet tincidunt ullamcorper.',
|
|
65
69
|
},
|
|
66
70
|
],
|
|
67
71
|
},
|
|
@@ -15,7 +15,7 @@ orbs:
|
|
|
15
15
|
|
|
16
16
|
node:
|
|
17
17
|
docker:
|
|
18
|
-
- image: circleci/node:
|
|
18
|
+
- image: circleci/node:16.13-buster-browsers
|
|
19
19
|
auth:
|
|
20
20
|
username: ${DOCKER_USERNAME}
|
|
21
21
|
password: ${DOCKER_PASSWORD}
|
|
@@ -994,11 +994,11 @@ workflows:
|
|
|
994
994
|
jobs:
|
|
995
995
|
- newskit/init_aws:
|
|
996
996
|
<<: *only_on_master_branch
|
|
997
|
-
context:
|
|
997
|
+
context: <% PROJECT_NAME >-dev
|
|
998
998
|
name: init_aws_eks_pr
|
|
999
999
|
job_type: 'eks_pr'
|
|
1000
1000
|
- newskit/remove_all_pr_environments:
|
|
1001
1001
|
<<: *only_on_master_branch
|
|
1002
|
-
context:
|
|
1002
|
+
context: <% PROJECT_NAME >-dev
|
|
1003
1003
|
requires:
|
|
1004
1004
|
- init_aws_eks_pr
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@newskit-render/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.24.1",
|
|
4
4
|
"description": "Newskit Render - Core package",
|
|
5
5
|
"author": "",
|
|
6
6
|
"license": "UNLICENSED",
|
|
7
7
|
"keywords": [],
|
|
8
8
|
"engines": {
|
|
9
|
-
"node": ">=
|
|
9
|
+
"node": ">=16.13.0"
|
|
10
10
|
},
|
|
11
11
|
"scripts": {
|
|
12
12
|
"build": "next build",
|
|
@@ -16,9 +16,11 @@
|
|
|
16
16
|
"test:unit": "jest --coverage --verbose --silent --i",
|
|
17
17
|
"test:unit:ci": "JEST_JUNIT_OUTPUT_NAME=core.xml node --max_old_space_size=4096 --expose-gc ./node_modules/.bin/jest --ci --coverage --reporters=default --reporters=jest-junit --runInBand --logHeapUsage",
|
|
18
18
|
"test:watch": "jest --watch",
|
|
19
|
-
"cy:run": "cypress run -b chrome --headless",
|
|
20
|
-
"cy:
|
|
19
|
+
"cy:run": "cypress run --config-file cypress/config/config.e2e.json -b chrome --headless",
|
|
20
|
+
"cy:vis": "cypress run --config-file cypress/config/config.visual.json -b chrome --headless",
|
|
21
|
+
"cy:open": "cypress open --config-file cypress/config/config.e2e.json -b chrome",
|
|
21
22
|
"test:e2e": "yarn cy:run",
|
|
23
|
+
"test:e2e:ci": "cypress run --env -b chrome --headless",
|
|
22
24
|
"start:test:server": "next build && next start",
|
|
23
25
|
"wait:server": "wait-on http://localhost:3000",
|
|
24
26
|
"pact:test": "NEWSKIT_API_ENV_URL='http://localhost:4343' jest --config=jest.config.pact.js",
|
|
@@ -30,63 +32,67 @@
|
|
|
30
32
|
"analyze": "ANALYZE=true next build"
|
|
31
33
|
},
|
|
32
34
|
"dependencies": {
|
|
33
|
-
"@apollo/client": "
|
|
34
|
-
"@newskit-render/api": "^0.
|
|
35
|
-
"@newskit-render/auth": "^0.
|
|
36
|
-
"@newskit-render/checkout": "^0.
|
|
37
|
-
"@newskit-render/
|
|
38
|
-
"@newskit-render/
|
|
39
|
-
"@newskit-render/
|
|
40
|
-
"@newskit-render/
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"react
|
|
48
|
-
"react-
|
|
35
|
+
"@apollo/client": "3.4.16",
|
|
36
|
+
"@newskit-render/api": "^0.14.0",
|
|
37
|
+
"@newskit-render/auth": "^0.28.0",
|
|
38
|
+
"@newskit-render/checkout": "^0.20.2",
|
|
39
|
+
"@newskit-render/feature-flags": "^0.10.0",
|
|
40
|
+
"@newskit-render/my-account": "^0.135.0",
|
|
41
|
+
"@newskit-render/shared-components": "^0.33.0",
|
|
42
|
+
"@newskit-render/sitemap": "^0.33.0",
|
|
43
|
+
"@newskit-render/validation": "^0.34.0",
|
|
44
|
+
"cross-fetch": "3.1.5",
|
|
45
|
+
"graphql": "15.6.0",
|
|
46
|
+
"newrelic": "7.1.0",
|
|
47
|
+
"newskit": "5.0.0",
|
|
48
|
+
"next": "12.0.10",
|
|
49
|
+
"react": "17.0.2",
|
|
50
|
+
"react-dom": "17.0.2",
|
|
51
|
+
"react-helmet": "6.1.0",
|
|
49
52
|
"react-hook-form": "7.8.4"
|
|
50
53
|
},
|
|
51
54
|
"devDependencies": {
|
|
52
|
-
"@apollo/react-testing": "
|
|
53
|
-
"@
|
|
54
|
-
"@
|
|
55
|
-
"@
|
|
56
|
-
"@
|
|
57
|
-
"@testing-library/
|
|
58
|
-
"@
|
|
59
|
-
"@types/
|
|
60
|
-
"@types/react
|
|
61
|
-
"@
|
|
62
|
-
"@typescript-eslint/
|
|
63
|
-
"
|
|
55
|
+
"@apollo/react-testing": "4.0.0",
|
|
56
|
+
"@applitools/eyes-cypress": "3.23.2",
|
|
57
|
+
"@emotion/jest": "11.3.0",
|
|
58
|
+
"@next/bundle-analyzer": "12.0.8",
|
|
59
|
+
"@pact-foundation/pact": "9.12.1",
|
|
60
|
+
"@testing-library/jest-dom": "5.11.4",
|
|
61
|
+
"@testing-library/react": "11.0.2",
|
|
62
|
+
"@types/newrelic": "7.0.0",
|
|
63
|
+
"@types/react": "17.0.2",
|
|
64
|
+
"@types/react-helmet": "6.1.0",
|
|
65
|
+
"@typescript-eslint/eslint-plugin": "3.7.1",
|
|
66
|
+
"@typescript-eslint/parser": "3.7.1",
|
|
67
|
+
"axe-core": "4.3.4",
|
|
68
|
+
"babel-jest": "26.3.0",
|
|
64
69
|
"cypress": "9.0.0",
|
|
65
|
-
"
|
|
66
|
-
"eslint
|
|
67
|
-
"eslint-config-airbnb
|
|
68
|
-
"eslint-config-
|
|
69
|
-
"eslint-config-
|
|
70
|
-
"eslint-
|
|
71
|
-
"eslint-
|
|
72
|
-
"eslint-
|
|
73
|
-
"eslint-plugin-
|
|
74
|
-
"eslint-plugin-
|
|
70
|
+
"cypress-axe": "0.13.0",
|
|
71
|
+
"eslint": "6.6.0",
|
|
72
|
+
"eslint-config-airbnb": "18.2.0",
|
|
73
|
+
"eslint-config-airbnb-typescript": "9.0.0",
|
|
74
|
+
"eslint-config-prettier": "6.11.0",
|
|
75
|
+
"eslint-config-react-app": "5.2.1",
|
|
76
|
+
"eslint-import-resolver-typescript": "2.0.0",
|
|
77
|
+
"eslint-loader": "4.0.2",
|
|
78
|
+
"eslint-plugin-cypress": "2.11.2",
|
|
79
|
+
"eslint-plugin-flowtype": "5.2.0",
|
|
80
|
+
"eslint-plugin-import": "2.22.1",
|
|
75
81
|
"eslint-plugin-jsx-a11y": "6.2.3",
|
|
76
|
-
"eslint-plugin-prettier": "
|
|
82
|
+
"eslint-plugin-prettier": "3.1.4",
|
|
77
83
|
"eslint-plugin-react": "7.19.0",
|
|
78
|
-
"eslint-plugin-react-hooks": "
|
|
79
|
-
"jest": "
|
|
80
|
-
"jest-junit": "
|
|
81
|
-
"jest-watch-typeahead": "
|
|
82
|
-
"lint-staged": "
|
|
83
|
-
"next-transpile-modules": "
|
|
84
|
-
"prettier": "
|
|
85
|
-
"prettier-eslint": "
|
|
86
|
-
"prettier-eslint-cli": "
|
|
87
|
-
"ts-jest": "
|
|
88
|
-
"typescript": "
|
|
89
|
-
"wait-on": "
|
|
84
|
+
"eslint-plugin-react-hooks": "1.6.1",
|
|
85
|
+
"jest": "27.4.7",
|
|
86
|
+
"jest-junit": "12.0.0",
|
|
87
|
+
"jest-watch-typeahead": "0.6.3",
|
|
88
|
+
"lint-staged": "12.1.7",
|
|
89
|
+
"next-transpile-modules": "8.0.0",
|
|
90
|
+
"prettier": "2.0.5",
|
|
91
|
+
"prettier-eslint": "11.0.0",
|
|
92
|
+
"prettier-eslint-cli": "5.0.0",
|
|
93
|
+
"ts-jest": "27.1.3",
|
|
94
|
+
"typescript": "4.4.3",
|
|
95
|
+
"wait-on": "5.3.0"
|
|
90
96
|
},
|
|
91
97
|
"precommit": [
|
|
92
98
|
"precommit"
|
package/pages/_app.tsx
CHANGED
|
@@ -3,6 +3,12 @@ import { AppProps } from 'next/app'
|
|
|
3
3
|
import Head from 'next/head'
|
|
4
4
|
import { ThemeProvider, Global, css, styled } from 'newskit'
|
|
5
5
|
import { SessionProvider } from '@newskit-render/auth'
|
|
6
|
+
import {
|
|
7
|
+
getFeatureFlags,
|
|
8
|
+
FeatureFlagsContextProvider,
|
|
9
|
+
FeatureFlag,
|
|
10
|
+
createFeatureFlagsInstance,
|
|
11
|
+
} from '@newskit-render/feature-flags'
|
|
6
12
|
import { AppContextProvider, AppContext } from '../app-context/AppContext'
|
|
7
13
|
import { logger } from '../helpers/logger'
|
|
8
14
|
|
|
@@ -12,6 +18,12 @@ if (!process.browser) {
|
|
|
12
18
|
logger()
|
|
13
19
|
}
|
|
14
20
|
|
|
21
|
+
if (process.env.OPTIMIZELY_SDK_KEY) {
|
|
22
|
+
createFeatureFlagsInstance({
|
|
23
|
+
optimizelyConfig: { sdkKey: process.env.OPTIMIZELY_SDK_KEY },
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
|
|
15
27
|
const GlobalStyling = css`
|
|
16
28
|
@font-face {
|
|
17
29
|
font-family: GillSansMTStd-Medium;
|
|
@@ -240,7 +252,11 @@ const PageContainer = styled.div`
|
|
|
240
252
|
min-height: 100vh;
|
|
241
253
|
`
|
|
242
254
|
|
|
243
|
-
|
|
255
|
+
interface MyAppProps extends AppProps {
|
|
256
|
+
featureFlags?: FeatureFlag
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function MyApp({ Component, pageProps, featureFlags }: MyAppProps) {
|
|
244
260
|
return (
|
|
245
261
|
<AppContextProvider>
|
|
246
262
|
<>
|
|
@@ -254,21 +270,36 @@ function MyApp({ Component, pageProps }: AppProps) {
|
|
|
254
270
|
key="viewport"
|
|
255
271
|
/>
|
|
256
272
|
</Head>
|
|
257
|
-
<
|
|
258
|
-
<
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
<
|
|
262
|
-
|
|
263
|
-
<
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
273
|
+
<FeatureFlagsContextProvider context={featureFlags}>
|
|
274
|
+
<SessionProvider pageProps={pageProps}>
|
|
275
|
+
<AppContext.Consumer>
|
|
276
|
+
{({ theme }) => (
|
|
277
|
+
<ThemeProvider theme={theme}>
|
|
278
|
+
<Global styles={GlobalStyling} />
|
|
279
|
+
<PageContainer>
|
|
280
|
+
<Component {...pageProps} />
|
|
281
|
+
</PageContainer>
|
|
282
|
+
</ThemeProvider>
|
|
283
|
+
)}
|
|
284
|
+
</AppContext.Consumer>
|
|
285
|
+
</SessionProvider>
|
|
286
|
+
</FeatureFlagsContextProvider>
|
|
269
287
|
</>
|
|
270
288
|
</AppContextProvider>
|
|
271
289
|
)
|
|
272
290
|
}
|
|
273
291
|
|
|
292
|
+
MyApp.getInitialProps = async ({ Component, ctx }) => {
|
|
293
|
+
let pageProps = {}
|
|
294
|
+
if (Component.getInitialProps) {
|
|
295
|
+
pageProps = await Component.getInitialProps(ctx)
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
if (process.env.OPTIMIZELY_SDK_KEY) {
|
|
299
|
+
const featureFlags = await getFeatureFlags()
|
|
300
|
+
return { featureFlags, pageProps }
|
|
301
|
+
}
|
|
302
|
+
return { pageProps }
|
|
303
|
+
}
|
|
304
|
+
|
|
274
305
|
export default MyApp
|
package/pages/_document.tsx
CHANGED
|
@@ -32,6 +32,13 @@ export default class MyDocument extends Document {
|
|
|
32
32
|
|
|
33
33
|
render() {
|
|
34
34
|
const helmet = Helmet.rewind()
|
|
35
|
+
const showAds =
|
|
36
|
+
this.props.__NEXT_DATA__.props.pageProps &&
|
|
37
|
+
this.props.__NEXT_DATA__.props.pageProps.showAds
|
|
38
|
+
? this.props.__NEXT_DATA__.props.pageProps.showAds
|
|
39
|
+
: false
|
|
40
|
+
|
|
41
|
+
const { featureFlags } = this.props.__NEXT_DATA__.props
|
|
35
42
|
return (
|
|
36
43
|
<Html lang="en">
|
|
37
44
|
<Head>
|
|
@@ -46,12 +53,14 @@ export default class MyDocument extends Document {
|
|
|
46
53
|
),
|
|
47
54
|
}}
|
|
48
55
|
/>
|
|
49
|
-
{EXPERIMENTATION_WEB &&
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
56
|
+
{EXPERIMENTATION_WEB &&
|
|
57
|
+
featureFlags &&
|
|
58
|
+
featureFlags.experimentation_web_flag && (
|
|
59
|
+
<ExperimentationWeb
|
|
60
|
+
optimizelyWebConfig={{ scriptCdn: EXPERIMENTATION_WEB }}
|
|
61
|
+
reactHelmet={Helmet}
|
|
62
|
+
/>
|
|
63
|
+
)}
|
|
55
64
|
{helmet.script.toComponent()}
|
|
56
65
|
{SOURCEPOINT_ACCOUNT_ID && (
|
|
57
66
|
<Consent
|
|
@@ -62,14 +71,18 @@ export default class MyDocument extends Document {
|
|
|
62
71
|
/>
|
|
63
72
|
)}
|
|
64
73
|
<meta name="robots" content="noindex" />
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
74
|
+
{showAds && (
|
|
75
|
+
<>
|
|
76
|
+
<script
|
|
77
|
+
type="text/javascript"
|
|
78
|
+
src="https://ads.newskit.co.uk/prebid.newskit.min.js"
|
|
79
|
+
/>
|
|
80
|
+
<script
|
|
81
|
+
type="text/javascript"
|
|
82
|
+
src="https://ads.newskit.co.uk/ads.newskit.min.js"
|
|
83
|
+
/>
|
|
84
|
+
</>
|
|
85
|
+
)}
|
|
73
86
|
</Head>
|
|
74
87
|
<body>
|
|
75
88
|
{TEALIUM_ACCOUNT_ID && (
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import { AccountCreation, getProviderProps } from '@newskit-render/checkout'
|
|
2
2
|
import React, { useContext } from 'react'
|
|
3
3
|
import { AppContext } from '../../../app-context/AppContext'
|
|
4
|
+
import validation from '../../../validation'
|
|
4
5
|
|
|
5
6
|
const AccountCreationPage = (props) => {
|
|
6
7
|
const { theme, setTheme } = useContext(AppContext)
|
|
7
|
-
return
|
|
8
|
+
return (
|
|
9
|
+
<AccountCreation
|
|
10
|
+
{...props}
|
|
11
|
+
customTheme={theme}
|
|
12
|
+
setTheme={setTheme}
|
|
13
|
+
validation={validation}
|
|
14
|
+
/>
|
|
15
|
+
)
|
|
8
16
|
}
|
|
9
17
|
|
|
10
18
|
export default AccountCreationPage
|