@newskit-render/core 1.13.3 → 1.22.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.
Files changed (112) hide show
  1. package/.eslintignore +5 -1
  2. package/.eslintrc +1 -1
  3. package/CHANGELOG.md +212 -0
  4. package/__tests__/pages/[articleSlug].test.tsx +1 -1
  5. package/__tests__/pages/__snapshots__/home.test.tsx.snap +175 -324
  6. package/__tests__/pages/home.test.tsx +1 -0
  7. package/applitools.config.js +9 -0
  8. package/components/article/__tests__/__snapshots__/index.test.tsx.snap +279 -517
  9. package/components/footer/__snapshots__/index.test.tsx.snap +7 -11
  10. package/components/header/index.test.tsx +1 -1
  11. package/components/header/index.tsx +60 -30
  12. package/components/section/__tests__/ArticleSlice.test.tsx +32 -24
  13. package/components/section/layouts/__tests__/__snapshots__/Lead.test.tsx.snap +30 -50
  14. package/components/section/layouts/__tests__/__snapshots__/SectionRow.test.tsx.snap +205 -358
  15. package/cypress/config/config.e2e.json +14 -0
  16. package/cypress/config/config.visual.json +8 -0
  17. package/cypress/e2e/account/SkipToContent.spec.js +12 -0
  18. package/cypress/e2e/account/accessibility.spec.js +69 -0
  19. package/cypress/e2e/account/account-page.spec.js +339 -0
  20. package/cypress/e2e/account/commenting-notifications.spec.js +44 -0
  21. package/cypress/e2e/account/main-api.spec.js +93 -0
  22. package/cypress/e2e/account/payment-page.spec.js +42 -0
  23. package/cypress/{integration → e2e/core}/home-page.spec.js +0 -0
  24. package/cypress/plugins/index.js +31 -0
  25. package/cypress/support/commands.js +48 -25
  26. package/cypress/support/index.js +2 -0
  27. package/cypress/visual/account/visual-regression.spec.js +31 -0
  28. package/helpers/a11y.ts +8 -6
  29. package/helpers/mocks/articleMock.ts +8 -4
  30. package/helpers/mocks/getRadioPostMock.ts +4 -2
  31. package/helpers/mocks/getUniversalArticleMock.ts +8 -4
  32. package/infrastructure/.circleci/config.yml +2 -2
  33. package/package.json +60 -54
  34. package/pages/[section]/[articleId]/[articleSlug].tsx +1 -0
  35. package/pages/[section]/index.tsx +1 -0
  36. package/pages/_app.tsx +216 -13
  37. package/pages/_document.tsx +27 -14
  38. package/pages/checkout/account-creation/index.tsx +9 -1
  39. package/pages/index.tsx +1 -0
  40. package/public/MyAccount/primary-navigation-logo-white.svg +6 -0
  41. package/public/fonts/bitter-medium.woff +0 -0
  42. package/public/fonts/bitter-medium.woff2 +0 -0
  43. package/public/fonts/bitter-mediumitalic.woff +0 -0
  44. package/public/fonts/bitter-mediumitalic.woff2 +0 -0
  45. package/public/fonts/bitter-regular.woff +0 -0
  46. package/public/fonts/bitter-regular.woff2 +0 -0
  47. package/public/fonts/bitter-semibold.woff +0 -0
  48. package/public/fonts/bitter-semibold.woff2 +0 -0
  49. package/public/fonts/dmmono-medium.woff +0 -0
  50. package/public/fonts/dmmono-medium.woff2 +0 -0
  51. package/public/fonts/dmsans-bold-webfont.woff +0 -0
  52. package/public/fonts/dmsans-bold-webfont.woff2 +0 -0
  53. package/public/fonts/dmsans-bolditalic-webfont.woff +0 -0
  54. package/public/fonts/dmsans-bolditalic-webfont.woff2 +0 -0
  55. package/public/fonts/dmsans-italic-webfont.woff +0 -0
  56. package/public/fonts/dmsans-italic-webfont.woff2 +0 -0
  57. package/public/fonts/dmsans-medium-webfont.woff +0 -0
  58. package/public/fonts/dmsans-medium-webfont.woff2 +0 -0
  59. package/public/fonts/dmsans-mediumitalic-webfont.woff +0 -0
  60. package/public/fonts/dmsans-mediumitalic-webfont.woff2 +0 -0
  61. package/public/fonts/dmsans-regular-webfont.woff +0 -0
  62. package/public/fonts/dmsans-regular-webfont.woff2 +0 -0
  63. package/public/fonts/notosans-bold-webfont.woff +0 -0
  64. package/public/fonts/notosans-bold-webfont.woff2 +0 -0
  65. package/public/fonts/notosans-italic-webfont.woff +0 -0
  66. package/public/fonts/notosans-italic-webfont.woff2 +0 -0
  67. package/public/fonts/notosans-medium-webfont.woff +0 -0
  68. package/public/fonts/notosans-medium-webfont.woff2 +0 -0
  69. package/public/fonts/notosans-regular-webfont.woff +0 -0
  70. package/public/fonts/notosans-regular-webfont.woff2 +0 -0
  71. package/public/fonts/poppins-bold-webfont.woff +0 -0
  72. package/public/fonts/poppins-bold-webfont.woff2 +0 -0
  73. package/public/fonts/poppins-bolditalic-webfont.woff +0 -0
  74. package/public/fonts/poppins-bolditalic-webfont.woff2 +0 -0
  75. package/public/fonts/poppins-extrabold-webfont.woff +0 -0
  76. package/public/fonts/poppins-extrabold-webfont.woff2 +0 -0
  77. package/public/fonts/poppins-extrabolditalic-webfont.woff +0 -0
  78. package/public/fonts/poppins-extrabolditalic-webfont.woff2 +0 -0
  79. package/public/fonts/poppins-italic-webfont.woff +0 -0
  80. package/public/fonts/poppins-italic-webfont.woff2 +0 -0
  81. package/public/fonts/poppins-light-webfont.woff +0 -0
  82. package/public/fonts/poppins-light-webfont.woff2 +0 -0
  83. package/public/fonts/poppins-lightitalic-webfont.woff +0 -0
  84. package/public/fonts/poppins-lightitalic-webfont.woff2 +0 -0
  85. package/public/fonts/poppins-medium-webfont.woff +0 -0
  86. package/public/fonts/poppins-medium-webfont.woff2 +0 -0
  87. package/public/fonts/poppins-mediumitalic-webfont.woff +0 -0
  88. package/public/fonts/poppins-mediumitalic-webfont.woff2 +0 -0
  89. package/public/fonts/poppins-regular-webfont.woff +0 -0
  90. package/public/fonts/poppins-regular-webfont.woff2 +0 -0
  91. package/public/fonts/poppins-semibold-webfont.woff +0 -0
  92. package/public/fonts/poppins-semibold-webfont.woff2 +0 -0
  93. package/public/fonts/poppins-semibolditalic-webfont.woff +0 -0
  94. package/public/fonts/poppins-semibolditalic-webfont.woff2 +0 -0
  95. package/public/fonts/source-serif-pro-600.woff +0 -0
  96. package/public/fonts/source-serif-pro-600.woff2 +0 -0
  97. package/public/fonts/source-serif-pro-600italic.woff +0 -0
  98. package/public/fonts/source-serif-pro-600italic.woff2 +0 -0
  99. package/public/fonts/source-serif-pro-700.woff +0 -0
  100. package/public/fonts/source-serif-pro-700.woff2 +0 -0
  101. package/public/fonts/source-serif-pro-700italic.woff +0 -0
  102. package/public/fonts/source-serif-pro-700italic.woff2 +0 -0
  103. package/public/fonts/source-serif-pro-italic.woff +0 -0
  104. package/public/fonts/source-serif-pro-italic.woff2 +0 -0
  105. package/public/fonts/source-serif-pro-regular.woff +0 -0
  106. package/public/fonts/source-serif-pro-regular.woff2 +0 -0
  107. package/public/prebid.min.js +1 -0
  108. package/temp/_document.tsx +1 -1
  109. package/theme/colours.json +4 -0
  110. package/theme/render-custom-theme.ts +5 -2
  111. package/tsconfig.json +4 -1
  112. package/helpers/articleUtil.ts +0 -4
