Skip to content

Commit

Permalink
Merge pull request #12052 from bbc/WSTEAMA-1407-uzbek-homepage-script…
Browse files Browse the repository at this point in the history
…-switch

WSTEAMA-1407: Add script switch link to the Uzbek homepage
  • Loading branch information
karinathomasbbc authored Oct 23, 2024
2 parents c067a6b + 75833fe commit cb27e04
Show file tree
Hide file tree
Showing 5 changed files with 175 additions and 31 deletions.
61 changes: 61 additions & 0 deletions data/uzbek/homePage/cyr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"data": {
"title": "Uzbek",
"description": "",
"pageType": "home",
"curations": [
{
"summaries": [
{
"type": "article",
"isLive": false,
"title": "Суриянинг темир хоними Асмо Асад ким?",
"firstPublished": "2024-07-30T16:58:46.760Z",
"lastPublished": "2024-07-30T16:58:46.760Z",
"link": "https://www.bbc.com/uzbek/articles/cve6ql6nr9do",
"imageUrl": "https://ichef.bbci.co.uk/ace/ws/{width}/cpsdevpb/8e45/test/ee2a18b0-4e93-11ef-ae89-b10ee2354b32.jpg.webp",
"imageAlt": "Россиянинг Яқин Шарқдаги асосий иттифоқчиси Сурия 13 йиллик урушдан кейин вайронага айланган. Ундан нима қолган бўлса",
"id": "cve6ql6nr9do"
},
{
"type": "article",
"isLive": false,
"title": "Сўз сизга: Ўзбекистон аҳолиси 37 миллиондан ошди деб мақтанамиз, лекин миллионлар ишсиз ё мардикор",
"firstPublished": "2024-09-16T15:46:52.239Z",
"lastPublished": "2024-09-16T15:46:52.239Z",
"link": "https://www.bbc.com/uzbek/articles/cl066728v0zo",
"imageUrl": "https://ichef.bbci.co.uk/ace/ws/{width}/cpsprodpb/36D1/production/_127933041__63970643_bbc-news-world-service-logo-nc.png.webp",
"id": "cl066728v0zo"
},
{
"type": "article",
"isLive": false,
"title": "Борис Николаевич Ельцин",
"firstPublished": "2024-10-07T09:52:06.034Z",
"lastPublished": "2024-10-07T09:58:27.823Z",
"link": "https://www.bbc.com/uzbek/articles/c6328w94722o/cyr",
"imageUrl": "https://ichef.bbci.co.uk/ace/ws/{width}/cpsprodpb/36D1/production/_127933041__63970643_bbc-news-world-service-logo-nc.png.webp",
"id": "c6328w94722o"
}
],
"activePage": 1,
"pageCount": 1,
"curationId": "urn:bbc:tipo:list:40724044-f99a-412d-a948-1f7410adeeab",
"curationType": "tipo-curation",
"position": 0,
"title": "Top Stories",
"visualProminence": "HIGH",
"visualStyle": "COLLECTION"
}
],
"metadata": {
"atiAnalytics": {
"contentId": "urn:bbc:tipo:topic:cvp5j113ngqt",
"contentType": "index-home",
"pageIdentifier": "uzbekcyr.page",
"pageTitle": "Uzbek"
}
}
},
"contentType": "application/json; charset=utf-8"
}
Empty file removed data/uzbek/homePage/index.json
Empty file.
61 changes: 61 additions & 0 deletions data/uzbek/homePage/lat.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"data": {
"title": "Uzbek",
"description": "",
"pageType": "home",
"curations": [
{
"summaries": [
{
"type": "article",
"isLive": false,
"title": "Суриянинг темир хоними Асмо Асад ким?",
"firstPublished": "2024-07-30T16:58:46.760Z",
"lastPublished": "2024-07-30T16:58:46.760Z",
"link": "https://www.bbc.com/uzbek/articles/cve6ql6nr9do",
"imageUrl": "https://ichef.bbci.co.uk/ace/ws/{width}/cpsdevpb/8e45/test/ee2a18b0-4e93-11ef-ae89-b10ee2354b32.jpg.webp",
"imageAlt": "Россиянинг Яқин Шарқдаги асосий иттифоқчиси Сурия 13 йиллик урушдан кейин вайронага айланган. Ундан нима қолган бўлса",
"id": "cve6ql6nr9do"
},
{
"type": "article",
"isLive": false,
"title": "Сўз сизга: Ўзбекистон аҳолиси 37 миллиондан ошди деб мақтанамиз, лекин миллионлар ишсиз ё мардикор",
"firstPublished": "2024-09-16T15:46:52.239Z",
"lastPublished": "2024-09-16T15:46:52.239Z",
"link": "https://www.bbc.com/uzbek/articles/cl066728v0zo",
"imageUrl": "https://ichef.bbci.co.uk/ace/ws/{width}/cpsprodpb/36D1/production/_127933041__63970643_bbc-news-world-service-logo-nc.png.webp",
"id": "cl066728v0zo"
},
{
"type": "article",
"isLive": false,
"title": "Борис Николаевич Ельцин",
"firstPublished": "2024-10-07T09:52:06.034Z",
"lastPublished": "2024-10-07T09:58:27.823Z",
"link": "https://www.bbc.com/uzbek/articles/c6328w94722o/cyr",
"imageUrl": "https://ichef.bbci.co.uk/ace/ws/{width}/cpsprodpb/36D1/production/_127933041__63970643_bbc-news-world-service-logo-nc.png.webp",
"id": "c6328w94722o"
}
],
"activePage": 1,
"pageCount": 1,
"curationId": "urn:bbc:tipo:list:40724044-f99a-412d-a948-1f7410adeeab",
"curationType": "tipo-curation",
"position": 0,
"title": "Top Stories",
"visualProminence": "HIGH",
"visualStyle": "COLLECTION"
}
],
"metadata": {
"atiAnalytics": {
"contentId": "urn:bbc:tipo:topic:cvp5j113ngqt",
"contentType": "index-home",
"pageIdentifier": "uzbeklat.page",
"pageTitle": "Uzbek"
}
}
},
"contentType": "application/json; charset=utf-8"
}
4 changes: 2 additions & 2 deletions src/app/legacy/containers/Header/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import SkipLink from '#psammead/psammead-brand/src/SkipLink';
import { RequestContext } from '#contexts/RequestContext';
import useOperaMiniDetection from '#hooks/useOperaMiniDetection';
import ScriptLink from '#app/components/Header/ScriptLink';
import { ARTICLE_PAGE } from '#app/routes/utils/pageTypes';
import { ARTICLE_PAGE, HOME_PAGE } from '#app/routes/utils/pageTypes';
import { ServiceContext } from '../../../contexts/ServiceContext';
import ConsentBanner from '../ConsentBanner';
import NavigationContainer from '../Navigation';
Expand Down Expand Up @@ -72,7 +72,7 @@ const HeaderContainer = ({
let shouldRenderScriptSwitch = false;

if (scriptLink && renderScriptSwitch) {
if (service === 'uzbek' && pageType !== ARTICLE_PAGE) {
if (service === 'uzbek' && ![ARTICLE_PAGE, HOME_PAGE].includes(pageType)) {
shouldRenderScriptSwitch = false;
} else {
shouldRenderScriptSwitch = true;
Expand Down
80 changes: 51 additions & 29 deletions src/app/legacy/containers/Header/index.test.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import React from 'react';
import {
INDEX_PAGE,
ARTICLE_PAGE,
FRONT_PAGE,
MEDIA_PAGE,
MEDIA_ASSET_PAGE,
TOPIC_PAGE,
} from '#app/routes/utils/pageTypes';
import * as PAGE_TYPES from '#app/routes/utils/pageTypes';
import userEvent from '@testing-library/user-event';
import Cookies from 'js-cookie';
import {
Expand All @@ -17,6 +10,16 @@ import {
import { service as pidginServiceConfig } from '../../../lib/config/services/pidgin';
import HeaderContainer from './index';

const {
INDEX_PAGE,
ARTICLE_PAGE,
FRONT_PAGE,
MEDIA_PAGE,
MEDIA_ASSET_PAGE,
TOPIC_PAGE,
HOME_PAGE,
} = PAGE_TYPES;

const defaultToggleState = {
scriptLink: {
enabled: true,
Expand Down Expand Up @@ -134,28 +137,47 @@ describe(`Header`, () => {
expect(container.querySelectorAll(scriptLinkSelector).length).toBe(1);
});

it('should not render script link for uzbek when it is not an article page ', () => {
const { container } = HeaderContainerWithContext({
renderOptions: {
pageType: FRONT_PAGE,
service: 'uzbek',
variant: 'cyr',
},
describe('when service is uzbek', () => {
describe.each(['cyr', 'lat'])('and variant is %s', variant => {
const supportedUzbekPageTypes = [ARTICLE_PAGE, HOME_PAGE];
const unsupportedUzbekPageTypes = Object.values(PAGE_TYPES).filter(
pageType => !supportedUzbekPageTypes.includes(pageType),
);

it.each(supportedUzbekPageTypes)(
'should render script link when page type is %s',
pageType => {
const { container } = HeaderContainerWithContext({
renderOptions: {
pageType,
service: 'uzbek',
variant,
},
});

expect(container.querySelectorAll(scriptLinkSelector).length).toBe(
1,
);
},
);

it.each(unsupportedUzbekPageTypes)(
'should not render script link when page type is %s',
pageType => {
const { container } = HeaderContainerWithContext({
renderOptions: {
pageType,
service: 'uzbek',
variant,
},
});

expect(container.querySelectorAll(scriptLinkSelector).length).toBe(
0,
);
},
);
});

expect(container.querySelectorAll(scriptLinkSelector).length).toBe(0);
});

it('should render script link for uzbek when it is an article page ', () => {
const { container } = HeaderContainerWithContext({
renderOptions: {
pageType: ARTICLE_PAGE,
service: 'uzbek',
variant: 'cyr',
},
});

expect(container.querySelectorAll(scriptLinkSelector).length).toBe(1);
});

it('should not render script link on Topic page when missing variant topic ID', () => {
Expand Down

0 comments on commit cb27e04

Please sign in to comment.