Skip to content

Commit

Permalink
Merge branch 'latest' into amp-iframe-externalembed-constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
amoore108 committed Sep 30, 2024
2 parents 25548b3 + 85f5314 commit e2ab09b
Show file tree
Hide file tree
Showing 22 changed files with 4,429 additions and 773 deletions.
41 changes: 5 additions & 36 deletions cypress/e2e/pages/onDemandAudio/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@
/* eslint-disable consistent-return */
import path from 'ramda/src/path';
import {
isAvailable,
getEpisodeAvailability,
overrideRendererOnTest,
getEmbedUrl,
isBrand,
} from '../../../support/helpers/onDemandRadioTv';
import envConfig from '../../../support/config/envs';
import appConfig from '../../../../src/server/utilities/serviceConfigs';
import getDataUrl from '../../../support/helpers/getDataUrl';
import processRecentEpisodes from '../../../../src/app/routes/utils/processRecentEpisodes';
import {
Expand All @@ -24,43 +21,15 @@ export default ({ service, pageType, variant }) => {
retries: 3,
},
() => {
it('should render an iframe with a valid URL', () => {
cy.request(
`${Cypress.env('currentPath')}.json${overrideRendererOnTest()}`,
).then(({ body: jsonData }) => {
if (!isAvailable(jsonData)) {
it('should render a valid media player', () => {
cy.getPageDataFromWindow().then(({ pageData }) => {
if (!getEpisodeAvailability(pageData)) {
return cy.log(
`Episode is not available: ${Cypress.env('currentPath')}`,
);
}
const language = appConfig[service][variant].lang;
const embedUrl = getEmbedUrl({ body: jsonData, language });
const isBrandPage = isBrand(jsonData);

cy.get('iframe').then(iframe => {
let iframeURL = isBrandPage ? iframe.prop('src') : embedUrl;
iframeURL = iframeURL.split('.com').pop();
cy.log(`cy.get('iframe') assertion has already happened`);
cy.log(
`used for Brand - iframe.prop('src') = ${iframe.prop('src')}`,
);
cy.log(`used for Episode - embedURL = ${embedUrl}`);
cy.log(`selector for iframe = iframe[src*="${iframeURL}"]`);
const pathTested = embedUrl.replace(
/^\//,
`${envConfig.baseUrl}/`,
);
cy.log(`path that will have response tested is ${pathTested}`);

cy.get(`iframe[src*="${iframeURL}"]`).should('be.visible');
cy.testResponseCodeAndTypeRetry({
// embedUrl may be relative - making it absolute to test the response
path: embedUrl.replace(/^\//, `${envConfig.baseUrl}/`),
responseCode: 200,
type: 'text/html',
allowFallback: true,
});
});
cy.get('[data-e2e="media-loader__container"]').should('be.visible');
});
});
},
Expand Down
8 changes: 0 additions & 8 deletions cypress/support/helpers/onDemandRadioTv.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import path from 'ramda/src/path';
import pathEq from 'ramda/src/pathEq';

import envConfig from '../config/envs';

Expand Down Expand Up @@ -32,13 +31,6 @@ export const getEmbedUrl = ({ body, language, isAmp }) => {
return isAmp ? `${embedUrl}/amp` : embedUrl;
};

export const isAvailable = pathEq('available', [
'content',
'blocks',
'0',
'availability',
]);

export const getEpisodeAvailability = ({ mediaBlocks }) =>
mediaBlocks[0]?.model?.availability === 'available';

Expand Down
118 changes: 118 additions & 0 deletions data/bengali/bbc_bangla_radio/p030vjwg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
{
"metadata": {
"id": "urn:bbc:ares:ws_media:brand:bbc_bangla_radio/p030vjwg",
"locators": {
"pid": "w172yylmc0c11jh",
"brandPid": "p030vjwg"
},
"type": "WSRADIO",
"createdBy": "bbc_bangla_radio",
"language": "bn",
"lastUpdated": 1727190718000,
"firstPublished": 1670857206000,
"lastPublished": 1670857206000,
"timestamp": 1670857206000,
"options": {},
"analyticsLabels": {
"pageTitle": "প্রবাহ - BBC News বাংলা",
"pageIdentifier": "bengali.bbc_bangla_radio.programmes.p030vjwg.page",
"producerId": "31",
"contentType": "player-episode",
"producer": "BENGALI"
},
"passport": {
"home": "",
"taggings": []
},
"tags": {},
"version": "v1.4.48",
"blockTypes": [
"media"
],
"title": "প্রবাহ",
"releaseDateTimeStamp": 1673827200000,
"useSensitiveOnwardJourneys": false
},
"content": {
"blocks": [
{
"id": "w172yylmc0c11jh",
"subType": "episode",
"format": "Audio",
"title": "16/01/2023 GMT",
"synopses": {
"short": "বিবিসি বাংলা থেকে সংবাদ, সমসাময়িক ঘটনা, বিশেষ প্রতিবেদন, খেলা-ধুলা, ফোন-ইন আর বিতর্ক",
"medium": "বিবিসি বাংলা থেকে সংবাদ, সমসাময়িক ঘটনা, বিশেষ প্রতিবেদন, খেলা-ধুলা, ফোন-ইন আর বিতর্ক"
},
"imageUrl": "ichef.bbci.co.uk/images/ic/$recipe/p08b2kb7.png",
"embedding": false,
"advertising": false,
"versions": [],
"availability": "notAvailable",
"smpKind": "radioProgramme",
"episodeTitle": "প্রবাহ",
"type": "media"
}
]
},
"promo": {
"headlines": {
"headline": "প্রবাহ"
},
"locators": {
"pid": "w172yylmc0c11jh",
"brandPid": "p030vjwg"
},
"media": {
"id": "w172yylmc0c11jh",
"subType": "episode",
"format": "Audio",
"title": "16/01/2023 GMT",
"synopses": {
"short": "বিবিসি বাংলা থেকে সংবাদ, সমসাময়িক ঘটনা, বিশেষ প্রতিবেদন, খেলা-ধুলা, ফোন-ইন আর বিতর্ক",
"medium": "বিবিসি বাংলা থেকে সংবাদ, সমসাময়িক ঘটনা, বিশেষ প্রতিবেদন, খেলা-ধুলা, ফোন-ইন আর বিতর্ক"
},
"imageUrl": "ichef.bbci.co.uk/images/ic/$recipe/p08b2kb7.png",
"embedding": false,
"advertising": false,
"versions": [],
"availability": "notAvailable",
"smpKind": "radioProgramme",
"episodeTitle": "প্রবাহ",
"type": "media"
},
"indexImage": {
"id": "p08b2kb7",
"subType": "index",
"href": "ichef.bbci.co.uk/images/ic/$recipe/p08b2kb7.png",
"path": "ichef.bbci.co.uk/images/ic/$recipe/p08b2kb7.png",
"height": 576,
"width": 1025,
"altText": "পরিক্রমা",
"caption": "সংবাদ বুলেটিনসহ সমসাময়িক ঘটনা নিয়ে দৈনিক অনুষ্ঠান, সাথে সাপ্তাহিক ফোন-ইন, বিতর্ক ও ফিচার",
"copyrightHolder": null,
"type": "image"
},
"releaseDateTimestamp": 1673827200000,
"brand": {
"pid": "p030vjwg",
"title": "প্রবাহ"
},
"id": "urn:bbc:ares:ws_media:page:bbc_bangla_radio/w172yylmc0c11jh",
"type": "ws_radio"
},
"relatedContent": {
"site": {
"subType": "site",
"name": "Bengali",
"uri": "/bengali",
"type": "simple"
},
"groups": [
{
"type": "other-episode",
"promos": []
}
]
}
}
Loading

0 comments on commit e2ab09b

Please sign in to comment.