Skip to content

Commit

Permalink
Merge pull request #12188 from bbc/WSTEAM1-1461-simorgh-fetch-tv-from…
Browse files Browse the repository at this point in the history
…-bff

WSTEAM1-1461: Fetch On Demand TV data from BFF
  • Loading branch information
karinathomasbbc authored Dec 6, 2024
2 parents cd0e4db + 7d19696 commit a7fefa1
Show file tree
Hide file tree
Showing 65 changed files with 6,719 additions and 14,039 deletions.
58 changes: 15 additions & 43 deletions cypress/e2e/pages/onDemandTV/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import {
getEpisodeAvailability,
videoPlaceholderImageUrl,
} from '../../../support/helpers/onDemandRadioTv';
import getDataUrl from '../../../support/helpers/getDataUrl';
import processRecentEpisodes from '../../../../src/app/routes/utils/processRecentEpisodes';

export default ({ service, pageType, variant }) => {
describe(`Tests for ${service} ${pageType}`, () => {
Expand Down Expand Up @@ -62,55 +60,29 @@ export default ({ service, pageType, variant }) => {
);
// There cannot be more episodes shown than the max allowed
if (recentEpisodesEnabled) {
const recentEpisodesMaxNumber = path(
['recentVideoEpisodes', 'value'],
toggles,
const recentEpisodesMaxNumber = parseInt(
toggles?.recentVideoEpisodes.value,
10,
);
const currentPath = Cypress.env('currentPath');
const url =
Cypress.env('APP_ENV') === 'test'
? `${currentPath}?renderer_env=live`
: `${currentPath}`;

cy.request(getDataUrl(url)).then(({ body }) => {
const episodeId = path(['content', 'blocks', 0, 'id'], body);

const expectedNumberOfEpisodes = processRecentEpisodes(body, {
exclude: episodeId,
recentEpisodesLimit: recentEpisodesMaxNumber,
}).length;
cy.log(
`Number of available episodes? ${recentEpisodesMaxNumber}`,
);
// More than one episode expected
cy.getPageDataFromWindow().then(data => {
const { recentEpisodes } = data;
cy.log({ recentEpisodes });

cy.log(
`Number of available episodes? ${expectedNumberOfEpisodes}`,
);
// More than one episode expected
if (expectedNumberOfEpisodes > 1) {
if (recentEpisodes?.length > 0 && recentEpisodesMaxNumber > 1) {
cy.get('[data-e2e=recent-episodes-list]').should('exist');

cy.get('[data-e2e=recent-episodes-list]').within(() => {
cy.get('[data-e2e=recent-episodes-list-item]')
.its('length')
.should('eq', expectedNumberOfEpisodes);
cy.get('[data-e2e=recent-episodes-list-item]').should(
'have.length.of.at.most',
recentEpisodesMaxNumber,
);
});
}
// If there is only one item, it is not in a list
else if (expectedNumberOfEpisodes === 1) {
cy.get('aside[aria-labelledby=recent-episodes]').within(
() => {
cy.get('[data-e2e="recent-episodes-list"]').should(
'not.exist',
);
},
);
}
// No items expected
else {
cy.get('aside[aria-labelledby=recent-episodes]').should(
'not.exist',
);

cy.log('No episodes present or available');
}
});
}
// Not toggled on for this service
Expand Down
2 changes: 1 addition & 1 deletion cypress/support/config/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -1998,7 +1998,7 @@ module.exports = () => ({
},
local: {
paths: [
'/hausa/bbc_hausa_tv/tv/w172xcg0kg6vph8', // Episode
'/hausa/bbc_hausa_tv/tv/w172yjj7rfhxp1p', // Episode
],
enabled: true,
},
Expand Down
Loading

0 comments on commit a7fefa1

Please sign in to comment.