@newskit-render/core 4.23.29 → 4.24.0-alpha.1
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 +8 -0
- package/helpers/mocks/index.ts +0 -2
- package/package.json +2 -2
- package/queries/index.ts +0 -1
- package/__tests__/pages/[articleSlug].test.tsx +0 -185
- package/__tests__/pages/__snapshots__/[articleSlug].test.tsx.snap +0 -1280
- package/helpers/mocks/getUniversalArticleMock.ts +0 -88
- package/pages/[section]/[articleId]/[articleSlug].tsx +0 -104
- package/pages/preview/[articleId]/version/[versionId]/index.tsx +0 -159
- package/queries/getUniversalArticle.ts +0 -68
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [4.23.29](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/core@4.23.29-alpha.2...@newskit-render/core@4.23.29) (2024-04-17)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @newskit-render/core
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
## [4.23.28](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/core@4.23.28-alpha.0...@newskit-render/core@4.23.28) (2024-04-15)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @newskit-render/core
|
package/helpers/mocks/index.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import getRadioPosts from './getRadioPostsMock'
|
|
2
2
|
import getRadioPost from './getRadioPostMock'
|
|
3
3
|
import getPage from './getPageMock'
|
|
4
|
-
import getUniversalArticle from './getUniversalArticleMock'
|
|
5
4
|
|
|
6
5
|
export const getRadioPostsMock = getRadioPosts
|
|
7
6
|
export const getRadioPostMock = getRadioPost
|
|
8
7
|
export const getPageMock = getPage
|
|
9
|
-
export const getUniversalArticleMock = getUniversalArticle
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@newskit-render/core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.24.0-alpha.1",
|
|
4
4
|
"description": "Newskit Render - Core package",
|
|
5
5
|
"author": "",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@newskit-render/checkout": "^3.9.19",
|
|
48
48
|
"@newskit-render/feature-flags": "^1.7.0",
|
|
49
49
|
"@newskit-render/feed": "^1.8.5",
|
|
50
|
-
"@newskit-render/my-account": "^7.41.0",
|
|
50
|
+
"@newskit-render/my-account": "^7.41.1-alpha.0",
|
|
51
51
|
"@newskit-render/shared-components": "^4.22.0",
|
|
52
52
|
"@newskit-render/standalone-components": "^3.20.12",
|
|
53
53
|
"@newskit-render/validation": "^1.14.0",
|
package/queries/index.ts
CHANGED
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import useSWR from 'swr'
|
|
2
|
-
import { act } from '@testing-library/react'
|
|
3
|
-
import { recomendationsMock } from '../../helpers/mocks/getRecommendationsMock'
|
|
4
|
-
import Article, {
|
|
5
|
-
ArticleSlug,
|
|
6
|
-
getServerSideProps,
|
|
7
|
-
} from '../../pages/[section]/[articleId]/[articleSlug]'
|
|
8
|
-
import { renderWithTheme } from '../../helpers/test-utils'
|
|
9
|
-
import { URL, Slug } from '../../helpers/global-types'
|
|
10
|
-
|
|
11
|
-
const props: ArticleSlug = {
|
|
12
|
-
universalArticle: {
|
|
13
|
-
id: 'demo-1',
|
|
14
|
-
url: 'https://mock-site-url/some-location' as URL,
|
|
15
|
-
label: 'Mock label',
|
|
16
|
-
slug: 'some-location' as Slug,
|
|
17
|
-
publisher: 'DEMO',
|
|
18
|
-
headline:
|
|
19
|
-
'Mock Article: Lorem ipsum dolor sit amet consectetur adipiscing elit',
|
|
20
|
-
kicker: '',
|
|
21
|
-
authors: undefined,
|
|
22
|
-
flags: [],
|
|
23
|
-
topics: [
|
|
24
|
-
{
|
|
25
|
-
name: 'Some topic one',
|
|
26
|
-
slug: 'some-topic-one',
|
|
27
|
-
link: undefined,
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
name: 'Some topic one',
|
|
31
|
-
slug: 'some-topic-one',
|
|
32
|
-
link: undefined,
|
|
33
|
-
},
|
|
34
|
-
],
|
|
35
|
-
template: undefined,
|
|
36
|
-
bylines: [
|
|
37
|
-
{
|
|
38
|
-
type: 'author',
|
|
39
|
-
slug: 'mock-author',
|
|
40
|
-
name: 'Mock Author',
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
value: 'Chief Mock Author',
|
|
44
|
-
type: 'inline',
|
|
45
|
-
},
|
|
46
|
-
],
|
|
47
|
-
publishedDateTime: '2019-02-14T00:00:00.000Z',
|
|
48
|
-
updatedDateTime: '2019-02-14T00:37:17.000Z',
|
|
49
|
-
summary: {
|
|
50
|
-
children: [
|
|
51
|
-
{
|
|
52
|
-
text: 'Lorem ipsum',
|
|
53
|
-
},
|
|
54
|
-
],
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
articleURL: 'https://hostname/section/test-1/slugche' as URL,
|
|
58
|
-
twitterUsername: 'D_Trump',
|
|
59
|
-
siteHost: 'https://hostname',
|
|
60
|
-
gscId: '4320982',
|
|
61
|
-
articleId: 'test-1',
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const user = {
|
|
65
|
-
paymentFailure: {
|
|
66
|
-
active: false,
|
|
67
|
-
startDate: null,
|
|
68
|
-
},
|
|
69
|
-
subscriptions: [{ endDate: null }],
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
jest.mock('swr')
|
|
73
|
-
let swrMock
|
|
74
|
-
|
|
75
|
-
jest.mock('next/router', () => {
|
|
76
|
-
return {
|
|
77
|
-
useRouter: () => ({ asPath: '' }),
|
|
78
|
-
}
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
jest.mock('../../config', () => ({
|
|
82
|
-
twitterUsername: 'D_Trump',
|
|
83
|
-
gscId: '4320982',
|
|
84
|
-
}))
|
|
85
|
-
|
|
86
|
-
jest.mock('cross-fetch', () =>
|
|
87
|
-
jest.fn().mockImplementation(() =>
|
|
88
|
-
Promise.resolve({
|
|
89
|
-
json: () => Promise.resolve(user),
|
|
90
|
-
})
|
|
91
|
-
)
|
|
92
|
-
)
|
|
93
|
-
|
|
94
|
-
jest.mock('newrelic', () => {
|
|
95
|
-
return {
|
|
96
|
-
setTransactionName: jest.fn(),
|
|
97
|
-
}
|
|
98
|
-
})
|
|
99
|
-
|
|
100
|
-
/* start cra-effected */
|
|
101
|
-
jest.mock('@newskit-render/feature-flags', () => ({
|
|
102
|
-
initAndGetFeatureFlag: jest
|
|
103
|
-
.fn()
|
|
104
|
-
.mockImplementation(() => Promise.resolve({ test: 'test' })),
|
|
105
|
-
}))
|
|
106
|
-
/* end cra-effected */
|
|
107
|
-
|
|
108
|
-
jest.mock('@newskit-render/api', () => ({
|
|
109
|
-
ClientTypes: { nkapi: 'nkapi' },
|
|
110
|
-
createApolloClient: jest.fn().mockImplementation(() => {
|
|
111
|
-
return Promise.resolve({
|
|
112
|
-
query: jest.fn().mockResolvedValueOnce({
|
|
113
|
-
data: {
|
|
114
|
-
universalArticle: props.universalArticle,
|
|
115
|
-
},
|
|
116
|
-
}),
|
|
117
|
-
})
|
|
118
|
-
}),
|
|
119
|
-
getAcsCookie: jest.fn().mockReturnValue({ Cookie: 'something' }),
|
|
120
|
-
Publisher: {
|
|
121
|
-
SUN_UK: 'SUN_UK',
|
|
122
|
-
},
|
|
123
|
-
}))
|
|
124
|
-
|
|
125
|
-
jest.mock('@newskit-render/my-account', () => {
|
|
126
|
-
return {
|
|
127
|
-
PastDueBannerExternal: 'PastDueBannerExternal',
|
|
128
|
-
}
|
|
129
|
-
})
|
|
130
|
-
|
|
131
|
-
describe('Article', () => {
|
|
132
|
-
describe('getServerSideProps', () => {
|
|
133
|
-
it('should return props', async () => {
|
|
134
|
-
const setHeaderMock = jest.fn()
|
|
135
|
-
|
|
136
|
-
const response = await getServerSideProps({
|
|
137
|
-
params: {
|
|
138
|
-
articleId: 'test-1',
|
|
139
|
-
section: 'section',
|
|
140
|
-
articleSlug: 'slugche',
|
|
141
|
-
},
|
|
142
|
-
req: { headers: { cookie: 'some-cookie', host: 'hostname' } },
|
|
143
|
-
res: { setHeader: setHeaderMock },
|
|
144
|
-
})
|
|
145
|
-
expect(response).toMatchObject({
|
|
146
|
-
props: {
|
|
147
|
-
...props,
|
|
148
|
-
showAds: true,
|
|
149
|
-
user,
|
|
150
|
-
featureFlags: { test: 'test' } /* cra-effected */,
|
|
151
|
-
},
|
|
152
|
-
})
|
|
153
|
-
expect(setHeaderMock).toHaveBeenCalledWith(
|
|
154
|
-
'Cache-Control',
|
|
155
|
-
'public, s-maxage=10, stale-while-revalidate=59'
|
|
156
|
-
)
|
|
157
|
-
})
|
|
158
|
-
})
|
|
159
|
-
})
|
|
160
|
-
|
|
161
|
-
describe('Recommendation', () => {
|
|
162
|
-
beforeEach(() => {
|
|
163
|
-
swrMock = useSWR as jest.Mock
|
|
164
|
-
})
|
|
165
|
-
afterEach(() => {
|
|
166
|
-
jest.resetAllMocks()
|
|
167
|
-
})
|
|
168
|
-
it('render related article page when data is null page', async () => {
|
|
169
|
-
let result
|
|
170
|
-
await act(async () => {
|
|
171
|
-
swrMock.mockReturnValueOnce({ data: null })
|
|
172
|
-
result = renderWithTheme(Article, props)
|
|
173
|
-
})
|
|
174
|
-
expect(result.asFragment()).toMatchSnapshot()
|
|
175
|
-
})
|
|
176
|
-
it('render related article page', async () => {
|
|
177
|
-
let result
|
|
178
|
-
await act(async () => {
|
|
179
|
-
swrMock.mockReturnValueOnce({ data: recomendationsMock })
|
|
180
|
-
result = renderWithTheme(Article, props)
|
|
181
|
-
})
|
|
182
|
-
expect(result.findByTestId('article-recommendation-small')).toBeDefined()
|
|
183
|
-
expect(result.findByTestId('articleRec-1')).toBeDefined()
|
|
184
|
-
})
|
|
185
|
-
})
|