@newskit-render/core 1.49.0 → 1.54.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 +114 -0
- package/__tests__/pages/[articleSlug].test.tsx +6 -0
- package/__tests__/pages/__snapshots__/home.test.tsx.snap +241 -1846
- package/__tests__/pages/home.test.tsx +6 -0
- package/components/article/__tests__/__snapshots__/index.test.tsx.snap +316 -3265
- package/components/common/BackToHomepage.tsx +36 -0
- package/components/footer/__snapshots__/index.test.tsx.snap +37 -271
- package/components/header/index.tsx +7 -0
- package/components/section/index.tsx +2 -0
- package/components/section/layouts/__tests__/__snapshots__/Lead.test.tsx.snap +36 -530
- package/components/section/layouts/__tests__/__snapshots__/SectionTitle.test.tsx.snap +42 -766
- package/cypress/e2e/account/account-subscription.spec.js +9 -8
- package/cypress/e2e/account/payment-failer.spec.js +3 -3
- package/cypress/support/commands.js +2 -2
- package/helpers/__tests__/getUser.test.ts +7 -8
- package/helpers/setupTests.ts +4 -0
- package/infrastructure/.circleci/config.yml +1 -0
- package/jest.config.js +21 -19
- package/package.json +8 -8
- package/pages/api/feed.ts +8 -2
- package/pages/help-hub/[id]/index.tsx +11 -0
- package/pages/help-hub/index.tsx +11 -0
- package/public/icon.png +0 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// These tests are skiped now, until CPS resolves their issue with subsriptions.
|
|
1
2
|
describe('Account Subscription & Cancellation', () => {
|
|
2
3
|
it('Should show no subscription view', () => {
|
|
3
4
|
cy.GetAcsSession('noSub')
|
|
@@ -81,9 +82,9 @@ describe('Account Subscription & Cancellation', () => {
|
|
|
81
82
|
cy.contains(
|
|
82
83
|
'All your subscription details, including payment info and transactions.'
|
|
83
84
|
)
|
|
84
|
-
cy.contains('
|
|
85
|
+
cy.contains('4AAA038867017')
|
|
85
86
|
cy.contains('************1111')
|
|
86
|
-
cy.contains('expiry date 01/
|
|
87
|
+
cy.contains('expiry date 01/25')
|
|
87
88
|
|
|
88
89
|
cy.get('a[href="/account/cancellation"]').should('be.visible').click()
|
|
89
90
|
|
|
@@ -125,7 +126,7 @@ describe('Account Subscription & Cancellation', () => {
|
|
|
125
126
|
})
|
|
126
127
|
},
|
|
127
128
|
})
|
|
128
|
-
cy.get('[data-testid="banner
|
|
129
|
+
cy.get('[data-testid="past-due-banner"]').should('be.visible')
|
|
129
130
|
cy.contains('Your subscription will end soon.')
|
|
130
131
|
cy.contains(
|
|
131
132
|
`You have cancelled your subscription and will lose access to all benefits on ${date.getDate()}/${
|
|
@@ -178,14 +179,14 @@ describe('Account Subscription & Cancellation', () => {
|
|
|
178
179
|
})
|
|
179
180
|
},
|
|
180
181
|
})
|
|
181
|
-
cy.get('[data-testid="banner
|
|
182
|
+
cy.get('[data-testid="past-due-banner"]').should('be.visible')
|
|
182
183
|
cy.contains('Your subscription will end soon.')
|
|
183
|
-
cy.get('[data-testid="close-
|
|
184
|
+
cy.get('button[data-testid="banner-close-button"]').click({
|
|
184
185
|
force: true,
|
|
185
186
|
multiple: true,
|
|
186
187
|
})
|
|
187
188
|
cy.reload()
|
|
188
|
-
cy.get('[data-testid="banner
|
|
189
|
+
cy.get('[data-testid="past-due-banner"]').should('not.exist')
|
|
189
190
|
})
|
|
190
191
|
|
|
191
192
|
it('Should not display banner if set date is passed current date', () => {
|
|
@@ -208,7 +209,7 @@ describe('Account Subscription & Cancellation', () => {
|
|
|
208
209
|
})
|
|
209
210
|
},
|
|
210
211
|
})
|
|
211
|
-
cy.get('[data-testid="banner
|
|
212
|
+
cy.get('[data-testid="past-due-banner"]').should('be.visible')
|
|
212
213
|
cy.contains('Your subscription has been cancelled.').then(() => {
|
|
213
214
|
window.localStorage.setItem(
|
|
214
215
|
'cancelledBanner',
|
|
@@ -216,7 +217,7 @@ describe('Account Subscription & Cancellation', () => {
|
|
|
216
217
|
)
|
|
217
218
|
})
|
|
218
219
|
cy.reload()
|
|
219
|
-
cy.get('[data-testid="banner
|
|
220
|
+
cy.get('[data-testid="past-due-banner"]').should('not.exist')
|
|
220
221
|
cy.clearLocalStorage()
|
|
221
222
|
})
|
|
222
223
|
|
|
@@ -21,7 +21,7 @@ describe('Payment Failer', () => {
|
|
|
21
21
|
})
|
|
22
22
|
},
|
|
23
23
|
})
|
|
24
|
-
cy.get('[data-testid="banner
|
|
24
|
+
cy.get('[data-testid="past-due-banner"]').should('be.visible')
|
|
25
25
|
cy.contains("We haven't been able to take payment")
|
|
26
26
|
cy.contains(
|
|
27
27
|
'You may need to update your payment details to keep your subscription.'
|
|
@@ -54,7 +54,7 @@ describe('Payment Failer', () => {
|
|
|
54
54
|
})
|
|
55
55
|
},
|
|
56
56
|
})
|
|
57
|
-
cy.get('[data-testid="banner
|
|
57
|
+
cy.get('[data-testid="past-due-banner"]').should('be.visible')
|
|
58
58
|
cy.contains('Act now to keep your subscription')
|
|
59
59
|
cy.contains(
|
|
60
60
|
'We’ve tried several times, but haven’t been able to take payment. Please update your payment details to keep your subscription.'
|
|
@@ -87,7 +87,7 @@ describe('Payment Failer', () => {
|
|
|
87
87
|
})
|
|
88
88
|
},
|
|
89
89
|
})
|
|
90
|
-
cy.get('[data-testid="banner
|
|
90
|
+
cy.get('[data-testid="past-due-banner"]').should('be.visible')
|
|
91
91
|
cy.contains('Your subscription has been terminated')
|
|
92
92
|
cy.contains(
|
|
93
93
|
'We didn’t receive payment for your subscription. To reactivate it, please call XXXX-XXX-XXXX.'
|
|
@@ -23,8 +23,8 @@ const userMap = {
|
|
|
23
23
|
password: 'Ad45p0-swq151@',
|
|
24
24
|
},
|
|
25
25
|
withSub: {
|
|
26
|
-
username: 'render-e2e-
|
|
27
|
-
password: '
|
|
26
|
+
username: 'render-e2e-subscription@yopmail.com',
|
|
27
|
+
password: 'Testing123$',
|
|
28
28
|
},
|
|
29
29
|
paypalSub: {
|
|
30
30
|
username: 'render-paypal-payment@yopmail.com',
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
+
import fetch from 'cross-fetch'
|
|
1
2
|
import { fetchUser } from '../getUser'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
jest.mock('cross-fetch', () => {
|
|
5
|
-
fetchMock = jest.fn()
|
|
6
|
-
return fetchMock
|
|
7
|
-
})
|
|
4
|
+
jest.mock('cross-fetch', () => jest.fn().mockImplementation(() => {}))
|
|
8
5
|
|
|
9
6
|
describe('getUser function', () => {
|
|
10
7
|
beforeEach(() => {
|
|
@@ -12,7 +9,9 @@ describe('getUser function', () => {
|
|
|
12
9
|
})
|
|
13
10
|
it("should call console.error with 'Bad response from server' when Response.status >= 400", async () => {
|
|
14
11
|
jest.spyOn(console, 'error')
|
|
15
|
-
|
|
12
|
+
;(fetch as jest.Mock).mockImplementation(() =>
|
|
13
|
+
Promise.resolve({ status: 500 })
|
|
14
|
+
)
|
|
16
15
|
await fetchUser(
|
|
17
16
|
{ Cookie: 'test' },
|
|
18
17
|
'http://localhost:3000/api/account/query'
|
|
@@ -22,7 +21,7 @@ describe('getUser function', () => {
|
|
|
22
21
|
|
|
23
22
|
it('should call response.json() when Response.status is < 400', async () => {
|
|
24
23
|
const mockJson = jest.fn()
|
|
25
|
-
|
|
24
|
+
;(fetch as jest.Mock).mockImplementation(() =>
|
|
26
25
|
Promise.resolve({ status: 200, json: mockJson })
|
|
27
26
|
)
|
|
28
27
|
await fetchUser(
|
|
@@ -34,7 +33,7 @@ describe('getUser function', () => {
|
|
|
34
33
|
|
|
35
34
|
it('should return null if no cookie', async () => {
|
|
36
35
|
const mockJson = jest.fn()
|
|
37
|
-
|
|
36
|
+
;(fetch as jest.Mock).mockImplementation(() =>
|
|
38
37
|
Promise.resolve({ status: 200, json: mockJson })
|
|
39
38
|
)
|
|
40
39
|
await fetchUser(
|
package/helpers/setupTests.ts
CHANGED
|
@@ -3,3 +3,7 @@
|
|
|
3
3
|
// expect(element).toHaveTextContent(/react/i)
|
|
4
4
|
// learn more: https://github.com/testing-library/jest-dom
|
|
5
5
|
import '@testing-library/jest-dom/extend-expect'
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
// remove this variable once SITE_HOST is refactored
|
|
9
|
+
process.env.SITE_HOST = 'https://newskit-render.ceng-dev.newsuk.tech'
|
|
@@ -259,6 +259,7 @@ orbs:
|
|
|
259
259
|
echo 'export HELM_OPT_SET="$HELM_OPT_SET --set secret.items.SN_PASSWORD=${SN_PASSWORD}"' >> $BASH_ENV
|
|
260
260
|
echo 'export HELM_OPT_SET="$HELM_OPT_SET --set secret.items.SN_USERNAME=${SN_USERNAME}"' >> $BASH_ENV
|
|
261
261
|
echo 'export HELM_OPT_SET="$HELM_OPT_SET --set secret.items.SN_ENVIRONMENT=${SN_ENVIRONMENT}"' >> $BASH_ENV
|
|
262
|
+
echo 'export HELM_OPT_SET="$HELM_OPT_SET --set secret.items.ZUORA_PAGE_ID=${ZUORA_PAGE_ID}"' >> $BASH_ENV
|
|
262
263
|
echo 'export HELM_OPT_SET="$HELM_OPT_SET --set secret.items.ZUORA_RSA_SIGNATURE_URI=${ZUORA_RSA_SIGNATURE_URI}"' >> $BASH_ENV
|
|
263
264
|
echo 'export HELM_OPT_SET="$HELM_OPT_SET --set secret.items.OPTIMIZELY_SDK_KEY=${OPTIMIZELY_SDK_KEY}"' >> $BASH_ENV
|
|
264
265
|
echo 'export HELM_PATH="helm"' >> $BASH_ENV
|
package/jest.config.js
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
process.env.TZ = 'GMT'
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
|
|
3
|
+
const nextJest = require('next/jest')
|
|
4
|
+
|
|
5
|
+
const createJestConfig = nextJest({
|
|
6
|
+
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment
|
|
7
|
+
dir: './',
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
const customJestConfig = {
|
|
4
11
|
setupFilesAfterEnv: ['<rootDir>/helpers/setupTests.ts'],
|
|
5
|
-
|
|
12
|
+
moduleDirectories: ['node_modules', '<rootDir>/'],
|
|
6
13
|
coverageThreshold: {
|
|
7
14
|
global: {
|
|
8
15
|
branches: 50,
|
|
@@ -11,26 +18,21 @@ module.exports = {
|
|
|
11
18
|
statements: 90,
|
|
12
19
|
},
|
|
13
20
|
},
|
|
14
|
-
|
|
15
|
-
'
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
transform: {
|
|
20
|
-
'^.+\\.(ts|tsx)$': 'ts-jest',
|
|
21
|
+
moduleNameMapper: {
|
|
22
|
+
'^react$': '<rootDir>/node_modules/react',
|
|
23
|
+
'^newskit$': '<rootDir>/node_modules/newskit',
|
|
21
24
|
},
|
|
25
|
+
testEnvironment: 'jest-environment-jsdom',
|
|
26
|
+
watchPlugins: [
|
|
27
|
+
'jest-watch-typeahead/filename',
|
|
28
|
+
'jest-watch-typeahead/testname',
|
|
29
|
+
],
|
|
22
30
|
testPathIgnorePatterns: [
|
|
23
31
|
'<rootDir>/cypress/',
|
|
24
32
|
'<rootDir>/node_modules/',
|
|
25
33
|
'<rootDir>/.next/',
|
|
26
34
|
],
|
|
27
|
-
snapshotSerializers: ['@emotion/jest/serializer'],
|
|
28
|
-
watchPlugins: [
|
|
29
|
-
'jest-watch-typeahead/filename',
|
|
30
|
-
'jest-watch-typeahead/testname',
|
|
31
|
-
],
|
|
32
|
-
moduleNameMapper: {
|
|
33
|
-
'^react$': '<rootDir>/node_modules/react',
|
|
34
|
-
'^newskit$': '<rootDir>/node_modules/newskit',
|
|
35
|
-
},
|
|
36
35
|
}
|
|
36
|
+
|
|
37
|
+
// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
|
|
38
|
+
module.exports = createJestConfig(customJestConfig)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@newskit-render/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.54.0",
|
|
4
4
|
"description": "Newskit Render - Core package",
|
|
5
5
|
"author": "",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -33,14 +33,14 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@apollo/client": "3.4.16",
|
|
36
|
-
"@newskit-render/api": "^0.
|
|
37
|
-
"@newskit-render/auth": "^0.
|
|
38
|
-
"@newskit-render/checkout": "^0.
|
|
36
|
+
"@newskit-render/api": "^0.23.0",
|
|
37
|
+
"@newskit-render/auth": "^0.34.0",
|
|
38
|
+
"@newskit-render/checkout": "^0.29.0",
|
|
39
39
|
"@newskit-render/feature-flags": "^0.15.0",
|
|
40
|
-
"@newskit-render/feed": "^0.
|
|
41
|
-
"@newskit-render/my-account": "^0.
|
|
42
|
-
"@newskit-render/shared-components": "^0.
|
|
43
|
-
"@newskit-render/standalone-components": "^0.
|
|
40
|
+
"@newskit-render/feed": "^0.10.0",
|
|
41
|
+
"@newskit-render/my-account": "^0.158.0",
|
|
42
|
+
"@newskit-render/shared-components": "^0.51.0",
|
|
43
|
+
"@newskit-render/standalone-components": "^0.6.1",
|
|
44
44
|
"@newskit-render/validation": "^0.41.0",
|
|
45
45
|
"cross-fetch": "3.1.5",
|
|
46
46
|
"graphql": "15.6.0",
|
package/pages/api/feed.ts
CHANGED
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
import { NextApiRequest, NextApiResponse } from 'next'
|
|
2
2
|
import { rssFeed, UpdatePeriod } from '@newskit-render/feed'
|
|
3
|
+
import { Publisher } from '@newskit-render/api'
|
|
3
4
|
|
|
4
5
|
const handler = async (req: NextApiRequest, res: NextApiResponse) =>
|
|
5
6
|
rssFeed({
|
|
6
7
|
res,
|
|
8
|
+
publisher:
|
|
9
|
+
process.env.PUBLISHER === 'DEMO'
|
|
10
|
+
? Publisher.VIRGIN
|
|
11
|
+
: (process.env.PUBLISHER as Publisher),
|
|
12
|
+
domain: process.env.SITE_HOST,
|
|
7
13
|
titeAttributes: {
|
|
8
14
|
title: 'Demo Site',
|
|
9
|
-
link:
|
|
15
|
+
link: '/feed',
|
|
10
16
|
description: 'Newskit Render Demo site',
|
|
11
17
|
lastBuildDate: new Date().toUTCString(),
|
|
12
18
|
language: 'en-US',
|
|
13
19
|
updatePeriod: 'hourly' as UpdatePeriod,
|
|
14
20
|
updateFrequency: 1,
|
|
15
|
-
logoUrl:
|
|
21
|
+
logoUrl: '/icon.png',
|
|
16
22
|
},
|
|
17
23
|
})
|
|
18
24
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { ResultsPage } from '@newskit-render/standalone-components'
|
|
3
|
+
import Layout from '../../../components/layout'
|
|
4
|
+
|
|
5
|
+
const HelpHubResultsPage = () => (
|
|
6
|
+
<Layout>
|
|
7
|
+
<ResultsPage />
|
|
8
|
+
</Layout>
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
export default HelpHubResultsPage
|
package/public/icon.png
ADDED
|
Binary file
|