Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ondemand audio (Radio and Podcasts) - Remove tests (Unit, integration and E2E) against AMP versions of these pages #11799

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
6ab93a7
remove amp tests
LilyL0u Jul 25, 2024
796c4d0
.amp now not valid route regex and tests
LilyL0u Jul 26, 2024
25dd152
revert adding default false to isAmp in radioSchedule test
LilyL0u Jul 26, 2024
787bc97
regex change update snapshots
LilyL0u Jul 26, 2024
fa2bf8d
regex change update snapshots and tests
LilyL0u Jul 29, 2024
65bb578
change file names
LilyL0u Jul 29, 2024
2c32a8a
remove od audio from amp validator
LilyL0u Jul 29, 2024
63c0d83
Merge branch 'latest' into WSTEAMA-Ondemand-audio-remove-tests-(unit-…
LilyL0u Jul 29, 2024
3e17d67
default value for isAmp in radioSchedule
LilyL0u Jul 29, 2024
9783523
Merge branch 'latest' into WSTEAMA-Ondemand-audio-remove-tests-(unit-…
LilyL0u Jul 31, 2024
7ea7f45
Merge branch 'latest' into WSTEAMA-Ondemand-audio-remove-tests-(unit-…
LilyL0u Aug 6, 2024
864c348
exclude radio pages from cookie banner amp tests
LilyL0u Aug 6, 2024
664b497
Merge branch 'latest' into WSTEAMA-Ondemand-audio-remove-tests-(unit-…
LilyL0u Aug 6, 2024
efd7d38
Merge branch 'latest' into WSTEAMA-Ondemand-audio-remove-tests-(unit-…
LilyL0u Aug 6, 2024
f79fc21
Merge branch 'latest' into WSTEAMA-Ondemand-audio-remove-tests-(unit-…
louisearchibald Aug 7, 2024
94972c5
Merge branch 'latest' into WSTEAMA-Ondemand-audio-remove-tests-(unit-…
amoore108 Aug 7, 2024
30eba58
Merge branch 'latest' into WSTEAMA-Ondemand-audio-remove-tests-(unit-…
louisearchibald Aug 8, 2024
d0e9075
Merge branch 'latest' into WSTEAMA-Ondemand-audio-remove-tests-(unit-…
LilyL0u Aug 12, 2024
6c93b4a
Merge branch 'latest' into WSTEAMA-Ondemand-audio-remove-tests-(unit-…
LilyL0u Aug 12, 2024
d5e15a0
Merge branch 'latest' into WSTEAMA-Ondemand-audio-remove-tests-(unit-…
LilyL0u Aug 12, 2024
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
32 changes: 2 additions & 30 deletions cypress/e2e/pages/onDemandAudio/index.cy.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import config from '../../../support/config/services';
import getPaths from '../../../support/helpers/getPaths';
import serviceHasPageType from '../../../support/helpers/serviceHasPageType';
import testsForCanonicalOnly from './testsForCanonicalOnly';
import testsForAMPOnly from './testsForAMPOnly';
import crossPlatformTests from './tests';
import e2eTests from './tests';
import visitPage from '../../../support/helpers/visitPage';
import { overrideRendererOnTest } from '../../../support/helpers/onDemandRadioTv';

Expand All @@ -24,37 +22,11 @@ Object.keys(config)

visitPage(newPath, pageType);
});
crossPlatformTests({
service,
pageType,
variant,
});
testsForCanonicalOnly({
e2eTests({
service,
pageType,
variant,
});
});
});
paths
.map(path => `${path}.amp`)
.forEach(currentPath => {
describe(`${pageType} - ${currentPath}`, () => {
before(() => {
Cypress.env('currentPath', currentPath);
visitPage(currentPath, pageType);
});
crossPlatformTests({
service,
pageType,
variant,
isAmp: true,
});
testsForAMPOnly({
service,
pageType,
variant,
});
});
});
});
83 changes: 74 additions & 9 deletions cypress/e2e/pages/onDemandAudio/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ 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 {
isScheduleDataComplete,
getIsProgramValid,
} from '../../../../src/app/legacy/containers/RadioSchedule/utilities/evaluateScheduleData';

export default ({ service, pageType, variant, isAmp }) => {
export default ({ service, pageType, variant }) => {
describe(`Tests for ${service} ${pageType}`, () => {
describe(
'Audio Player',
Expand All @@ -30,7 +34,7 @@ export default ({ service, pageType, variant, isAmp }) => {
);
}
const language = appConfig[service][variant].lang;
const embedUrl = getEmbedUrl({ body: jsonData, language, isAmp });
const embedUrl = getEmbedUrl({ body: jsonData, language });
const isBrandPage = isBrand(jsonData);

cy.get('iframe').then(iframe => {
Expand Down Expand Up @@ -132,7 +136,6 @@ export default ({ service, pageType, variant, isAmp }) => {
convertTimestampsToLocaleString(processedEpisodesData);

const simorghJsonResWithLocaleStringTimestamp =
!isAmp &&
convertTimestampsToLocaleString(
win.SIMORGH_DATA.pageData.recentEpisodes,
);
Expand All @@ -147,12 +150,12 @@ export default ({ service, pageType, variant, isAmp }) => {
JSON.stringify(cypressJsonResWithLocaleStringTimestamp),
);
cy.log('HTML on page - ', renderedEpisodesInnerText);
if (!isAmp) {
cy.log(
'Simorgh json response - ',
JSON.stringify(simorghJsonResWithLocaleStringTimestamp),
);
}

cy.log(
'Simorgh json response - ',
JSON.stringify(simorghJsonResWithLocaleStringTimestamp),
);

/* eslint-enable no-console */
}

Expand Down Expand Up @@ -200,6 +203,68 @@ export default ({ service, pageType, variant, isAmp }) => {
});
});
});
describe('Radio Schedule', () => {
it('should be displayed if there is enough schedule data', function test() {
const currentPath = `${Cypress.env(
'currentPath',
)}.json${overrideRendererOnTest()}`;

cy.request(currentPath).then(({ body: jsonData }) => {
cy.fixture(`toggles/${service}.json`).then(toggles => {
const scheduleIsEnabled = path(
['onDemandRadioSchedule', 'enabled'],
toggles,
);
cy.log(
`On Demand Radio Page configured for Radio Schedule? ${scheduleIsEnabled}`,
);

if (scheduleIsEnabled) {
const masterBrand = jsonData.metadata.createdBy;

const schedulePath =
`/${service}/${masterBrand}/schedule.json${overrideRendererOnTest()}`.replace(
'bbc_afaanoromoo_radio',
'bbc_oromo_radio',
);

cy.request(schedulePath).then(({ body: scheduleJson }) => {
const { schedules } = scheduleJson;
const isProgramValid = getIsProgramValid(() => {});
const validSchedules = schedules.filter(isProgramValid);

const isRadioScheduleDataComplete = isScheduleDataComplete({
schedules: validSchedules,
});

cy.log(
`Radio Schedule is displayed? ${isRadioScheduleDataComplete}`,
);
if (scheduleIsEnabled && isRadioScheduleDataComplete) {
cy.log('Schedule has enough data');
cy.get('[data-e2e=radio-schedule]').should('exist');
// cy.get('[data-e2e=live]').should('exist');
} else {
cy.get('[data-e2e=radio-schedule]').should('not.exist');
}
});
} else {
cy.get('[data-e2e=radio-schedule]').should('not.exist');
}
});
});
});
});
});
describe('Chartbeat', () => {
if (envConfig.chartbeatEnabled) {
it('should have a script with src value set to chartbeat source', () => {
cy.hasScriptWithChartbeatSrc();
});
it('should have chartbeat config set to window object', () => {
cy.hasGlobalChartbeatConfig();
});
}
});
});
};
25 changes: 0 additions & 25 deletions cypress/e2e/pages/onDemandAudio/testsForAMPOnly.js

This file was deleted.

78 changes: 0 additions & 78 deletions cypress/e2e/pages/onDemandAudio/testsForCanonicalOnly.js

This file was deleted.

3 changes: 2 additions & 1 deletion cypress/e2e/specialFeatures/cookieBanner/index.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const getPaths = service =>
);

