@newskit-render/core 1.50.1 → 1.63.2

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 (50) hide show
  1. package/CHANGELOG.md +324 -0
  2. package/__pacts__/spec/newskitApi.consumer.pact.ts +19 -32
  3. package/__tests__/pages/[articleSlug].test.tsx +12 -8
  4. package/__tests__/pages/__snapshots__/brightcove.test.tsx.snap +20 -0
  5. package/__tests__/pages/__snapshots__/home.test.tsx.snap +241 -1846
  6. package/__tests__/pages/brightcove.test.tsx +34 -0
  7. package/__tests__/pages/home.test.tsx +22 -12
  8. package/__tests__/pages/mocks.ts +29 -0
  9. package/__tests__/pages/relatedArticles.test.tsx +76 -0
  10. package/components/article/RelatedArticles.tsx +48 -55
  11. package/components/article/__tests__/__snapshots__/index.test.tsx.snap +414 -3366
  12. package/components/article/__tests__/index.test.tsx +46 -2
  13. package/components/article/index.tsx +28 -15
  14. package/components/footer/__snapshots__/index.test.tsx.snap +37 -271
  15. package/components/header/index.tsx +7 -0
  16. package/components/section/layouts/Rows.tsx +36 -17
  17. package/components/section/layouts/__tests__/Rows.test.tsx +12 -0
  18. package/components/section/layouts/__tests__/__snapshots__/Lead.test.tsx.snap +36 -530
  19. package/components/section/layouts/__tests__/__snapshots__/SectionTitle.test.tsx.snap +42 -766
  20. package/components/section/layouts/types.ts +3 -0
  21. package/config/index.ts +85 -0
  22. package/constants/index.ts +3 -1
  23. package/cypress/e2e/account/accessibility.spec.js +14 -17
  24. package/cypress/e2e/account/account-subscription.spec.js +9 -8
  25. package/cypress/e2e/account/payment-failer.spec.js +3 -3
  26. package/cypress/support/commands.js +2 -2
  27. package/helpers/__tests__/getUser.test.ts +7 -8
  28. package/helpers/logger.ts +3 -1
  29. package/helpers/mocks/articleMock.ts +1 -1
  30. package/helpers/mocks/getUniversalArticleMock.ts +13 -0
  31. package/helpers/setupTests.ts +4 -0
  32. package/jest.config.js +22 -19
  33. package/package.json +11 -11
  34. package/pages/[section]/[articleId]/[articleSlug].tsx +9 -4
  35. package/pages/[section]/[articleId]/relatedArticles.tsx +85 -0
  36. package/pages/_app.tsx +4 -3
  37. package/pages/_document.tsx +17 -18
  38. package/pages/api/auth/[...nextauth].ts +2 -3
  39. package/pages/api/feed.ts +7 -3
  40. package/pages/api/news-sitemap.ts +4 -6
  41. package/pages/api/sitemap.ts +10 -7
  42. package/pages/help-hub/[id]/index.tsx +11 -0
  43. package/pages/help-hub/index.tsx +11 -0
  44. package/pages/index.tsx +1 -0
  45. package/pages/player/brightcove.tsx +19 -0
  46. package/pages/preview/[articleId]/version/[versionId]/index.tsx +9 -4
  47. package/public/icon.png +0 -0
  48. package/queries/getRadioPosts.ts +1 -1
  49. package/queries/getUniversalArticle.ts +13 -0
  50. package/temp/header.tsx +7 -0
package/pages/api/feed.ts CHANGED
@@ -1,18 +1,22 @@
1
1
  import { NextApiRequest, NextApiResponse } from 'next'
2
2
  import { rssFeed, UpdatePeriod } from '@newskit-render/feed'
3
+ import { Publisher } from '@newskit-render/api'
4
+ import { publisher, siteHost } from '../../config'
3
5
 
4
6
  const handler = async (req: NextApiRequest, res: NextApiResponse) =>
