Skip to content

Commit

Permalink
Move preroll ads to main Cypress tests
Browse files Browse the repository at this point in the history
  • Loading branch information
karinathomasbbc committed Nov 3, 2020
1 parent 8e7bbdf commit 690d2a1
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cypress.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"**/123PlaygroundForTests/**",
"**/specialFeatures/utilities/**",
"**/specialFeatures/**/testsForAMPOnly.js",
"**/specialFeatures/**/testsForCanonicalOnly.js"
"**/specialFeatures/**/testsForCanonicalOnly.js",
"**/specialFeatures/**/config.js"
],
"defaultCommandTimeout": 10000,
"pageLoadTimeout": 100000,
Expand Down
47 changes: 47 additions & 0 deletions cypress/integration/specialFeatures/prerollAds/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
export const mapsWithoutPreroll = {
local: [],
test: [],
live: [
{
reason: 'service does not have preroll ads enabled',
paths: [
'https://www.bbc.com/pidgin/media-44221514', // CPS Video
],
},
{
reason: 'Castaway advertising flag is false',
paths: [],
},
{
reason: 'duration is less than 30 seconds',
paths: [
'https://www.bbc.com/mundo/media-52481764', // CPS Video
],
},
],
};

export const mapsWithPreroll = {
local: [],
test: [],
live: [
{
service: 'afrique',
paths: [
'https://www.bbc.com/afrique/media-53045965', // CPS Video, advertising enabled, preroll enabled for afrique service
],
},
{
service: 'zhongwen',
paths: [
'https://www.bbc.com/zhongwen/simp/science-53136501', // CPS Video. advertising enabled, preroll enabled for zhongwen service
],
},
{
service: 'russian',
paths: [
// 'https://www.bbc.com/russian/media-52728860', // CPS Video
],
},
],
};
69 changes: 69 additions & 0 deletions cypress/integration/specialFeatures/prerollAds/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import path from 'ramda/src/path';
import getAppEnv from '../../../support/helpers/getAppEnv';
import { mapsWithPreroll, mapsWithoutPreroll } from './config';

const environment = getAppEnv();

describe('Media Asset Pages - Preroll Ads', () => {
describe('should not load the preroll ad plugin', () => {
const noPreroll = mapsWithoutPreroll[environment];

if (noPreroll && noPreroll.length > 0) {
noPreroll.forEach(map => {
const { paths, reason } = map;

describe(`because ${reason}`, () => {
paths.forEach(url => {
it(url, () => {
cy.visit(url);
cy.get('iframe').then(iframe => {
const embedUrl = iframe.prop('src');
cy.visit(embedUrl);
cy.get(`script[src*="dotcom-bootstrap.js"]`).should(
'not.exist',
);
});
});
});
});
});
} else {
it(`No MAPs without preroll ads configured for the ${environment} environment`, () => {});
}
});

describe('should load the preroll ad plugin', () => {
const withPreroll = mapsWithPreroll[environment];

if (withPreroll && withPreroll.length > 0) {
withPreroll.forEach(map => {
const { paths, service } = map;

if (paths.length > 0) {
paths.forEach(url => {
it(url, () => {
cy.getToggles(service).then(() => {
cy.fixture(`toggles/${service}.json`).then(toggles => {
const adsEnabled = path(['preroll', 'enabled'], toggles);

if (adsEnabled) {
cy.visit(url);
cy.get('iframe').then(iframe => {
const embedUrl = iframe.prop('src');
cy.visit(embedUrl);
cy.get(`script[src*="dotcom-bootstrap.js"]`).should(
'exist',
);
});
}
});
});
});
});
}
});
} else {
it(`No MAPs with preroll ads configured for the ${environment} environment`, () => {});
}
});
});

0 comments on commit 690d2a1

Please sign in to comment.