Skip to content

Commit

Permalink
Merge branch 'WSTEAMA-303-message-banner-tracking' of github.com:bbc/…
Browse files Browse the repository at this point in the history
…simorgh into WSTEAMA-303-message-banner-tracking
  • Loading branch information
karinathomasbbc committed Jan 12, 2024
2 parents 5500324 + a1e0aa0 commit 749d761
Show file tree
Hide file tree
Showing 69 changed files with 114 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,7 @@ exports[`PageLayoutWrapper should render default page wrapper with children 1`]
©
</span>
2023 BBC. The BBC is not responsible for the content of external sites.
2024 BBC. The BBC is not responsible for the content of external sites.
<a
class="focusIndicatorInvert emotion-80 emotion-51"
Expand Down
16 changes: 9 additions & 7 deletions src/app/components/PageLayoutWrapper/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ const PageLayoutWrapper = ({
});
}
let wrappedPageTimeStart = new Date();
const wrappedYear = wrappedPageTimeStart.getFullYear();
const wrappedMonth = wrappedPageTimeStart.getMonth() + 1;
let wrappedYear = wrappedPageTimeStart.getFullYear();
let wrappedMonth = wrappedPageTimeStart.getMonth() + 1;
let wrappedStorageKey = 'ws_bbc_wrapped';
let wrappedContents = {};
wrappedContents[wrappedYear] = {
Expand All @@ -152,17 +152,19 @@ const PageLayoutWrapper = ({
'wordCount': 0,
};
wrappedContents[wrappedYear].byMonth[wrappedMonth] = 0;
const saveWrapped = () => {
let saveWrapped = () => {
localStorage.setItem(wrappedStorageKey, JSON.stringify(wrappedContents));
}
let wrappedLocalStorageContents = localStorage.getItem(wrappedStorageKey);
if (wrappedLocalStorageContents) {
const wrappedLocalStorageContentsParsed = JSON.parse(wrappedLocalStorageContents);
wrappedContents[wrappedYear] = wrappedLocalStorageContentsParsed[wrappedYear] || wrappedLocalStorageContentsParsed;
wrappedContents[wrappedYear].byMonth[wrappedMonth] = wrappedLocalStorageContentsParsed[wrappedYear].byMonth[wrappedMonth] || 0;
if (wrappedLocalStorageContentsParsed.hasOwnProperty(wrappedYear)) {
wrappedContents[wrappedYear] = wrappedLocalStorageContentsParsed[wrappedYear] || wrappedContents[wrappedYear];
wrappedContents[wrappedYear].byMonth[wrappedMonth] = wrappedLocalStorageContentsParsed[wrappedYear].byMonth[wrappedMonth] || 0;
}
}
const wrappedContentsShortcut = wrappedContents[wrappedYear];
const wrappedTopics = ${JSON.stringify(
let wrappedContentsShortcut = wrappedContents[wrappedYear];
let wrappedTopics = ${JSON.stringify(
pageData?.metadata?.topics,
)};
if (wrappedTopics) {
Expand Down
19 changes: 16 additions & 3 deletions src/app/hooks/useLocation/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
import { renderHook } from '@testing-library/react-hooks';
import { fireEvent } from '@testing-library/react';
import { useState } from 'react';
import useLocation, * as useLocationObj from '.';

jest.mock('react', () => ({
...jest.requireActual('react'),
useState: jest.fn(),
}));

describe('useLocation', () => {
beforeEach(() => {
(useState as jest.Mock).mockImplementation(
jest.requireActual('react').useState,
);
});
it('should set location to the current window location', () => {
const { result } = renderHook(() => useLocation());

Expand Down Expand Up @@ -31,15 +42,17 @@ describe('useLocation', () => {
expect(removeEventListenerSpy).toHaveBeenCalled();
});

it('should update itself on user popstate interaction ', () => {
const spy = jest.spyOn(useLocationObj, 'default');
it('should update itself on user popstate interaction', () => {
const spy = jest.fn();

(useState as jest.Mock).mockImplementation(() => ['location', spy]);

renderHook(() => useLocationObj.default());

fireEvent(window, new window.PopStateEvent('popstate'));
fireEvent(window, new window.PopStateEvent('popstate'));
fireEvent(window, new window.PopStateEvent('popstate'));

expect(spy).toBeCalledTimes(3);
expect(spy).toBeCalledTimes(4);
});
});
8 changes: 4 additions & 4 deletions src/app/legacy/containers/StoryPromo/LinkContents/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ const LinkContents = ({ item, isInline, id }) => {
return 'photogallery';
}

const mediaType = pathOr(null, ['media', 'format'], item);

const mediaType = (
pathOr(null, ['media', 'format'], item) ||
pathOr(null, ['contentType'], item)
)?.toLowerCase();
return mediaType === 'audio' ? 'listen' : mediaType;
};

const type = getAnnouncedType();

// Always gets the first version. Smarter logic may be needed in the future.
const rawDuration = pathOr(null, ['media', 'versions', 0, 'duration'], item);
let offScreenDuration;
Expand All @@ -54,7 +55,6 @@ const LinkContents = ({ item, isInline, id }) => {
);
}
const mediaType = mediaTranslations[type];

return (
// role="text" is required to correct a text splitting bug on iOS VoiceOver.
// ID is a temporary fix for the a11y nested span's bug experienced in TalkBack, refer to the following issue: /~https://github.com/bbc/simorgh/issues/9652
Expand Down
5 changes: 4 additions & 1 deletion src/app/legacy/containers/StoryPromo/utilities/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ import {
MEDIA_ASSET_PAGE,
} from '#app/routes/utils/pageTypes';

// MAP is now either a Media Asset Page or a Media Article Page
export const isMap = item => {
const isCpsTypeMap = pathOr(null, ['cpsType'], item) === MEDIA_ASSET_PAGE;
const hasMedia = pathOr(false, ['media'], item);
const contentType = pathOr(null, ['contentType'], item);
const isOptimoMediaPromo = ['Audio', 'Video'].includes(contentType);

return isCpsTypeMap || Boolean(hasMedia);
return isCpsTypeMap || Boolean(hasMedia) || isOptimoMediaPromo;
};

export const getHeadingTagOverride = ({ pageType, isContentTypeGuide }) => {
Expand Down
4 changes: 3 additions & 1 deletion src/app/pages/TopicPage/TopicImage/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ const ImageWrapper = styled.div`
`;

const TopicImage = ({ image }) => {
const imageUrl = image.replace('/480/', '/128/');

return (
<BadgeWrapper>
<ImageWrapper>
<Image src={image} alt="" data-testid="topic-badge" />
<Image src={imageUrl} alt="" data-testid="topic-badge" />
</ImageWrapper>
</BadgeWrapper>
);
Expand Down
16 changes: 16 additions & 0 deletions src/app/pages/TopicPage/index.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,22 @@ describe('Topic Page', () => {
expect(container.getElementsByTagName('p').length).toEqual(1);
});

it('should resize the badge image from 480 to 128', () => {
const { queryByTestId } = render(
<TopicPage pageData={mundoWithBadgeAndDescr} />,
getOptionParams({ service: 'mundo', lang: 'es' }),
);

const topicBadge = queryByTestId('topic-badge');

expect(topicBadge).toBeInTheDocument();
const topicBadgeSrc = topicBadge.getAttribute('src');
expect(topicBadgeSrc).not.toBe(mundoWithBadgeAndDescr.imageData.url);
expect(topicBadgeSrc).toBe(
mundoWithBadgeAndDescr.imageData.url.replace('/480/', '/128/'),
);
});

it('should render description without badge', () => {
const { container, queryByTestId } = render(
<TopicPage pageData={pidginMultipleItems} service="pidgin" />,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ exports[`AMP Articles Footer Cookie Settings Button should match text and on han

exports[`AMP Articles Footer I can click on the BBC branding and it would take me to the homepage 1`] = `"/news"`;

exports[`AMP Articles Footer I can see the footer copyright and external linking text 1`] = `2023 BBC. The BBC is not responsible for the content of external sites. Read about our approach to external linking."`;
exports[`AMP Articles Footer I can see the footer copyright and external linking text 1`] = `2024 BBC. The BBC is not responsible for the content of external sites. Read about our approach to external linking."`;

exports[`AMP Articles Header I can see the branding 1`] = `"BBC News"`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ exports[`Canonical Articles Footer Anchors should match text and url 9`] = `

exports[`Canonical Articles Footer I can click on the BBC branding and it would take me to the homepage 1`] = `"/news"`;

exports[`Canonical Articles Footer I can see the footer copyright and external linking text 1`] = `2023 BBC. The BBC is not responsible for the content of external sites. Read about our approach to external linking."`;
exports[`Canonical Articles Footer I can see the footer copyright and external linking text 1`] = `2024 BBC. The BBC is not responsible for the content of external sites. Read about our approach to external linking."`;

exports[`Canonical Articles Header I can see the branding 1`] = `"BBC News"`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ exports[`AMP Articles Footer Cookie Settings Button should match text and on han

exports[`AMP Articles Footer I can click on the BBC branding and it would take me to the homepage 1`] = `"/persian"`;

exports[`AMP Articles Footer I can see the footer copyright and external linking text 1`] = `2023 بی بی سی. بی بی سی مسئول محتوای سایت های دیگر نیست. سیاست ما درباره لینک دادن به سایت های دیگر."`;
exports[`AMP Articles Footer I can see the footer copyright and external linking text 1`] = `2024 بی بی سی. بی بی سی مسئول محتوای سایت های دیگر نیست. سیاست ما درباره لینک دادن به سایت های دیگر."`;

exports[`AMP Articles Header I can see the branding 1`] = `"BBC News, فارسی"`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ exports[`Canonical Articles Footer Anchors should match text and url 8`] = `

exports[`Canonical Articles Footer I can click on the BBC branding and it would take me to the homepage 1`] = `"/persian"`;

exports[`Canonical Articles Footer I can see the footer copyright and external linking text 1`] = `2023 بی بی سی. بی بی سی مسئول محتوای سایت های دیگر نیست. سیاست ما درباره لینک دادن به سایت های دیگر."`;
exports[`Canonical Articles Footer I can see the footer copyright and external linking text 1`] = `2024 بی بی سی. بی بی سی مسئول محتوای سایت های دیگر نیست. سیاست ما درباره لینک دادن به سایت های دیگر."`;

exports[`Canonical Articles Header I can see the branding 1`] = `"BBC News, فارسی"`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ exports[`AMP Articles Footer Cookie Settings Button should match text and on han

exports[`AMP Articles Footer I can click on the BBC branding and it would take me to the homepage 1`] = `"/scotland"`;

exports[`AMP Articles Footer I can see the footer copyright and external linking text 1`] = `2023 BBC. The BBC is not responsible for the content of external sites. Read about our approach to external linking."`;
exports[`AMP Articles Footer I can see the footer copyright and external linking text 1`] = `2024 BBC. The BBC is not responsible for the content of external sites. Read about our approach to external linking."`;

exports[`AMP Articles Header I can see the branding 1`] = `"BBC Scotland"`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ exports[`Canonical Articles Footer Anchors should match text and url 8`] = `

exports[`Canonical Articles Footer I can click on the BBC branding and it would take me to the homepage 1`] = `"/scotland"`;

exports[`Canonical Articles Footer I can see the footer copyright and external linking text 1`] = `2023 BBC. The BBC is not responsible for the content of external sites. Read about our approach to external linking."`;
exports[`Canonical Articles Footer I can see the footer copyright and external linking text 1`] = `2024 BBC. The BBC is not responsible for the content of external sites. Read about our approach to external linking."`;

exports[`Canonical Articles Header I can see the branding 1`] = `"BBC Scotland"`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ exports[`AMP Feature Index page Footer Cookie Settings Button should match text

exports[`AMP Feature Index page Footer I can click on the BBC branding and it would take me to the homepage 1`] = `"/afrique"`;

exports[`AMP Feature Index page Footer I can see the footer copyright and external linking text 1`] = `2023 BBC. La BBC n'est pas responsable du contenu des sites externes. Découvrez notre approche en matière de liens externes."`;
exports[`AMP Feature Index page Footer I can see the footer copyright and external linking text 1`] = `2024 BBC. La BBC n'est pas responsable du contenu des sites externes. Découvrez notre approche en matière de liens externes."`;

exports[`AMP Feature Index page Header I can see the branding 1`] = `"BBC News, Afrique"`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ exports[`Canonical Feature Index page Footer Anchors should match text and url 8

exports[`Canonical Feature Index page Footer I can click on the BBC branding and it would take me to the homepage 1`] = `"/afrique"`;

exports[`Canonical Feature Index page Footer I can see the footer copyright and external linking text 1`] = `2023 BBC. La BBC n'est pas responsable du contenu des sites externes. Découvrez notre approche en matière de liens externes."`;
exports[`Canonical Feature Index page Footer I can see the footer copyright and external linking text 1`] = `2024 BBC. La BBC n'est pas responsable du contenu des sites externes. Découvrez notre approche en matière de liens externes."`;

exports[`Canonical Feature Index page Header I can see the branding 1`] = `"BBC News, Afrique"`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ exports[`AMP Feature Index page Footer Cookie Settings Button should match text

exports[`AMP Feature Index page Footer I can click on the BBC branding and it would take me to the homepage 1`] = `"/urdu"`;

exports[`AMP Feature Index page Footer I can see the footer copyright and external linking text 1`] = `2023 بی بی سی. بی بی سی بیرونی ویب سائٹس کے مواد کا ذمہ دار نہیں بیرونی لنکس کے بارے میں ہماری پالیسی."`;
exports[`AMP Feature Index page Footer I can see the footer copyright and external linking text 1`] = `2024 بی بی سی. بی بی سی بیرونی ویب سائٹس کے مواد کا ذمہ دار نہیں بیرونی لنکس کے بارے میں ہماری پالیسی."`;

exports[`AMP Feature Index page Header I can see the branding 1`] = `"BBC News, اردو"`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ exports[`Canonical Feature Index page Footer Anchors should match text and url 8

exports[`Canonical Feature Index page Footer I can click on the BBC branding and it would take me to the homepage 1`] = `"/urdu"`;

exports[`Canonical Feature Index page Footer I can see the footer copyright and external linking text 1`] = `2023 بی بی سی. بی بی سی بیرونی ویب سائٹس کے مواد کا ذمہ دار نہیں بیرونی لنکس کے بارے میں ہماری پالیسی."`;
exports[`Canonical Feature Index page Footer I can see the footer copyright and external linking text 1`] = `2024 بی بی سی. بی بی سی بیرونی ویب سائٹس کے مواد کا ذمہ دار نہیں بیرونی لنکس کے بارے میں ہماری پالیسی."`;

exports[`Canonical Feature Index page Header I can see the branding 1`] = `"BBC News, اردو"`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ exports[`AMP Front Page Footer Cookie Settings Button should match text and on h

exports[`AMP Front Page Footer I can click on the BBC branding and it would take me to the homepage 1`] = `"/serbian"`;

exports[`AMP Front Page Footer I can see the footer copyright and external linking text 1`] = `2023 BBC. BBC nije odgovoran za sadržaj drugih sajtova. Pročitajte naša pravila o linkovanju drugih sajtova."`;
exports[`AMP Front Page Footer I can see the footer copyright and external linking text 1`] = `2024 BBC. BBC nije odgovoran za sadržaj drugih sajtova. Pročitajte naša pravila o linkovanju drugih sajtova."`;

exports[`AMP Front Page Header I can see the branding 1`] = `"BBC News, na srpskom"`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ exports[`Canonical Front Page Footer Anchors should match text and url 8`] = `

exports[`Canonical Front Page Footer I can click on the BBC branding and it would take me to the homepage 1`] = `"/serbian"`;

exports[`Canonical Front Page Footer I can see the footer copyright and external linking text 1`] = `2023 BBC. BBC nije odgovoran za sadržaj drugih sajtova. Pročitajte naša pravila o linkovanju drugih sajtova."`;
exports[`Canonical Front Page Footer I can see the footer copyright and external linking text 1`] = `2024 BBC. BBC nije odgovoran za sadržaj drugih sajtova. Pročitajte naša pravila o linkovanju drugih sajtova."`;

exports[`Canonical Front Page Header I can see the branding 1`] = `"BBC News, na srpskom"`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ exports[`AMP Home Page Footer Cookie Settings Button should match text and on ha

exports[`AMP Home Page Footer I can click on the BBC branding and it would take me to the homepage 1`] = `"/arabic"`;

exports[`AMP Home Page Footer I can see the footer copyright and external linking text 1`] = `2023 بي بي سي. بي بي سي ليست مسؤولة عن محتوى المواقع الخارجية. سياستنا بخصوص الروابط الخارجية."`;
exports[`AMP Home Page Footer I can see the footer copyright and external linking text 1`] = `2024 بي بي سي. بي بي سي ليست مسؤولة عن محتوى المواقع الخارجية. سياستنا بخصوص الروابط الخارجية."`;

exports[`AMP Home Page Header I can see the branding 1`] = `"BBC News, عربي"`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ exports[`AMP Home Page Footer Cookie Settings Button should match text and on ha

exports[`AMP Home Page Footer I can click on the BBC branding and it would take me to the homepage 1`] = `"/kyrgyz"`;

exports[`AMP Home Page Footer I can see the footer copyright and external linking text 1`] = `2023 BBC. Би-Би-Си сырткы интернет сайттардын мазмуну үчүн жооптуу эмес. Башка интернет сайттардын мазмуну боюнча биздин позиция."`;
exports[`AMP Home Page Footer I can see the footer copyright and external linking text 1`] = `2024 BBC. Би-Би-Си сырткы интернет сайттардын мазмуну үчүн жооптуу эмес. Башка интернет сайттардын мазмуну боюнча биздин позиция."`;

exports[`AMP Home Page Header I can see the branding 1`] = `"BBC News, Кыргыз КызMATы"`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ exports[`Canonical Home Page Footer Anchors should match text and url 8`] = `

exports[`Canonical Home Page Footer I can click on the BBC branding and it would take me to the homepage 1`] = `"/kyrgyz"`;

exports[`Canonical Home Page Footer I can see the footer copyright and external linking text 1`] = `2023 BBC. Би-Би-Си сырткы интернет сайттардын мазмуну үчүн жооптуу эмес. Башка интернет сайттардын мазмуну боюнча биздин позиция."`;
exports[`Canonical Home Page Footer I can see the footer copyright and external linking text 1`] = `2024 BBC. Би-Би-Си сырткы интернет сайттардын мазмуну үчүн жооптуу эмес. Башка интернет сайттардын мазмуну боюнча биздин позиция."`;

exports[`Canonical Home Page Header I can see the branding 1`] = `"BBC News, Кыргыз КызMATы"`;

Expand Down
Loading

0 comments on commit 749d761

Please sign in to comment.