diff --git a/src/lib/get-topper-settings.js b/src/lib/get-topper-settings.js index 4087287..168a56d 100644 --- a/src/lib/get-topper-settings.js +++ b/src/lib/get-topper-settings.js @@ -6,33 +6,13 @@ const themeImageRatio = { 'full-bleed-offset': 'full-bleed' }; -const isNews = (content) => - content.annotations && - content.annotations.some((annotation) => annotation.prefLabel === 'News'); - -const isLiveBlogV1 = (content) => - /** - * The `live-blog` content type is not used in Elasticsearch. The content type is - * overridden from `article` to `live-blog` in `next-article` here: - * https://github.com/Financial-Times/next-article/blob/574581adc200e60051e3ca9c7fd5e9a6e16cee82/server/controllers/content.js#L29-L32 - */ - content.type === 'live-blog' && content.realtime; - const isLiveBlogV2 = (content) => content.type === 'live-blog-package'; -const isLiveBlogV1OrPackage = (content) => - isLiveBlogV1(content) || - (content.package && - isNews(content.package) && - content.package.contains[0].id === content.id) || - (content.type === 'package' && isNews(content)); - const isPackageArticlesWithExtraTheme = (content) => content.containedIn && content.containedIn.length && content.package && - content.package.design.theme.includes('extra') && - !isNews(content.package); + content.package.design.theme.includes('extra'); const isPackage = (content) => content.type === 'package' && content.design && content.design.theme; @@ -62,31 +42,6 @@ const useLiveBlogV2 = () => { }; }; -const useLiveBlogV1OrPackageTopper = (content, flags) => { - const designTheme = - (content.package && content.package.design.theme) || - (content.design && content.design.theme); - const isStandaloneLiveBlog = isLiveBlogV1(content); - - const isLoud = - designTheme === 'extra' || - designTheme === 'extra-wide' || - isStandaloneLiveBlog; - - return { - layout: null, - backgroundColour: isLoud ? 'crimson' : 'wheat', - modifiers: ['news-package'], - themeImageRatio: 'split', - includesImage: true, - isExperimental: true, - myFtButton: { - variant: isLoud ? 'monochrome' : 'standard', - followPlusDigestEmail: followPlusDigestEmail(flags) - } - }; -}; - const useExtraThemeTopper = () => { return { layout: 'full-bleed-offset', @@ -236,8 +191,6 @@ const getTopperSettings = (content, flags = {}) => { if (isLiveBlogV2(content)) { return useLiveBlogV2(); - } else if (isLiveBlogV1OrPackage(content)) { - return useLiveBlogV1OrPackageTopper(content, flags); } else if (isPackageArticlesWithExtraTheme(content)) { return useExtraThemeTopper(); } else if (isPackage(content)) { diff --git a/test/lib/get-topper-settings.test.js b/test/lib/get-topper-settings.test.js index d95153a..a9ff629 100644 --- a/test/lib/get-topper-settings.test.js +++ b/test/lib/get-topper-settings.test.js @@ -18,22 +18,6 @@ describe('Get topper settings', () => { }); describe('Live blog', () => { - it('returns the live blog v1 topper', () => { - const topper = getTopperSettings({ - type: 'live-blog', - realtime: true, - }); - - expect(topper).to.deep.include({ - backgroundColour: 'crimson', - modifiers: ['news-package'], - myFtButton: { - variant: 'monochrome', - followPlusDigestEmail: false - } - }); - }); - it('returns the live blog v2 topper', () => { const topper = getTopperSettings({ type: 'live-blog-package' @@ -47,132 +31,6 @@ describe('Get topper settings', () => { }); }); - describe('Live news package', () => { - describe('Basic theme', () => { - describe('Package landing page', () => { - it('returns a wheat background colour', () => { - const topper = getTopperSettings({ - type: 'package', - annotations: [{ prefLabel: 'News' }], - design: { theme: 'basic' } - }); - - expect(topper.backgroundColour).to.equal('wheat'); - expect(topper.myFtButton.variant).to.equal('standard'); - }); - }); - - describe('Package article', () => { - it('returns a wheat background colour for the first article', () => { - const topper = getTopperSettings({ - type: 'article', - id: 123, - annotations: [ - { prefLabel: 'Barcelona' }, - { prefLabel: 'News' } - ], - package: { - contains: [{ id: 123 }], - design: { theme: 'basic' }, - annotations: [ - { prefLabel: 'Barcelona' }, - { prefLabel: 'News' } - ] - } - }); - - expect(topper.backgroundColour).to.equal('wheat'); - expect(topper.myFtButton.variant).to.equal('standard'); - }); - - it('returns the basic topper for the second article', () => { - const topper = getTopperSettings({ - type: 'article', - id: 456, - annotations: [ - { prefLabel: 'Barcelona' }, - { prefLabel: 'News' } - ], - package: { - contains: [{ id: 123 }, { id: 456 }], - design: { theme: 'extra' }, - annotations: [ - { prefLabel: 'Barcelona' }, - { prefLabel: 'News' } - ] - } - }); - - expect(topper.backgroundColour).to.equal('paper'); - expect(topper.myFtButton.variant).to.equal('standard'); - }); - }); - }); - - describe('Extra theme', () => { - describe('Package landing page', () => { - it('returns a crimson background colour', () => { - const topper = getTopperSettings({ - type: 'package', - annotations: [ - { prefLabel: 'Barcelona' }, - { prefLabel: 'News' } - ], - design: { theme: 'extra' } - }); - - expect(topper.backgroundColour).to.equal('crimson'); - expect(topper.myFtButton.variant).to.equal('monochrome'); - }); - }); - - describe('Package article', () => { - it('returns a crimson background colour for first article', () => { - const topper = getTopperSettings({ - type: 'article', - id: 123, - annotations: [ - { prefLabel: 'Barcelona' }, - { prefLabel: 'News' } - ], - package: { - contains: [{ id: 123 }], - design: { theme: 'extra' }, - annotations: [ - { prefLabel: 'Barcelona' }, - { prefLabel: 'News' } - ] - } - }); - - expect(topper.backgroundColour).to.equal('crimson'); - expect(topper.myFtButton.variant).to.equal('monochrome'); - }); - - it('returns a paper background colour for the second article', () => { - const topper = getTopperSettings({ - type: 'article', - id: 456, - annotations: [ - { prefLabel: 'Barcelona' }, - { prefLabel: 'News' } - ], - package: { - contains: [{ id: 123 }, { id: 456 }], - design: { theme: 'extra' }, - annotations: [ - { prefLabel: 'Barcelona' }, - { prefLabel: 'News' } - ] - } - }); - expect(topper.backgroundColour).to.equal('paper'); - expect(topper.myFtButton.variant).to.equal('standard'); - }); - }); - }); - }); - describe('Package articles with an `extra` theme', () => { it('returns the slate offset topper', () => { const topper = getTopperSettings({