@newskit-render/core 1.66.0 → 1.68.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 (51) hide show
  1. package/CHANGELOG.md +133 -0
  2. package/README.md +16 -0
  3. package/__tests__/pages/[articleSlug].test.tsx +1 -55
  4. package/__tests__/pages/__snapshots__/home.test.tsx.snap +657 -626
  5. package/__tests__/pages/__snapshots__/relatedArticles.test.tsx.snap +651 -0
  6. package/__tests__/pages/relatedArticles.test.tsx +23 -11
  7. package/components/article/__tests__/__snapshots__/index.test.tsx.snap +1091 -1060
  8. package/components/footer/index.tsx +1 -1
  9. package/components/header/banner-messages.ts +45 -0
  10. package/components/header/index.tsx +31 -287
  11. package/components/header/navigation-links.ts +20 -0
  12. package/components/layout/LayoutTemplate.tsx +4 -1
  13. package/config/__tests__/index.test.ts +53 -0
  14. package/config/environment.ts +67 -0
  15. package/config/index.ts +2 -85
  16. package/config/multiTenancy.ts +12 -0
  17. package/{app-context → context/app-context}/AppContext.test.tsx +7 -3
  18. package/{app-context/AppContext.tsx → context/app-context/index.tsx} +5 -1
  19. package/context/index.tsx +2 -0
  20. package/context/multi-tenancy/MultiTenancy.test.tsx +47 -0
  21. package/context/multi-tenancy/index.tsx +31 -0
  22. package/css/index.ts +224 -0
  23. package/cypress/support/commands.js +8 -4
  24. package/helpers/__tests__/createThemeDropdownObject.test.ts +3 -3
  25. package/helpers/__tests__/getRecommendation.test.ts +62 -0
  26. package/helpers/createThemeDropdownObject.ts +3 -3
  27. package/helpers/getRecommendations.ts +29 -0
  28. package/helpers/global-types.ts +8 -0
  29. package/{__tests__/pages/mocks.ts → helpers/mocks/getRecommendationsMock.ts} +2 -6
  30. package/helpers/multiTenancy.ts +19 -0
  31. package/jest.config.js +1 -2
  32. package/package.json +11 -9
  33. package/pages/[section]/[articleId]/[articleSlug].tsx +17 -10
  34. package/pages/[section]/[articleId]/relatedArticles.tsx +49 -40
  35. package/pages/_app.tsx +42 -257
  36. package/pages/account/cancellation/index.tsx +1 -1
  37. package/pages/account/edit/[field].tsx +1 -1
  38. package/pages/account/index.tsx +1 -1
  39. package/pages/account/newsletters-and-alerts/index.tsx +1 -1
  40. package/pages/account/payment/index.tsx +1 -1
  41. package/pages/account/subscription-and-billing/index.tsx +1 -1
  42. package/pages/api/auth/[...nextauth].ts +5 -1
  43. package/pages/api/recommendations/[...slug].ts +21 -0
  44. package/pages/checkout/account-creation/index.tsx +1 -1
  45. package/pages/checkout/payment-details/index.tsx +1 -1
  46. package/pages/help-hub/[id]/index.tsx +22 -9
  47. package/pages/help-hub/index.tsx +22 -9
  48. package/pages/help-hub/results.tsx +24 -0
  49. package/theme/strings/demo.ts +1 -0
  50. package/theme/strings/index.ts +1 -0
  51. package/components/header/index.test.tsx +0 -73
@@ -1,12 +1,21 @@
1
- import { recommendationsProvider } from '@newskit-render/standalone-components'
2
- import {
1
+ import { act } from '@testing-library/react'
2
+ import RelatedArticlesPage, {
3
3
  RelatedArticles,
4
4
  getServerSideProps,
5
5
  } from '../../pages/[section]/[articleId]/relatedArticles'
6
- import { mockArticles } from './mocks'
7
6
 
7
+ import { renderWithTheme } from '../../helpers/test-utils'
8
+ import { recomendationsMock } from '../../helpers/mocks/getRecommendationsMock'
9
+
10
+ jest.mock('../../helpers/getRecommendations', () => {
11
+ return {
12
+ fetcher: jest.fn().mockImplementationOnce(() => {
13
+ return recomendationsMock
14
+ }),
15
+ }
16
+ })
8
17
  const props: RelatedArticles = {
9
- recommendations: mockArticles,
18
+ articleId: 'test-1',
10
19
  }
11
20
 
12
21
  const user = {
@@ -39,12 +48,6 @@ jest.mock('@newskit-render/api', () => ({
39
48
  },
40
49
  }))
41
50
 
42
- jest.mock('@newskit-render/standalone-components', () => {
43
- return {
44
- recommendationsProvider: jest.fn(),
45
- }
46
- })
47
-
48
51
  describe('Article', () => {
49
52
  describe('getServerSideProps', () => {
50
53
  beforeAll(() => {
@@ -53,7 +56,6 @@ describe('Article', () => {
53
56
  TWITTER_USERNAME: 'D_Trump',
54
57
  GSC_ID: '4320982',
55
58
  })
56
- recommendationsProvider.mockResolvedValueOnce(mockArticles)
57
59
  })
58
60
 
59
61
  it('should return props', async () => {
@@ -74,3 +76,13 @@ describe('Article', () => {
74
76
  })
75
77
  })
76
78
  })
79
+
80
+ describe('Recommendation', () => {
81
+ it('render page', async () => {
82
+ let result
83
+ await act(async () => {
84
+ result = renderWithTheme(RelatedArticlesPage)
85
+ })
86
+ expect(result.asFragment()).toMatchSnapshot()
87
+ })
88
+ })