@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.
Files changed (49) hide show
  1. package/.eslintignore +5 -1
  2. package/.eslintrc +1 -1
  3. package/CHANGELOG.md +212 -0
  4. package/Dockerfile +1 -1
  5. package/__tests__/pages/[articleSlug].test.tsx +1 -1
  6. package/__tests__/pages/__snapshots__/home.test.tsx.snap +175 -324
  7. package/__tests__/pages/home.test.tsx +1 -0
  8. package/applitools.config.js +9 -0
  9. package/components/article/__tests__/__snapshots__/index.test.tsx.snap +279 -517
  10. package/components/footer/__snapshots__/index.test.tsx.snap +7 -11
  11. package/components/header/index.test.tsx +1 -1
  12. package/components/header/index.tsx +60 -30
  13. package/components/section/__tests__/ArticleSlice.test.tsx +32 -24
  14. package/components/section/layouts/__tests__/__snapshots__/Lead.test.tsx.snap +30 -50
  15. package/components/section/layouts/__tests__/__snapshots__/SectionRow.test.tsx.snap +205 -358
  16. package/cypress/config/config.e2e.json +14 -0
  17. package/cypress/config/config.visual.json +8 -0
  18. package/cypress/e2e/account/SkipToContent.spec.js +12 -0
  19. package/cypress/e2e/account/accessibility.spec.js +69 -0
  20. package/cypress/e2e/account/account-page.spec.js +339 -0
  21. package/cypress/e2e/account/commenting-notifications.spec.js +44 -0
  22. package/cypress/e2e/account/main-api.spec.js +93 -0
  23. package/cypress/e2e/account/payment-page.spec.js +42 -0
  24. package/cypress/{integration → e2e/core}/home-page.spec.js +0 -0
  25. package/cypress/plugins/index.js +31 -0
  26. package/cypress/support/commands.js +48 -25
  27. package/cypress/support/index.js +2 -0
  28. package/cypress/visual/account/visual-regression.spec.js +31 -0
  29. package/helpers/a11y.ts +8 -6
  30. package/helpers/mocks/articleMock.ts +8 -4
  31. package/helpers/mocks/getRadioPostMock.ts +4 -2
  32. package/helpers/mocks/getUniversalArticleMock.ts +8 -4
  33. package/infrastructure/.circleci/config.yml +3 -3
  34. package/package.json +61 -55
  35. package/pages/[section]/[articleId]/[articleSlug].tsx +1 -0
  36. package/pages/[section]/index.tsx +1 -0
  37. package/pages/_app.tsx +44 -13
  38. package/pages/_document.tsx +27 -14
  39. package/pages/checkout/account-creation/index.tsx +9 -1
  40. package/pages/index.tsx +1 -0
  41. package/public/MyAccount/no-subscription.svg +15 -0
  42. package/public/MyAccount/previous-subscription.svg +15 -0
  43. package/public/MyAccount/primary-navigation-logo-white.svg +6 -0
  44. package/public/prebid.min.js +1 -0
  45. package/temp/_document.tsx +1 -1
  46. package/theme/colours.json +4 -0
  47. package/theme/render-custom-theme.ts +5 -2
  48. package/tsconfig.json +4 -1
  49. package/helpers/articleUtil.ts +0 -4
@@ -200,30 +200,26 @@ exports[`Footer tests should render footer 1`] = `
200
200
 
201
201
  .emotion-12 {
202
202
  margin: 0;
203
- padding: 1px 0;
204
203
  font-family: "DM Sans",sans-serif;
205
204
  font-size: 14px;
206
- line-height: 1.4285714285714286;
205
+ line-height: 21px;
207
206
  font-weight: 500;
208
- letter-spacing: -0.5px;
207
+ letter-spacing: 0;
208
+ padding: 0.5px 0px;
209
209
  display: inline-block;
210
210
  display: block;
211
211
  }
212
212
 
213
213
  .emotion-12::before {
214
214
  content: '';
215
+ margin-bottom: -0.391em;
215
216
  display: block;
216
- height: 0;
217
- width: 0;
218
- margin-bottom: -0.3955357142857143em;
219
217
  }
220
218
 
221
219
  .emotion-12::after {
222
220
  content: '';
221
+ margin-top: -0.409em;
223
222
  display: block;
224
- height: 0;
225
- width: 0;
226
- margin-top: -0.3955357142857143em;
227
223
  }
228
224
 
229
225
  .emotion-35 {
@@ -231,9 +227,9 @@ exports[`Footer tests should render footer 1`] = `
231
227
  color: #535353;
