@newskit-render/core 1.49.2 → 1.59.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 (52) hide show
  1. package/CHANGELOG.md +195 -0
  2. package/__tests__/pages/[articleSlug].test.tsx +12 -8
  3. package/__tests__/pages/__snapshots__/brightcove.test.tsx.snap +20 -0
  4. package/__tests__/pages/__snapshots__/home.test.tsx.snap +241 -1846
  5. package/__tests__/pages/brightcove.test.tsx +34 -0
  6. package/__tests__/pages/home.test.tsx +22 -12
  7. package/__tests__/pages/mocks.ts +29 -0
  8. package/__tests__/pages/relatedArticles.test.tsx +76 -0
  9. package/components/article/RelatedArticles.tsx +48 -55
  10. package/components/article/__tests__/__snapshots__/index.test.tsx.snap +414 -3366
  11. package/components/article/__tests__/index.test.tsx +46 -2
  12. package/components/article/index.tsx +28 -15
  13. package/components/common/BackToHomepage.tsx +36 -0
  14. package/components/footer/__snapshots__/index.test.tsx.snap +37 -271
  15. package/components/header/index.tsx +7 -0
  16. package/components/section/index.tsx +2 -0
  17. package/components/section/layouts/Rows.tsx +36 -17
  18. package/components/section/layouts/__tests__/Rows.test.tsx +12 -0
  19. package/components/section/layouts/__tests__/__snapshots__/Lead.test.tsx.snap +36 -530
  20. package/components/section/layouts/__tests__/__snapshots__/SectionTitle.test.tsx.snap +42 -766
  21. package/components/section/layouts/types.ts +3 -0
  22. package/config/index.ts +85 -0
  23. package/constants/index.ts +3 -1
  24. package/cypress/e2e/account/accessibility.spec.js +14 -17
  25. package/cypress/e2e/account/account-subscription.spec.js +9 -8
  26. package/cypress/e2e/account/payment-failer.spec.js +3 -3
  27. package/cypress/support/commands.js +2 -2
  28. package/helpers/__tests__/getUser.test.ts +7 -8
  29. package/helpers/logger.ts +3 -1
  30. package/helpers/mocks/articleMock.ts +1 -1
  31. package/helpers/mocks/getUniversalArticleMock.ts +13 -0
  32. package/helpers/setupTests.ts +4 -0
  33. package/infrastructure/.circleci/config.yml +1 -0
  34. package/jest.config.js +22 -19
  35. package/package.json +11 -11
  36. package/pages/[section]/[articleId]/[articleSlug].tsx +9 -4
  37. package/pages/[section]/[articleId]/relatedArticles.tsx +85 -0
  38. package/pages/_app.tsx +4 -3
  39. package/pages/_document.tsx +17 -18
  40. package/pages/api/auth/[...nextauth].ts +2 -3
  41. package/pages/api/feed.ts +7 -3
  42. package/pages/api/news-sitemap.ts +4 -6
  43. package/pages/api/sitemap.ts +10 -7
  44. package/pages/help-hub/[id]/index.tsx +11 -0
  45. package/pages/help-hub/index.tsx +11 -0
  46. package/pages/index.tsx +1 -1
  47. package/pages/player/brightcove.tsx +19 -0
  48. package/pages/preview/[articleId]/version/[versionId]/index.tsx +9 -4
  49. package/public/icon.png +0 -0
  50. package/queries/getRadioPosts.ts +1 -1
  51. package/queries/getUniversalArticle.ts +13 -0
  52. package/temp/header.tsx +7 -0
@@ -1,30 +1,49 @@
1
1
  import React from 'react'
2
2
  import { Block, GridLayout } from 'newskit'
3
+ import { ArticleRecommendation } from '@newskit-render/standalone-components'
3
4
  import { LayoutProps } from './types'
4
5
  import { outerGridOverride } from './gridUtils'
5
6
  import { getBlock } from './Block'
6
7
 
7
8
  export const BasicRow: React.FC<LayoutProps> = ({
8
9
  slice,
10
+ articles,
9
11
  colums,
10
12
  variant = 'titleTeaserVertical',
11
- }) => (
12
- <GridLayout
13
- columns={colums}
14
- columnGap="space050"
15
- data-testid={`${slice.name}-Grid`}
16
- {...outerGridOverride}
17
- >
18
- {slice.children.map((block, i) => (
19
- <Block
20
- key={('article' in block && block.article.id) || i}
21
- data-testid={`titleTeaserVertical-${i}`}
22
- >
23
- {getBlock(block, variant)}
24
- </Block>
25
- ))}
26
- </GridLayout>
27
- )
13
+ 'data-testid': testid,
14
+ }) => {
15
+ const dataTestid =
16
+ (testid && testid) || (slice && `${slice.name}-Grid`) || 'Articles-Grid'
17
+ return (
18
+ <GridLayout
19
+ columns={colums}
20
+ columnGap="space050"
21
+ data-testid={dataTestid}
22
+ {...outerGridOverride}
23
+ >
24
+ {articles
25
+ ? articles.map((article, i) => (
26
+ /* eslint-disable-next-line */
27
+ <Block
28
+ spaceStack="space050"
29
+ key={article.title}
30
+ data-testid={`articleRec-${i}`}
31
+ >
32
+ <ArticleRecommendation article={article} size="large" />
33
+ </Block>
34
+ ))
35
+ : slice.children.map((block, i) => (
36
+ /* eslint-disable-next-line */
37
+ <Block
38
+ key={'article' in block ? block.article.id : i}
39
+ data-testid={`titleTeaserVertical-${i}`}
40
+ >
41
+ {getBlock(block, variant)}
42
+ </Block>
43
+ ))}
44
+ </GridLayout>
45
+ )
46
+ }
28
47
 
29
48
  export const Row3: React.FC<LayoutProps> = ({ slice }) => (
30
49
  <GridLayout
@@ -2,6 +2,7 @@ import { renderWithTheme } from '../../../../helpers/test-utils'
2
2
  import { BasicRow, Row3 } from '../Rows'
3
3
  import { getPageMock } from '../../../../helpers/mocks'
4
4
  import { ArticleSlice } from '../../../../helpers/global-types'
5
+ import { relatedArticles } from '../../../../helpers/mocks/articleMock'
5
6
 
6
7
  describe('Rows', () => {
7
8
  test('should render a row with 2 columns', () => {
@@ -25,4 +26,15 @@ describe('Rows', () => {
25
26
 
26
27
  expect(getAllByTestId(/titleTeaserVertical-/).length).toEqual(3)
27
28
  })
29
+
30
+ describe('Recommended articles', () => {
31
+ test('should render with recommended articles', () => {
32
+ const { getAllByTestId } = renderWithTheme(BasicRow, {
33
+ articles: relatedArticles,
34
+ colums: { xs: '1fr', md: '1fr 1fr', lg: '1fr 1fr 1fr' },
35
+ })
36
+
37
+ expect(getAllByTestId(/articleRec-/).length).toEqual(4)
38
+ })
39
+ })
28
40
  })