5
7
  rssFeed({
6
8
  res,
9
+ publisher:
10
+ publisher === 'DEMO' ? Publisher.VIRGIN : (publisher as Publisher),
11
+ domain: siteHost,
7
12
  titeAttributes: {
8
13
  title: 'Demo Site',
9
- link: `${process.env.SITE_HOST}/feed`,
14
+ link: '/feed',
10
15
  description: 'Newskit Render Demo site',
11
- lastBuildDate: new Date().toUTCString(),
12
16
  language: 'en-US',
13
17
  updatePeriod: 'hourly' as UpdatePeriod,
14
18
  updateFrequency: 1,
15
- logoUrl: `${process.env.SITE_HOST}/favicon.ico`,
19
+ logoUrl: '/icon.png',
16
20
  },
17
21
  })
18
22
 
@@ -1,7 +1,7 @@
1
1
  import { NextApiRequest, NextApiResponse } from 'next'
2
2
  import { newsSitemap } from '@newskit-render/feed'
3
3
  import { Publisher } from '@newskit-render/api'
4
-
4
+ import { publisher, siteHost, sitemapPublicationName } from '../../config'
5
5
  /* We do not have sitemap date for Demo so using Virgin,
6
6
  * This can be removed and replace with just - publisher: process.env.PUBLISHER as PublisherGroup, in created projects
7
7
  */
@@ -10,11 +10,9 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) =>
10
10
  newsSitemap({
11
11
  res,
12
12
  publisher:
13
- process.env.PUBLISHER === 'DEMO'
14
- ? Publisher.VIRGIN
15
- : (process.env.PUBLISHER as Publisher),
16
- domain: new URL(process.env.SITE_HOST as string).host,
17
- publicationName: process.env.SITEMAP_PUBLICATION_NAME as string,
13
+ publisher === 'DEMO' ? Publisher.VIRGIN : (publisher as Publisher),
14
+ domain: new URL(siteHost as string).host,
15
+ publicationName: sitemapPublicationName as string,
18
16
  })
19
17
 
20
18
  export default handler
@@ -1,7 +1,12 @@
1
1
  import { NextApiRequest, NextApiResponse } from 'next'
2
2
  import { genericSitemap, CustomStaticPage } from '@newskit-render/feed'
3
3
  import { Publisher } from '@newskit-render/api'
4
-
4
+ import {
5
+ publisher,
6
+ siteHost,
7
+ sitemapFirstPublicationDate,
8
+ sitemapPublicationName,
9
+ } from '../../config'
5
10
  /* We do not have sitemap date for Demo so using Virgin,
6
11
  * This can be removed and replace with just - publisher: process.env.PUBLISHER as PublisherGroup, in created projects
7
12
  */
@@ -16,12 +21,10 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) =>
16
21
  res,
17
22
  query: req.query,
18
23
  publisher:
19
- process.env.PUBLISHER === 'DEMO'
20
- ? Publisher.VIRGIN
21
- : (process.env.PUBLISHER as Publisher),
22
- domain: new URL(process.env.SITE_HOST as string).host,
23
- firstArticleDate: process.env.SITEMAP_FIRST_PUBLICATION_DATE as string,
24
- publicationName: process.env.SITEMAP_PUBLICATION_NAME as string,
24
+ publisher === 'DEMO' ? Publisher.VIRGIN : (publisher as Publisher),
25
+ domain: new URL(siteHost as string).host,
26
+ firstArticleDate: sitemapFirstPublicationDate as string,
27
+ publicationName: sitemapPublicationName as string,
25
28
  customStaticPageCollection: defaultCustomStaticPagesCollection,
26
29
  })
27
30
 
@@ -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
@@ -0,0 +1,11 @@
1
+ import React from 'react'
2
+ import { SearchPage } from '@newskit-render/standalone-components'
3
+ import Layout from '../../components/layout'
4
+
5
+ const HelpHub = () => (
6
+ <Layout>
7
+ <SearchPage />
8
+ </Layout>
9
+ )
10
+
11
+ export default HelpHub
package/pages/index.tsx CHANGED
@@ -12,6 +12,7 @@ import { addCacheHeaders } from '../helpers/addCacheHeaders'
12
12
 
