Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 136 additions & 0 deletions ws-nextjs-app/cypress/e2e/liveRadioPage/index.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
import runTestsForPage, {
TestDataType,
} from '../../support/helpers/runTestsForPage';
import e2eTests from './tests';
import testsForAllPages from '../testsForAllPages';
import testsForAllCanonicalPages from '../testsForAllCanonicalPages';
import { assertPageView } from '../specialFeatures/atiAnalytics/assertions';
import {
assertRadioScheduleComponentClick,
assertRadioScheduleComponentView,
} from '../specialFeatures/atiAnalytics/assertions/radioSchedule';

const pageType = 'liveRadio';

const tests = [e2eTests, testsForAllPages, testsForAllCanonicalPages];

const testSuites = [
{
path: '/afaanoromoo/bbc_afaanoromoo_radio/liveradio',
service: 'afaanoromoo',
runforEnv: ['local', 'test', 'live'],
tests,
},
{
path: '/afrique/bbc_afrique_radio/liveradio',
service: 'afrique',
runforEnv: ['local', 'test', 'live'],
tests,
},
{
path: '/amharic/bbc_amharic_radio/liveradio',
service: 'amharic',
runforEnv: ['local', 'test', 'live'],
tests,
},
{
path: '/arabic/bbc_arabic_radio/liveradio',
service: 'arabic',
runforEnv: ['local', 'test', 'live'],
tests,
},
{
path: '/burmese/bbc_burmese_radio/liveradio',
service: 'burmese',
runforEnv: ['local', 'test', 'live'],
tests,
},
{
path: '/dari/bbc_dari_radio/liveradio',
service: 'dari',
runforEnv: ['test'],
tests,
},
{
path: '/gahuza/bbc_gahuza_radio/liveradio',
service: 'gahuza',
runforEnv: ['local', 'test', 'live'],
tests,
},
{
path: '/hausa/bbc_hausa_radio/liveradio',
service: 'hausa',
runforEnv: ['local', 'test', 'live'],
tests,
},
{
path: '/korean/bbc_korean_radio/liveradio',
service: 'korean',
runforEnv: ['local', 'test', 'live'],
tests,
},
{
path: '/nepali/bbc_nepali_radio/liveradio',
service: 'nepali',
runforEnv: ['local', 'test', 'live'],
tests,
},
{
path: '/pashto/bbc_pashto_radio/liveradio',
service: 'pashto',
runforEnv: ['local', 'test', 'live'],
tests,
},
{
path: '/somali/bbc_somali_radio/liveradio',
service: 'somali',
runforEnv: ['local', 'test', 'live'],
tests,
},
{
path: '/swahili/bbc_swahili_radio/liveradio',
service: 'swahili',
runforEnv: ['local', 'test', 'live'],
tests,
},
{
path: '/tigrinya/bbc_tigrinya_radio/liveradio',
service: 'tigrinya',
runforEnv: ['local', 'test', 'live'],
tests,
},
{
path: '/uzbek/bbc_uzbek_radio/liveradio',
service: 'uzbek',
runforEnv: ['local', 'test', 'live'],
tests,
},
] as unknown as TestDataType[];

const atiAnalyticsTestSuites = [
{
path: '/hausa/bbc_hausa_radio/liveradio',
runforEnv: ['local', 'live'],
service: 'hausa',
pageIdentifier: 'hausa.bbc_hausa_radio.liveradio.page',
siteId: 51,
applicationType: 'responsive',
contentType: 'player-live',
tests: [
assertPageView,
assertRadioScheduleComponentView,
assertRadioScheduleComponentClick,
],
},
] as unknown as TestDataType[];

runTestsForPage({
pageType,
testSuites,
});

runTestsForPage({
pageType: 'liveRadio',
testSuites: atiAnalyticsTestSuites,
testIsolation: true,
});
56 changes: 56 additions & 0 deletions ws-nextjs-app/cypress/e2e/liveRadioPage/tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/* eslint-disable import/prefer-default-export */

import chartbeatTests from '../../support/helpers/chartbeatTests';
// For testing features that may differ across services but share a common logic e.g. translated strings.
export default ({ service, pageType }) =>
describe(`Tests for ${service} ${pageType}`, () => {
beforeEach(() => {
cy.getToggles(service);
});
describe('LinkedData', () => {
// will be addressed by this https://github.com/bbc/simorgh/issues/3117
it.skip('should include mainEntityOfPage in the LinkedData', () => {
cy.get('script[type="application/ld+json"]')
.should('contain', 'mainEntityOfPage')
.and('contain', 'headline');
});
});

describe(
'Audio Player',
{
retries: 3,
},
() => {
it('should render a valid media player', () => {
cy.get('[data-e2e="media-loader__container"]').should('exist');
});
},
);

chartbeatTests();

describe('Radio Schedule', () => {
it('should be displayed if there is enough schedule data', function test() {
cy.fixture(`toggles/${service}.json`).then(toggles => {
const scheduleIsEnabled = toggles?.liveRadioSchedule?.enabled;
cy.log(
`Live Radio Page configured for Radio Schedule? ${scheduleIsEnabled}`,
);

if (scheduleIsEnabled) {
cy.getPageDataFromWindow().then(pageData => {
const { radioScheduleData } = pageData;

if (radioScheduleData) {
cy.log('Schedule has enough data');
cy.get('[data-e2e=radio-schedule]').should('exist');
} else {
cy.get('[data-e2e=radio-schedule]').should('not.exist');
}
});
}
});
});
});
});
Loading