@newskit-render/core 1.45.0 → 1.49.0

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 (34) hide show
  1. package/CHANGELOG.md +96 -0
  2. package/__tests__/pages/__snapshots__/home.test.tsx.snap +769 -1261
  3. package/components/section/ArticleSlice.tsx +17 -43
  4. package/components/section/CollectionBlock.tsx +38 -6
  5. package/components/section/__tests__/ArticleSlice.test.tsx +37 -51
  6. package/components/section/__tests__/CollectionBlock.test.tsx +63 -13
  7. package/components/section/__tests__/pageBlock.test.tsx +8 -4
  8. package/components/section/index.tsx +17 -12
  9. package/components/section/layouts/Lead.tsx +36 -15
  10. package/components/section/layouts/Rows.tsx +67 -0
  11. package/components/section/layouts/{SectionRow.tsx → SectionTitle.tsx} +24 -52
  12. package/components/section/layouts/__tests__/Lead.test.tsx +31 -6
  13. package/components/section/layouts/__tests__/Rows.test.tsx +28 -0
  14. package/components/section/layouts/__tests__/SectionTitle.test.tsx +36 -0
  15. package/components/section/layouts/__tests__/__snapshots__/Lead.test.tsx.snap +274 -315
  16. package/components/section/layouts/__tests__/__snapshots__/SectionTitle.test.tsx.snap +942 -0
  17. package/components/section/layouts/gridUtils.ts +12 -9
  18. package/components/section/layouts/index.tsx +2 -1
  19. package/components/section/layouts/types.ts +5 -1
  20. package/components/section/{pageBlock.ts → pageBlock.tsx} +5 -2
  21. package/components/teaser/index.tsx +7 -6
  22. package/components/teaser/teaserVariants.ts +2 -0
  23. package/components/teaser/variants/horizontal.ts +14 -0
  24. package/cypress/e2e/account/account-subscription.spec.js +2 -2
  25. package/cypress/support/commands.js +2 -2
  26. package/helpers/mocks/getPageMock.ts +2 -59
  27. package/next.config.js +4 -0
  28. package/package.json +16 -10
  29. package/pages/account/cancellation/index.tsx +2 -0
  30. package/pages/api/feed.ts +19 -0
  31. package/theme/render-custom-theme.ts +1 -0
  32. package/components/section/layouts/Row.tsx +0 -28
  33. package/components/section/layouts/__tests__/SectionRow.test.tsx +0 -56
  34. package/components/section/layouts/__tests__/__snapshots__/SectionRow.test.tsx.snap +0 -4542
@@ -1,12 +1,37 @@
1
1
  import { renderWithTheme } from '../../../../helpers/test-utils'
2
- import { Lead } from '../Lead'
2
+ import { Lead, LeadFullWidth } from '../Lead'
3
3
  import { getPageMock } from '../../../../helpers/mocks'
4
4
  import { ArticleSlice } from '../../../../helpers/global-types'
5
5
 
