Skip to content

Commit

Permalink
Merge pull request #13 from Financial-Times/remove-news-package-toppe…
Browse files Browse the repository at this point in the history
…r-logic

CI-944 - Remove the logic around showing the 'news-package' topper when a series has the genre of `news`
  • Loading branch information
jkerr321 authored Dec 13, 2021
2 parents 1c72bb8 + fe287a1 commit 3dfd756
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 190 deletions.
49 changes: 1 addition & 48 deletions src/lib/get-topper-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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)) {
Expand Down
142 changes: 0 additions & 142 deletions test/lib/get-topper-settings.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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({
Expand Down

0 comments on commit 3dfd756

Please sign in to comment.