-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move preroll ads to main Cypress tests
- Loading branch information
1 parent
8e7bbdf
commit 690d2a1
Showing
3 changed files
with
118 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
], | ||
}, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`, () => {}); | ||
} | ||
}); | ||
}); |