232
228
  font-family: "DM Sans",sans-serif;
233
229
  font-size: 14px;
234
- line-height: 1.4285714285714286;
230
+ line-height: 1.5;
235
231
  font-weight: 500;
236
- letter-spacing: -0.5px;
232
+ letter-spacing: 0;
237
233
  }
238
234
 
239
235
  .emotion-35 svg {
@@ -37,7 +37,7 @@ describe('Header tests', () => {
37
37
 
38
38
  test('render links', () => {
39
39
  const { getByLabelText } = renderWithTheme(Header)
40
- expect(getByLabelText('Home Page')).toHaveAttribute('href', '/')
40
+ expect(getByLabelText('Logo Link')).toHaveAttribute('href', '/')
41
41
  expect(getByLabelText('Section One Link')).toHaveAttribute(
42
42
  'href',
43
43
  '/section-one'
@@ -10,9 +10,16 @@ import {
10
10
  Stack,
11
11
  Block,
12
12
  IconFilledMenu,
13
+ Image,
13
14
  } from 'newskit'
14
15
  import { PastDueBannerExternal } from '@newskit-render/my-account'
15
- import { NextLink } from '@newskit-render/shared-components'
16
+ import {
17
+ NextLink,
18
+ theSunTheme,
19
+ timesTheme,
20
+ virginRadioTheme,
21
+ ThemeDropdown,
22
+ } from '@newskit-render/shared-components'
16
23
  import {
17
24
  renderCustomLightTheme as LightTheme,
18
25
  renderCustomDarkTheme as DarkTheme,
@@ -22,7 +29,6 @@ import NewsKitLogoFull from '../common/NewskitLogo'
22
29
  import NewsKitLogoShort from '../common/NewskitLogoShort'
23
30
  import NavLink from '../common/NavLink'
24
31
  import { AppContext } from '../../app-context/AppContext'
25
- import { getKey } from '../../helpers/articleUtil'
26
32
  import { handleEnterKeyPress } from '../../helpers/a11y'
27
33
  import { UserData, VxInstance } from '../../helpers/global-types'
28
34
 
@@ -30,7 +36,7 @@ export const headerSize = 'sizing090'
30
36
 
31
37
  const StyledHeader = styled.div`
32
38
  ${getSizingCssFromTheme('height', headerSize)}
33
- ${getColorCssFromTheme('backgroundColor', 'neutral100')};
39
+ ${getColorCssFromTheme('backgroundColor', 'customInterfaceBrand')};
34
40
  a,
35
41
  a:visited:not(:disabled) {
36
42
  ${getColorCssFromTheme('color', 'white')};
@@ -54,21 +60,25 @@ const StyledHeader = styled.div`
54
60
  const pastDueBanner = {
55
61
  firstNotice: {
56
62
  title: "We haven't been able to take payment",
57
- text: 'You may need to update your payment details to keep your subscription.',
63
+ text:
64
+ 'You may need to update your payment details to keep your subscription.',
58
65
  button: 'Update payment details',
59
66
  },
60
67
  secondNotice: {
61
68
  title: 'Act now to keep your subscription',
62
- text: 'We’ve tried several times, but haven’t been able to take payment. Please update your payment details to keep your subscription.',
69
+ text:
70
+ 'We’ve tried several times, but haven’t been able to take payment. Please update your payment details to keep your subscription.',
63
71
  button: 'Update payment details',
64
72
  },
65
73
  terminated: {
66
74
  title: 'Your subscription has been terminated',
67
- text: 'We didn’t receive payment for your subscription. To reactivate it, please call 0800 018 5177.',
75
+ text:
76
+ 'We didn’t receive payment for your subscription. To reactivate it, please call 0800 018 5177.',
68
77
  },
69
78
  cancelled: {
70
79
  title: 'Your subscription has been cancelled.',
71
- text: 'You’ll no longer have access to subscription benefits. To re-activate call 0800 555 1234.',
80
+ text:
81
+ 'You’ll no longer have access to subscription benefits. To re-activate call 0800 555 1234.',
72
82
  },
73
83
  treshold: {
74
84
  firstNotice: 26,
@@ -147,21 +157,13 @@ const NavButton = ({
147
157
  </Block>
148
158
  )
149
159
 
150
- const ThemeDropdown = ({ options }) => {
151
- const { theme, setTheme } = useContext(AppContext)
152
-
153
- return (
154
- <select
155
- value={getKey(options, theme)}
156
- onChange={(e) => setTheme(options[e.target.value])}
157
- >
158
- {Object.keys(options).map((o) => (
159
- <option key={o} value={o}>
160
- {o}
161
- </option>
162
- ))}
163
- </select>
164
- )
160
+ const clientNavigationLogos = {
161
+ 'The-Sun': { src: 'navigationPrimary-brandMark-sun.svg', width: '115px' },
162
+ 'Virgin-Radio': { src: 'navigationPrimary-brandMark-vr.svg', width: '150px' },
163
+ 'The-Times': {
164
+ src: 'navigationPrimary-brandMark-times.svg',
165
+ width: '150px',
166
+ },
165
167
  }
166
168
 
167
169
  const Header: React.FC<{ user: UserData }> = ({ user }) => {
@@ -170,6 +172,8 @@ const Header: React.FC<{ user: UserData }> = ({ user }) => {
170
172
  setShowMenu(!showMenu)
171
173
  document.body.style.overflow = showMenu ? '' : 'hidden'
172
174
  }
175
+ const { theme, setTheme } = useContext(AppContext)
176
+
173
177
  return (
174
178
  <>
175
179
  <StyledHeader>
@@ -184,14 +188,30 @@ const Header: React.FC<{ user: UserData }> = ({ user }) => {
184
188
  type="standalone"
185
189
  overrides={{ stylePreset: 'linkStandaloneInverse' }}
186
190
  href="/"
187
- aria-label="Home Page"
191
+ aria-label="Logo Link"
188
192
  >
189
- <Visible md lg xl>
190
- <NewsKitLogoFull color="white" size="sizing120" />
191
- </Visible>
192
- <Visible xs sm>
193
- <NewsKitLogoShort color="white" size="sizing120" />
194
- </Visible>
193
+ {!clientNavigationLogos[theme.name] ? (
194
+ <>
195
+ <Visible md lg xl>
196
+ <NewsKitLogoFull color="white" size="sizing120" />
197
+ </Visible>
198
+ <Visible xs sm>
199
+ <NewsKitLogoShort color="white" size="sizing120" />
200
+ </Visible>
201
+ </>
202
+ ) : (
203
+ <Block>
204
+ <Image
205
+ alt=""
206
+ src={`/MyAccount/${
207
+ clientNavigationLogos[theme.name].src
208
+ }`}
209
+ overrides={{
210
+ width: clientNavigationLogos[theme.name].width,
211
+ }}
212
+ />
213
+ </Block>
214
+ )}
195
215
  </NextLink>
196
216
  <Stack
197
217
  flow="horizontal-center"
@@ -242,7 +262,17 @@ const Header: React.FC<{ user: UserData }> = ({ user }) => {
242
262
  />
243
263
  </Block>
244
264
  </Visible>
245
- <ThemeDropdown options={{ LightTheme, DarkTheme }} />
265
+ <ThemeDropdown
266
+ theme={theme}
267
+ setTheme={setTheme}
268
+ options={{
269
+ LightTheme,
270
+ DarkTheme,
271
+ theSunTheme,
272
+ timesTheme,
273
+ virginRadioTheme,
274
+ }}
275
+ />
246
276
  </Stack>
247
277
  </Stack>
248
278
  </Cell>
@@ -34,18 +34,22 @@ describe('ArticleSlice', () => {
34
34
  })
35
35
 
36
36
  test('Handle SECONDARY_4 article-block Index Page', () => {
37
- const { getByTestId, getAllByTestId, getAllByRole, queryByTestId } =
38
- renderWithTheme(SectionContext.Provider, {
39
- value: {
40
- isIndexPage: true,
41
- },
42
- children: (
43
- <ArticleSlice
44
- slice={getPageMock.page.body[0].children[1]}
45
- collection={getPageMock.page.body[0]}
46
- />
47
- ),
48
- })
37
+ const {
38
+ getByTestId,
39
+ getAllByTestId,
40
+ getAllByRole,
41
+ queryByTestId,
42
+ } = renderWithTheme(SectionContext.Provider, {
43
+ value: {
44
+ isIndexPage: true,
45
+ },
46
+ children: (
47
+ <ArticleSlice
48
+ slice={getPageMock.page.body[0].children[1]}
49
+ collection={getPageMock.page.body[0]}
50
+ />
51
+ ),
52
+ })
49
53
  expect(queryByTestId('SectionTitleBar')).not.toBeInTheDocument()
50
54
  expect(getByTestId('SECONDARY_4-Grid')).toBeInTheDocument()
51
55
  expect(getAllByTestId(/titleTeaserVertical-/).length).toEqual(4)
@@ -67,18 +71,22 @@ describe('ArticleSlice', () => {
67
71
  })
68
72
 
69
73
  test('Handle SECONDARY_4_ODD article-block Index Page', () => {
70
- const { getByTestId, getAllByTestId, getAllByRole, queryByTestId } =
71
- renderWithTheme(SectionContext.Provider, {
72
- value: {
73
- isIndexPage: true,
74
- },
75
- children: (
76
- <ArticleSlice
77
- slice={getPageMock.page.body[0].children[5]}
78
- collection={getPageMock.page.body[0]}
79
- />
80
- ),
81
- })
74
+ const {
75
+ getByTestId,
76
+ getAllByTestId,
77
+ getAllByRole,
78
+ queryByTestId,
79
+ } = renderWithTheme(SectionContext.Provider, {
80
+ value: {
81
+ isIndexPage: true,
82
+ },
83
+ children: (
84
+ <ArticleSlice
85
+ slice={getPageMock.page.body[0].children[5]}
86
+ collection={getPageMock.page.body[0]}
87
+ />
88
+ ),
89
+ })
82
90
  expect(getByTestId('SectionTitleBar')).toBeInTheDocument()
83
91
  expect(queryByTestId('addTopSpace')).toBeInTheDocument()
84
92
  expect(getByTestId('SECONDARY_4_ODD-Grid')).toBeInTheDocument()
@@ -235,7 +235,6 @@ exports[`Lead 1`] = `
235
235
 
236
236
  .emotion-11 {
237
237
  margin: 0;
238
- padding: 1px 0;
239
238
  color: #0A0A0A;
240
239
  }
241
240
 
@@ -247,25 +246,22 @@ exports[`Lead 1`] = `
247
246
  .emotion-11 {
248
247
  font-family: "Bitter",serif;
249
248
  font-size: 24px;
250
- line-height: 1.1666666666666667;
249
+ line-height: 27px;
251
250
  font-weight: 500;
252
- letter-spacing: -0.5px;
251
+ letter-spacing: 0;
252
+ padding: 0.5px 0px;
253
253
  }
254
254
 
255
255
  .emotion-11::before {
256
256
  content: '';
257
+ margin-bottom: -0.2055em;
257
258
  display: block;
258
- height: 0;
259
- width: 0;
260
- margin-bottom: -0.2333333333333334em;
261
259
  }
262
260
 
263
261
  .emotion-11::after {
264
262
  content: '';
263
+ margin-top: -0.2275em;
265
264
  display: block;
266
- height: 0;
267
- width: 0;
268
- margin-top: -0.2958333333333334em;
269
265
  }
270
266
  }
271
267
 
@@ -273,25 +269,22 @@ exports[`Lead 1`] = `
273
269
  .emotion-11 {
274
270
  font-family: "Bitter",serif;
275
271
  font-size: 36px;
276
- line-height: 1.1111111111111112;
272
+ line-height: 40.5px;
277
273
  font-weight: 500;
278
- letter-spacing: -0.5px;
274
+ letter-spacing: 0;
275
+ padding: 0.5px 0px;
279
276
  }
280
277
 
281
278
  .emotion-11::before {
282
279
  content: '';
280
+ margin-bottom: -0.2055em;
283
281
  display: block;
284
- height: 0;
285
- width: 0;
286
- margin-bottom: -0.2055555555555556em;
287
282
  }
288
283
 
289
284
  .emotion-11::after {
290
285
  content: '';
286
+ margin-top: -0.2275em;
291
287
  display: block;
292
- height: 0;
293
- width: 0;
294
- margin-top: -0.2680555555555556em;
295
288
  }
296
289
  }
297
290
 
@@ -299,25 +292,22 @@ exports[`Lead 1`] = `
299
292
  .emotion-11 {
300
293
  font-family: "Bitter",serif;
301
294
  font-size: 40px;
302
- line-height: 1.2;
295
+ line-height: 45px;
303
296
  font-weight: 500;
304
- letter-spacing: -0.5px;
297
+ letter-spacing: 0;
298
+ padding: 0.5px 0px;
305
299
  }
306
300
 
307
301
  .emotion-11::before {
308
302
  content: '';
303
+ margin-bottom: -0.2055em;
309
304
  display: block;
310
- height: 0;
311
- width: 0;
312
- margin-bottom: -0.25em;
313
305
  }
314
306
 
315
307
  .emotion-11::after {
316
308
  content: '';
309
+ margin-top: -0.2275em;
317
310
  display: block;
318
- height: 0;
319
- width: 0;
320
- margin-top: -0.3125em;
321
311
  }
322
312
  }
323
313
 
@@ -469,7 +459,6 @@ exports[`Lead 1`] = `
469
459
 
470
460
  .emotion-24 {
471
461
  margin: 0;
472
- padding: 1px 0;
473
462
  color: #0A0A0A;
474
463
  }
475
464
 
@@ -481,25 +470,22 @@ exports[`Lead 1`] = `
481
470
  .emotion-24 {
482
471
  font-family: "Bitter",serif;
483
472
  font-size: 24px;
484
- line-height: 1.1666666666666667;
473
+ line-height: 27px;
485
474
  font-weight: 500;
486
- letter-spacing: -0.5px;
475
+ letter-spacing: 0;
476
+ padding: 0.5px 0px;
487
477
  }
488
478
 
489
479
  .emotion-24::before {
490
480
  content: '';
481
+ margin-bottom: -0.2055em;
491
482
  display: block;
492
- height: 0;
493
- width: 0;
494
- margin-bottom: -0.2333333333333334em;
495
483
  }
496
484
 
497
485
  .emotion-24::after {
498
486
  content: '';
487
+ margin-top: -0.2275em;
499
488
  display: block;
500
- height: 0;
501
- width: 0;
502
- margin-top: -0.2958333333333334em;
503
489
  }
504
490
  }
505
491
 
@@ -507,25 +493,22 @@ exports[`Lead 1`] = `
507
493
  .emotion-24 {
508
494
  font-family: "Bitter",serif;
509
495
  font-size: 28px;
510
- line-height: 1.1428571428571428;
496
+ line-height: 31.5px;
511
497
  font-weight: 500;
512
- letter-spacing: -0.5px;
498
+ letter-spacing: 0;
499
+ padding: 0.5px 0px;
513
500
  }
514
501
 
515
502
  .emotion-24::before {
516
503
  content: '';
504
+ margin-bottom: -0.2055em;
517
505
  display: block;
518
- height: 0;
519
- width: 0;
520
- margin-bottom: -0.22142857142857142em;
521
506
  }
522
507
 
523
508
  .emotion-24::after {
524
509
  content: '';
510
+ margin-top: -0.2275em;
525
511
  display: block;
526
- height: 0;
527
- width: 0;
528
- margin-top: -0.2839285714285714em;
529
512
  }
530
513
  }
531
514
 
@@ -533,25 +516,22 @@ exports[`Lead 1`] = `
533
516
  .emotion-24 {
534
517
  font-family: "Bitter",serif;
535
518
  font-size: 32px;
536
- line-height: 1.125;
519
+ line-height: 36px;
537
520
  font-weight: 500;
538
- letter-spacing: -0.5px;
521
+ letter-spacing: 0;
522
+ padding: 0.5px 0px;
539
523
  }
540
524
 
541
525
  .emotion-24::before {
542
526
  content: '';
527
+ margin-bottom: -0.2055em;
543
528
  display: block;
544
- height: 0;
545
- width: 0;
546
- margin-bottom: -0.21250000000000002em;
547
529
  }
548
530
 
549
531
  .emotion-24::after {
550
532
  content: '';
533
+ margin-top: -0.2275em;
551
534
  display: block;
552
- height: 0;
553
- width: 0;
554
- margin-top: -0.275em;
555
535
  }
556
536
  }
557
537