@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.
- package/CHANGELOG.md +133 -0
- package/README.md +16 -0
- package/__tests__/pages/[articleSlug].test.tsx +1 -55
- package/__tests__/pages/__snapshots__/home.test.tsx.snap +657 -626
- package/__tests__/pages/__snapshots__/relatedArticles.test.tsx.snap +651 -0
- package/__tests__/pages/relatedArticles.test.tsx +23 -11
- package/components/article/__tests__/__snapshots__/index.test.tsx.snap +1091 -1060
- package/components/footer/index.tsx +1 -1
- package/components/header/banner-messages.ts +45 -0
- package/components/header/index.tsx +31 -287
- package/components/header/navigation-links.ts +20 -0
- package/components/layout/LayoutTemplate.tsx +4 -1
- package/config/__tests__/index.test.ts +53 -0
- package/config/environment.ts +67 -0
- package/config/index.ts +2 -85
- package/config/multiTenancy.ts +12 -0
- package/{app-context → context/app-context}/AppContext.test.tsx +7 -3
- package/{app-context/AppContext.tsx → context/app-context/index.tsx} +5 -1
- package/context/index.tsx +2 -0
- package/context/multi-tenancy/MultiTenancy.test.tsx +47 -0
- package/context/multi-tenancy/index.tsx +31 -0
- package/css/index.ts +224 -0
- package/cypress/support/commands.js +8 -4
- package/helpers/__tests__/createThemeDropdownObject.test.ts +3 -3
- package/helpers/__tests__/getRecommendation.test.ts +62 -0
- package/helpers/createThemeDropdownObject.ts +3 -3
- package/helpers/getRecommendations.ts +29 -0
- package/helpers/global-types.ts +8 -0
- package/{__tests__/pages/mocks.ts → helpers/mocks/getRecommendationsMock.ts} +2 -6
- package/helpers/multiTenancy.ts +19 -0
- package/jest.config.js +1 -2
- package/package.json +11 -9
- package/pages/[section]/[articleId]/[articleSlug].tsx +17 -10
- package/pages/[section]/[articleId]/relatedArticles.tsx +49 -40
- package/pages/_app.tsx +42 -257
- package/pages/account/cancellation/index.tsx +1 -1
- package/pages/account/edit/[field].tsx +1 -1
- package/pages/account/index.tsx +1 -1
- package/pages/account/newsletters-and-alerts/index.tsx +1 -1
- package/pages/account/payment/index.tsx +1 -1
- package/pages/account/subscription-and-billing/index.tsx +1 -1
- package/pages/api/auth/[...nextauth].ts +5 -1
- package/pages/api/recommendations/[...slug].ts +21 -0
- package/pages/checkout/account-creation/index.tsx +1 -1
- package/pages/checkout/payment-details/index.tsx +1 -1
- package/pages/help-hub/[id]/index.tsx +22 -9
- package/pages/help-hub/index.tsx +22 -9
- package/pages/help-hub/results.tsx +24 -0
- package/theme/strings/demo.ts +1 -0
- package/theme/strings/index.ts +1 -0
- package/components/header/index.test.tsx +0 -73
|
@@ -1,12 +1,21 @@
|
|
|
1
|
-
import {
|
|
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
|
-
|
|
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
|
+
})
|