13
13
  export async function getServerSideProps(context) {
14
14
  newrelic.setTransactionName('Homepage')
15
+ console.warn('config:')
15
16
  console.warn('context:')
16
17
  console.warn(context.req && context.req.headers)
17
18
 
@@ -0,0 +1,19 @@
1
+ import React from 'react'
2
+ import { VideoPlayer } from 'newskit'
3
+ import { useRouter } from 'next/router'
4
+
5
+ const BrightcovePlayer: React.FC<{}> = () => {
6
+ const router = useRouter()
7
+
8
+ const videoConfig = {
9
+ 'data-account': router.query.account_id as string,
10
+ 'data-player': router.query.player_id as string,
11
+ 'data-video-id': router.query.video_id as string,
12
+ 'data-embed': 'default',
13
+ controls: true,
14
+ }
15
+
16
+ return <VideoPlayer config={videoConfig} />
17
+ }
18
+
19
+ export default BrightcovePlayer
@@ -22,6 +22,11 @@ import {
22
22
  relatedArticles,
23
23
  } from '../../../../../helpers/mocks/articleMock'
24
24
  import { addCacheHeaders } from '../../../../../helpers/addCacheHeaders'
25
+ import {
26
+ siteHost as configSiteHost,
27
+ twitterUsername as configTwitterUsername,
28
+ gscId as configGscId,
29
+ } from '../../../../../config'
25
30
 
26
31
  const PreviewArticle = ({
27
32
  universalArticle,
@@ -104,10 +109,10 @@ export async function getServerSideProps(context) {
104
109
  props: {
105
110
  universalArticle: data.universalArticle,
106
111
  session,
107
- articleURL: `${process.env.SITE_HOST}/preview/${articleId}/version/${versionId}`,
108
- twitterUsername: process.env.TWITTER_USERNAME || '',
109
- siteHost: process.env.SITE_HOST || '',
110
- gscId: process.env.GSC_ID || '',
112
+ articleURL: `${configSiteHost}/preview/${articleId}/version/${versionId}`,
113
+ twitterUsername: configTwitterUsername || '',
114
+ siteHost: configSiteHost || '',
115
+ gscId: configGscId || '',
111
116
  },
112
117
  }
113
118
  }
Binary file
@@ -1,7 +1,7 @@
1
1
  import { gql } from '@apollo/client'
2
2
 
3
3
  export const GET_RADIO_POSTS = gql`
4
- query GetRadioPosts($pageCursors: String!) {
4
+ query getRadioPosts($pageCursors: String!) {
5
5
  radioPosts(cursor: $pageCursors) {
6
6
  data {
7
7
  dateCreated
@@ -49,6 +49,19 @@ export const GET_UNIVERSAL_ARTICLE = gql`
49
49
  aspectRatio
50
50
  }
51
51
  }
52
+ ... on Video {
53
+ accountId
54
+ videoId
55
+ posterImage {
56
+ ... on Image {
57
+ crops {
58
+ url
59
+ alt
60
+ aspectRatio
61
+ }
62
+ }
63
+ }
64
+ }
52
65
  }
53
66
  }
54
67
  }
package/temp/header.tsx CHANGED
@@ -121,6 +121,13 @@ const pastDueBanner = {
121
121
  text:
122
122
  'You have cancelled your subscription and will lose access to all benefits on ##DATE##. To re-activate your subscription call ##PHONE_NUMBER##.',
123
123
  },
124
+ toBeCancelledWithRefund: {
125
+ title: 'Your subscription will end soon.',
126
+ phoneNumber: '0800 xxxx xxxxx',
127
+ text:
128
+ 'We have successfully cancelled your subscription and will be processing your refund shortly. If you have any question please call ##PHONE_NUMBER##.',
129
+ dismissDays: 7,
130
+ },
124
131
  treshold: {
125
132
  firstNotice: 26,
126
133
  secondNotice: 30,