const pageType = 'all';
const urlsToExcludeFromAmpTests = ['_tv', '_radio'];

Object.keys(config)
.filter(service => serviceFilter(service))
Expand All @@ -57,7 +58,7 @@ Object.keys(config)
paths
.map(path => `${path}.amp`)
.forEach(path => {
if (!path.includes('tv')) {
if (!urlsToExcludeFromAmpTests.some(url => path.includes(url))) {
describeForEuOnly(`${path} - AMP Cookie Banner`, () => {
beforeEach(() => {
visitPage(path, pageType);
Expand Down
1 change: 0 additions & 1 deletion scripts/ampHtmlValidator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const pageTypes = [
'liveRadio',
'photoGalleryPage',
'mostReadPage',
'onDemandAudio',
'onDemandTV',
'mediaAssetPage',
'storyPage',
Expand Down
3 changes: 0 additions & 3 deletions src/app/pages/OnDemandAudioPage/OnDemandAudioPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import pathOr from 'ramda/src/pathOr';
import useLocation from '#hooks/useLocation';
import ComscoreAnalytics from '#containers/ComscoreAnalytics';
import Grid, { GelPageGrid } from '#components/Grid';
import { RequestContext } from '#contexts/RequestContext';
import StyledRadioHeadingContainer from '#containers/OnDemandHeading/StyledRadioHeadingContainer';
import OnDemandParagraphContainer from '#containers/OnDemandParagraph';
import AVPlayer from '#containers/AVPlayer';
Expand Down Expand Up @@ -108,7 +107,6 @@ const OnDemandAudioPage = ({ pageData, mediaIsAvailable, MediaError }) => {

const pageType = path(['metadata', 'type'], pageData);

const { isAmp } = useContext(RequestContext);
const location = useLocation();
const { dir, liveRadioOverrides, lang, service, translations, serviceName } =
useContext(ServiceContext);
Expand All @@ -124,7 +122,6 @@ const OnDemandAudioPage = ({ pageData, mediaIsAvailable, MediaError }) => {
const embedUrl = getEmbedUrl({
mediaId,
type: 'media',
isAmp,
queryString: location.search,
});

Expand Down
Loading
Loading