@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
@@ -0,0 +1,24 @@
1
+ import React, { useContext } from 'react'
2
+ import { ResultsPage } from '@newskit-render/standalone-components'
3
+ import { createThemeDropdownObject } from '../../helpers/createThemeDropdownObject'
4
+ import { AppContext } from '../../context'
5
+
6
+ const HelpHubResultsPage = (props) => {
7
+ const { theme, setTheme } = useContext(AppContext)
8
+ const themeDropdownObject = createThemeDropdownObject(setTheme)
9
+
10
+ return (
11
+ <ResultsPage
12
+ {...props}
13
+ contextName="resultsPage"
14
+ customTheme={theme}
15
+ themeDropdownObject={themeDropdownObject}
16
+ />
17
+ )
18
+ }
19
+
20
+ export default HelpHubResultsPage
21
+
22
+ // export const getServerSideProps = async (context) => {
23
+ // return getProviderProps({ ...context, provider: '' })
24
+ // }
@@ -0,0 +1 @@
1
+ export const demo = {}
@@ -0,0 +1 @@
1
+ export * from './demo'
@@ -1,73 +0,0 @@
1
- import { fireEvent } from '@testing-library/react'
2
- import { renderWithTheme } from '../../helpers/test-utils'
3
- import Header from '.'
4
-
5
- jest.mock('@newskit-render/shared-components', () => {
6
- return {
7
- // @ts-ignore
8
- ...jest.requireActual('@newskit-render/shared-components'),
9
- PastDueBannerExternal: 'PastDueBannerExternal',
10
- }
11
- })
12
-
13
- describe('Header tests', () => {
14
- test('should open and close mobile menu', () => {
15
- const { getByTestId, queryByTestId } = renderWithTheme(Header)
16
- expect(getByTestId('mobile-menu-btn')).toBeInTheDocument()
17
- expect(queryByTestId('mobile-block-space')).not.toBeInTheDocument()
18
- fireEvent.click(getByTestId('mobile-menu-btn'))
19
- expect(getByTestId('mobile-block-space')).toBeInTheDocument()
20
- fireEvent.click(getByTestId('mobile-menu-btn'))
21
- expect(queryByTestId('mobile-block-space')).not.toBeInTheDocument()
22
- })
23
-
24
- test('should open and close mobile menu with keypress', () => {
25
- const { getByTestId, queryByTestId } = renderWithTheme(Header)
26
- expect(getByTestId('mobile-menu-btn')).toBeInTheDocument()
27
- expect(queryByTestId('mobile-block-space')).not.toBeInTheDocument()
28
- fireEvent.keyDown(getByTestId('mobile-menu-btn'), {
29
- key: 'Enter',
30
- code: 'Enter',
31
- })
32
- expect(getByTestId('mobile-block-space')).toBeInTheDocument()
33
- fireEvent.keyDown(getByTestId('mobile-menu-btn'), {
34
- key: 'Enter',
35
- code: 'Enter',
36
- })
37
- expect(queryByTestId('mobile-block-space')).not.toBeInTheDocument()
38
- })
39
-
40
- test('render links', () => {
41
- const { getByLabelText } = renderWithTheme(Header)
42
- expect(getByLabelText('Logo Link')).toHaveAttribute('href', '/')
43
- expect(getByLabelText('Section One Link')).toHaveAttribute(
44
- 'href',
45
- '/section-one'
46
- )
47
- expect(getByLabelText('Section Two Link')).toHaveAttribute(
48
- 'href',
49
- '/section-two'
50
- )
51
- expect(getByLabelText('Section Three Link')).toHaveAttribute(
52
- 'href',
53
- '/section-three'
54
- )
55
- })
56
-
57
- test('render Account link if there is user data', () => {
58
- const user = {
59
- firstName: '',
60
- lastName: '',
61
- cpn: '',
62
- email: '',
63
- hash: '',
64
- mobile: '',
65
- phoneNumber: '',
66
- dateOfBirth: '',
67
- subscriptions: [],
68
- paymentFailure: { active: false },
69
- }
70
- const { getByTestId } = renderWithTheme(Header, { user })
71
- expect(getByTestId('account-link')).toBeInTheDocument()
72
- })
73
- })