@@ -1,25 +1,48 @@
1
- // ***********************************************
2
- // This example commands.js shows you how to
3
- // create various custom commands and overwrite
4
- // existing commands.
5
- //
6
- // For more comprehensive examples of custom
7
- // commands please read more here:
8
- // https://on.cypress.io/custom-commands
9
- // ***********************************************
10
- //
11
- //
12
- // -- This is a parent command --
13
- // Cypress.Commands.add("login", (email, password) => { ... })
14
- //
15
- //
16
- // -- This is a child command --
17
- // Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
18
- //
19
- //
20
- // -- This is a dual command --
21
- // Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
22
- //
23
- //
24
- // -- This will overwrite an existing command --
25
- // Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
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
+ })
@@ -15,6 +15,8 @@
15
15
 
16
16
  // Import commands.js using ES2015 syntax:
17
17
  import './commands'
18
+ import 'cypress-axe'
19
+ import '@applitools/eyes-cypress/commands'
18
20
 
19
21
  // Alternatively you can use CommonJS syntax:
20
22
  // require('./commands')
@@ -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
- (onClick: () => void) =>
3
- ({ key }: { key: string }) => {
4
- if (key === 'Enter') {
5
- onClick()
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: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut a sodales leo. Cras egestas nisl libero, vitae viverra justo gravida quis.',
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: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut a sodales leo. Cras egestas nisl libero, vitae viverra justo gravida quis.',
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: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut a sodales leo. Cras egestas nisl libero, vitae viverra justo gravida quis.',
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: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut a sodales leo. Cras egestas nisl libero, vitae viverra justo gravida quis.',
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: 'Proin eget tortor risus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; ',
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: ', 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
+ 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: '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.',
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: '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
+ 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: '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.',
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: '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.',
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
  },
@@ -994,11 +994,11 @@ workflows:
994
994
  jobs:
995
995
  - newskit/init_aws:
996
996
  <<: *only_on_master_branch
997
- context: ncu-newskit-render-trial-project-dev
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: ncu-newskit-render-trial-project-dev
1002
+ context: <% PROJECT_NAME >-dev
1003
1003
  requires:
1004
1004
  - init_aws_eks_pr
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newskit-render/core",
3
- "version": "1.13.3",
3
+ "version": "1.22.1",
4
4
  "description": "Newskit Render - Core package",
5
5
  "author": "",
6
6
  "license": "UNLICENSED",
@@ -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:open": "cypress open",
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": "^3.4.16",
34
- "@newskit-render/api": "^0.8.0",
35
- "@newskit-render/auth": "^0.25.0",
36
- "@newskit-render/checkout": "^0.15.0",
37
- "@newskit-render/my-account": "^0.123.0",
38
- "@newskit-render/shared-components": "^0.25.0",
39
- "@newskit-render/sitemap": "^0.28.0",
40
- "@newskit-render/validation": "^0.30.0",
41
- "cross-fetch": "^3.1.4",
42
- "graphql": "^15.6.0",
43
- "newrelic": "^7.1.0",
44
- "newskit": "4.3.1",
45
- "next": "^12.0.2",
46
- "react": "^17.0.1",
47
- "react-dom": "^17.0.2",
48
- "react-helmet": "^6.1.0",
35
+ "@apollo/client": "3.4.16",
36
+ "@newskit-render/api": "^0.13.0",
37
+ "@newskit-render/auth": "^0.27.0",
38
+ "@newskit-render/checkout": "^0.19.1",
39
+ "@newskit-render/feature-flags": "^0.9.0",
40
+ "@newskit-render/my-account": "^0.133.0",
41
+ "@newskit-render/shared-components": "^0.31.0",
42
+ "@newskit-render/sitemap": "^0.31.1",
43
+ "@newskit-render/validation": "^0.33.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.8",
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": "^4.0.0",
53
- "@emotion/jest": "^11.3.0",
54
- "@next/bundle-analyzer": "^12.0.8",
55
- "@pact-foundation/pact": "^9.12.1",
56
- "@testing-library/jest-dom": "^5.11.4",
57
- "@testing-library/react": "^11.0.2",
58
- "@types/newrelic": "^7.0.0",
59
- "@types/react": "^16.9.49",
60
- "@types/react-helmet": "^6.1.0",
61
- "@typescript-eslint/eslint-plugin": "^3.7.1",
62
- "@typescript-eslint/parser": "^3.7.1",
63
- "babel-jest": "^26.3.0",
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
- "eslint": "^6.6.0",
66
- "eslint-config-airbnb": "^18.2.0",
67
- "eslint-config-airbnb-typescript": "^9.0.0",
68
- "eslint-config-prettier": "^6.11.0",
69
- "eslint-config-react-app": "^5.2.1",
70
- "eslint-import-resolver-typescript": "^2.0.0",
71
- "eslint-loader": "^4.0.2",
72
- "eslint-plugin-cypress": "^2.11.2",
73
- "eslint-plugin-flowtype": "^5.2.0",
74
- "eslint-plugin-import": "^2.22.1",
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": "^3.1.4",
82
+ "eslint-plugin-prettier": "3.1.4",
77
83
  "eslint-plugin-react": "7.19.0",
78
- "eslint-plugin-react-hooks": "^1.6.1",
79
- "jest": "^27.2.4",
80
- "jest-junit": "^12.0.0",
81
- "jest-watch-typeahead": "^0.6.3",
82
- "lint-staged": "^12.1.7",
83
- "next-transpile-modules": "^8.0.0",
84
- "prettier": "^2.0.5",
85
- "prettier-eslint": "^11.0.0",
86
- "prettier-eslint-cli": "^5.0.0",
87
- "ts-jest": "^27.0.5",
88
- "typescript": "^4.4.3",
89
- "wait-on": "^5.3.0"
84
+ "eslint-plugin-react-hooks": "1.6.1",
85
+ "jest": "27.2.4",
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.0.5",
94
+ "typescript": "4.4.3",
95
+ "wait-on": "5.3.0"
90
96
  },