6
- test('Lead', () => {
7
- const { asFragment } = renderWithTheme(Lead, {
8
- slice: getPageMock.page.body[0].children[0] as ArticleSlice,
9
- sectionURL: getPageMock.page.body[0].link.url,
6
+ describe('Lead', () => {
7
+ test('should render Lead', () => {
8
+ const { asFragment } = renderWithTheme(Lead, {
9
+ slice: getPageMock.page.body[0].children[0] as ArticleSlice,
10
+ })
11
+ expect(asFragment()).toMatchSnapshot()
12
+ })
13
+
14
+ test('should render Lead with cells', () => {
15
+ const { getAllByTestId, queryByTestId } = renderWithTheme(Lead, {
16
+ slice: getPageMock.page.body[0].children[0] as ArticleSlice,
17
+ })
18
+
19
+ expect(
20
+ queryByTestId('SUPPLEMENT_LEAD_AND_4_STACK-Grid')
21
+ ).toBeInTheDocument()
22
+ expect(queryByTestId('featureVerticalCell')).toBeInTheDocument()
23
+ expect(getAllByTestId(/titleVerticalCell-/).length).toEqual(2)
24
+ })
25
+ })
26
+
27
+ describe('Lead full width', () => {
28
+ test('should render Lead full width', () => {
29
+ const { queryByTestId } = renderWithTheme(LeadFullWidth, {
30
+ slice: getPageMock.page.body[0].children[0] as ArticleSlice,
31
+ })
32
+
33
+ expect(
34
+ queryByTestId('SUPPLEMENT_LEAD_AND_4_STACK-Grid')
35
+ ).toBeInTheDocument()
10
36
  })
11
- expect(asFragment()).toMatchSnapshot()
12
37
  })
@@ -0,0 +1,28 @@
1
+ import { renderWithTheme } from '../../../../helpers/test-utils'
2
+ import { BasicRow, Row3 } from '../Rows'
3
+ import { getPageMock } from '../../../../helpers/mocks'
4
+ import { ArticleSlice } from '../../../../helpers/global-types'
5
+
6
+ describe('Rows', () => {
7
+ test('should render a row with 2 columns', () => {
8
+ const slice = {
9
+ ...getPageMock.page.body[0].children[0],
10
+ children: getPageMock.page.body[0].children[0].children.slice(0, 2),
11
+ }
12
+ const { getAllByTestId } = renderWithTheme(BasicRow, {
13
+ slice: slice as ArticleSlice,
14
+ colums: { xs: '1fr', md: '1fr 1fr' },
15
+ })
16
+
17
+ expect(getAllByTestId(/titleTeaserVertical-/).length).toEqual(2)
18
+ })
19
+
20
+ test('should render a row with 3 columns', () => {
21
+ const { getAllByTestId } = renderWithTheme(Row3, {
22
+ slice: getPageMock.page.body[0].children[0] as ArticleSlice,
23
+ colums: { xs: '1fr', md: '1fr 1fr' },
24
+ })
25
+
26
+ expect(getAllByTestId(/titleTeaserVertical-/).length).toEqual(3)
27
+ })
28
+ })
@@ -0,0 +1,36 @@
1
+ import { renderWithTheme } from '../../../../helpers/test-utils'
2
+ import { SectionTitle } from '../SectionTitle'
3
+ import { getPageMock } from '../../../../helpers/mocks'
4
+ import { ArticleSlice } from '../../../../helpers/global-types'
5
+
6
+ describe('SectionTitle', () => {
7
+ test('SectionTitle with title', () => {
8
+ const { asFragment } = renderWithTheme(SectionTitle, {
9
+ slice: getPageMock.page.body[0].children[1] as ArticleSlice,
10
+ sectionURL: getPageMock.page.body[0].link.url,
11
+ title: getPageMock.page.body[0].title,
12
+ })
13
+ expect(asFragment()).toMatchSnapshot()
14
+ })
15
+
16
+ test('SectionTitle without extra space', () => {
17
+ const { asFragment } = renderWithTheme(SectionTitle, {
18
+ slice: getPageMock.page.body[0].children[1] as ArticleSlice,
19
+ sectionURL: getPageMock.page.body[0].link.url,
20
+ title: getPageMock.page.body[0].title,
21
+ addTopSpace: true,
22
+ })
23
+ expect(asFragment()).toMatchSnapshot()
24
+ })
25
+
26
+ test('SectionTitle alternative titlebar', () => {
27
+ const { asFragment } = renderWithTheme(SectionTitle, {
28
+ slice: getPageMock.page.body[0].children[1] as ArticleSlice,
29
+ sectionURL: getPageMock.page.body[0].link.url,
30
+ title: getPageMock.page.body[0].title,
31
+ titleBarStylePreset: 'inkContrast',
32
+ titleBarColour: 'transparent',
33
+ })
34
+ expect(asFragment()).toMatchSnapshot()
35
+ })
36
+ })