91
97
  "precommit": [
92
98
  "precommit"
@@ -70,6 +70,7 @@ export async function getServerSideProps(context) {
70
70
  twitterUsername: process.env.TWITTER_USERNAME || '',
71
71
  siteHost: process.env.SITE_HOST || '',
72
72
  gscId: process.env.GSC_ID || '',
73
+ showAds: true,
73
74
  // user,
74
75
  },
75
76
  }
@@ -38,6 +38,7 @@ export async function getServerSideProps(context) {
38
38
  props: {
39
39
  page: data.page,
40
40
  isIndexPage: true,
41
+ showAds: true,
41
42
  // user,
42
43
  },
43
44
  }
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;
@@ -49,6 +61,178 @@ const GlobalStyling = css`
49
61
  font-family: TheSun-Medium;
50
62
  src: url('/fonts/TheSun-Medium.ttf') format('truetype');
51
63
  }
64
+ @font-face {
65
+ font-family: 'DM Sans';
66
+ src: url('/fonts/dmsans-regular-webfont.woff2') format('woff2'),
67
+ url('/fonts/dmsans-regular-webfont.woff') format('woff');
68
+ font-style: normal;
69
+ font-weight: 400;
70
+ font-display: swap;
71
+ }
72
+ @font-face {
73
+ font-family: 'DM Sans';
74
+ src: url('/fonts/dmsans-italic-webfont.woff2') format('woff2'),
75
+ url('/fonts/dmsans-italic-webfont.woff') format('woff');
76
+ font-style: italic;
77
+ font-weight: 400;
78
+ font-display: swap;
79
+ }
80
+ @font-face {
81
+ font-family: 'DM Sans';
82
+ src: url('/fonts/dmsans-medium-webfont.woff2') format('woff2'),
83
+ url('/fonts/dmsans-medium-webfont.woff') format('woff');
84
+ font-style: normal;
85
+ font-weight: 500;
86
+ font-display: swap;
87
+ }
88
+ @font-face {
89
+ font-family: 'DM Sans';
90
+ src: url('/fonts/dmsans-mediumitalic-webfont.woff2') format('woff2'),
91
+ url('/fonts/dmsans-mediumitalic-webfont.woff') format('woff');
92
+ font-style: italic;
93
+ font-weight: 500;
94
+ font-display: swap;
95
+ }
96
+ @font-face {
97
+ font-family: 'DM Sans';
98
+ src: url('/fonts/dmsans-bold-webfont.woff2') format('woff2'),
99
+ url('/fonts/dmsans-bold-webfont.woff') format('woff');
100
+ font-style: normal;
101
+ font-weight: 700;
102
+ font-display: swap;
103
+ }
104
+ @font-face {
105
+ font-family: 'DM Sans';
106
+ src: url('/fonts/dmsans-bolditalic-webfont.woff2') format('woff2'),
107
+ url('/fonts/dmsans-bolditalic-webfont.woff') format('woff');
108
+ font-style: italic;
109
+ font-weight: 700;
110
+ font-display: swap;
111
+ }
112
+ @font-face {
113
+ font-family: 'Poppins';
114
+ src: url('/fonts/poppins-bold-webfont.woff2') format('woff2'),
115
+ url('/fonts/poppins-bold-webfont.woff') format('woff');
116
+ font-weight: 700;
117
+ font-style: normal;
118
+ }
119
+ @font-face {
120
+ font-family: 'Poppins';
121
+ src: url('/fonts/poppins-bolditalic-webfont.woff2') format('woff2'),
122
+ url('/fonts/poppins-bolditalic-webfont.woff') format('woff');
123
+ font-weight: normal;
124
+ font-style: italic;
125
+ }
126
+ @font-face {
127
+ font-family: 'Poppins';
128
+ src: url('/fonts/poppins-extrabold-webfont.woff2') format('woff2'),
129
+ url('/fonts/poppins-extrabold-webfont.woff') format('woff');
130
+ font-weight: 800;
131
+ font-style: normal;
132
+ }
133
+ @font-face {
134
+ font-family: 'Poppins';
135
+ src: url('/fonts/poppins-extrabolditalic-webfont.woff2') format('woff2'),
136
+ url('/fonts/poppins-extrabolditalic-webfont.woff') format('woff');
137
+ font-weight: 800;
138
+ font-style: italic;
139
+ }
140
+ @font-face {
141
+ font-family: 'Poppins';
142
+ src: url('/fonts/poppins-italic-webfont.woff2') format('woff2'),
143
+ url('/fonts/poppins-italic-webfont.woff') format('woff');
144
+ font-weight: 400;
145
+ font-style: italic;
146
+ }
147
+ @font-face {
148
+ font-family: 'Poppins';
149
+ src: url('/fonts/poppins-light-webfont.woff2') format('woff2'),
150
+ url('/fonts/poppins-light-webfont.woff') format('woff');
151
+ font-weight: 300;
152
+ font-style: normal;
153
+ }
154
+ @font-face {
155
+ font-family: 'Poppins';
156
+ src: url('/fonts/poppins-lightitalic-webfont.woff2') format('woff2'),
157
+ url('/fonts/poppins-lightitalic-webfont.woff') format('woff');
158
+ font-weight: 300;
159
+ font-style: italic;
160
+ }
161
+ @font-face {
162
+ font-family: 'Poppins';
163
+ src: url('/fonts/poppins-medium-webfont.woff2') format('woff2'),
164
+ url('/fonts/poppins-medium-webfont.woff') format('woff');
165
+ font-weight: 500;
166
+ font-style: normal;
167
+ }
168
+ @font-face {
169
+ font-family: 'Poppins';
170
+ src: url('/fonts/poppins-mediumitalic-webfont.woff2') format('woff2'),
171
+ url('/fonts/poppins-mediumitalic-webfont.woff') format('woff');
172
+ font-weight: 500;
173
+ font-style: italic;
174
+ }
175
+ @font-face {
176
+ font-family: 'Poppins';
177
+ src: url('/fonts/poppins-regular-webfont.woff2') format('woff2'),
178
+ url('/fonts/poppins-regular-webfont.woff') format('woff');
179
+ font-weight: 400;
180
+ font-style: normal;
181
+ }
182
+ @font-face {
183
+ font-family: 'Poppins';
184
+ src: url('/fonts/poppins-semibold-webfont.woff2') format('woff2'),
185
+ url('/fonts/poppins-semibold-webfont.woff') format('woff');
186
+ font-weight: 600;
187
+ font-style: normal;
188
+ }
189
+ @font-face {
190
+ font-family: 'Poppins';
191
+ src: url('/fonts/poppins-semibolditalic-webfont.woff2') format('woff2'),
192
+ url('/fonts/poppins-semibolditalic-webfont.woff') format('woff');
193
+ font-weight: 600;
194
+ font-style: italic;
195
+ }
196
+ @font-face {
197
+ font-family: 'DM Mono';
198
+ src: url('/fonts/dmmono-medium.woff2') format('woff2'),
199
+ url('/fonts/dmmono-medium.woff') format('woff');
200
+ font-style: normal;
201
+ font-weight: 500;
202
+ font-display: swap;
203
+ }
204
+ @font-face {
205
+ font-family: 'Bitter';
206
+ src: url('/fonts/bitter-regular.woff2') format('woff2'),
207
+ url('/fonts/bitter-regular.woff') format('woff');
208
+ font-style: normal;
209
+ font-weight: 400;
210
+ font-display: swap;
211
+ }
212
+ @font-face {
213
+ font-family: 'Bitter';
214
+ src: url('/fonts/bitter-medium.woff2') format('woff2'),
215
+ url('/fonts/bitter-medium.woff') format('woff');
216
+ font-style: normal;
217
+ font-weight: 500;
218
+ font-display: swap;
219
+ }
220
+ @font-face {
221
+ font-family: 'Bitter';
222
+ src: url('/fonts/bitter-mediumitalic.woff2') format('woff2'),
223
+ url('/fonts/bitter-mediumitalic.woff') format('woff');
224
+ font-style: italic;
225
+ font-weight: 500;
226
+ font-display: swap;
227
+ }
228
+ @font-face {
229
+ font-family: 'Bitter';
230
+ src: url('/fonts/bitter-semibold.woff2') format('woff2'),
231
+ url('/fonts/bitter-semibold.woff') format('woff');
232
+ font-style: normal;
233
+ font-weight: 600;
234
+ font-display: swap;
235
+ }
52
236
 
53
237
  html,
54
238
  body {
@@ -68,7 +252,11 @@ const PageContainer = styled.div`
68
252
  min-height: 100vh;
69
253
  `
70
254
 
71
- function MyApp({ Component, pageProps }: AppProps) {
255
+ interface MyAppProps extends AppProps {
256
+ featureFlags?: FeatureFlag
257
+ }
258
+
259
+ function MyApp({ Component, pageProps, featureFlags }: MyAppProps) {
72
260
  return (
73
261
  <AppContextProvider>
74
262
  <>
@@ -82,21 +270,36 @@ function MyApp({ Component, pageProps }: AppProps) {
82
270
  key="viewport"
83
271
  />
84
272
  </Head>
85
- <SessionProvider pageProps={pageProps}>
86
- <AppContext.Consumer>
87
- {({ theme }) => (
88
- <ThemeProvider theme={theme}>
89
- <Global styles={GlobalStyling} />
90
- <PageContainer>
91
- <Component {...pageProps} />
92
- </PageContainer>
93
- </ThemeProvider>
94
- )}
95
- </AppContext.Consumer>
96
- </SessionProvider>
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>
97
287
  </>
98
288
  </AppContextProvider>
99
289
  )
100
290
  }
101
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
+
102
305
  export default MyApp