From cc9115fe4b3a82fadf49cbed3dc23b7498f2071a Mon Sep 17 00:00:00 2001 From: Melissa Date: Mon, 10 Oct 2016 14:55:47 -0500 Subject: [PATCH 01/21] wip --- elements/bulbs-video/components/revealed.js | 26 +++++++++++------ lib/bulbs-elements/settings.js | 31 +++++++++++++++++++++ 2 files changed, 49 insertions(+), 8 deletions(-) create mode 100644 lib/bulbs-elements/settings.js diff --git a/elements/bulbs-video/components/revealed.js b/elements/bulbs-video/components/revealed.js index 217f56fd..110d2161 100644 --- a/elements/bulbs-video/components/revealed.js +++ b/elements/bulbs-video/components/revealed.js @@ -8,11 +8,10 @@ import Comscore from '../plugins/comscore'; import React, { PropTypes } from 'react'; import invariant from 'invariant'; +import SETTINGS from 'bulbs-elements/settings'; -// FIXME: where should this be defined? Per-app? -// Or in some better sort of settings file here? -global.BULBS_ELEMENTS_ONIONSTUDIOS_GA_ID = 'UA-223393-14'; -global.BULBS_ELEMENTS_COMSCORE_ID = '6036328'; +global.BULBS_ELEMENTS_ONIONSTUDIOS_GA_ID = SETTINGS.BULBS_ELEMENTS_ONIONSTUDIOS_GA_ID; +global.BULBS_ELEMENTS_COMSCORE_ID = SETTINGS.BULBS_ELEMENTS_COMSCORE_ID; let prefixCount = 0; function makeGaPrefix () { @@ -40,6 +39,11 @@ export default class Revealed extends React.Component { '`` requires `jwplayer` to be in global scope.' ); + invariant( + window.isMobile, + '`` requires `isMobile()` to be set on window.' + ); + let gaPrefix = makeGaPrefix(); ga('create', BULBS_ELEMENTS_ONIONSTUDIOS_GA_ID, 'auto', { name: gaPrefix }); @@ -157,12 +161,18 @@ export default class Revealed extends React.Component { } vastUrl (videoMeta) { - let baseUrl = 'http://us-theonion.videoplaza.tv/proxy/distributor/v2?rt=vast_2.0'; - + let baseUrl = `http://${SETTINGS.FREEWHEEL_NETWORK_ID}v.fwmrm.net/ad/g/1?`; let vastTestId = this.vastTest(window.location.search); - // AD_TYPE: one of p (preroll), m (midroll), po (postroll), o (overlay) - baseUrl += '&tt=p'; + if (window.isMobile.any) { + var prof = 'theonion_mobileweb_html5'; + } else { + var prof = 'theonion_desktop_html5'; + } + + baseUrl += '&resp=' + SETTINGS.RESP; + baseUrl += '&prof=' + prof; + videoMeta.tags.push('html5'); // Force HTML 5 // Tags baseUrl += '&t=' + videoMeta.tags; diff --git a/lib/bulbs-elements/settings.js b/lib/bulbs-elements/settings.js new file mode 100644 index 00000000..b86834b4 --- /dev/null +++ b/lib/bulbs-elements/settings.js @@ -0,0 +1,31 @@ +let settings = { + base: { + BULBS_ELEMENTS_ONIONSTUDIOS_GA_ID: 'UA-223393-14', + BULBS_ELEMENTS_COMSCORE_ID: '6036328', + RESP: 'vmap1', + }, + development: { + FREEWHEEL_NETWORK_ID: '111976', + }, + test: { + FREEWHEEL_NETWORK_ID: '111976', + }, + production: { + FREEWHEEL_NETWORK_ID: '123456', + } +} + +function getEnvironment () { + let envValues; + if (process.env.NODE_ENV === 'production') { + envValues = settings.production; + } else if ( process.env.NODE_ENV === 'test') { + envValues = settings.test; + } else { + envValues = settings.development; + } + return Object.assign(settings.base, envValues); +}; + +let SETTINGS = getEnvironment(); +export default SETTINGS; From fa3aeeb10116c7b50eeb421662575ad70a17df68 Mon Sep 17 00:00:00 2001 From: Melissa Date: Mon, 10 Oct 2016 15:14:14 -0500 Subject: [PATCH 02/21] update specs --- .../bulbs-video/components/revealed.test.js | 44 ++++++++++++++----- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/elements/bulbs-video/components/revealed.test.js b/elements/bulbs-video/components/revealed.test.js index 88d9ee8f..3b6973ee 100644 --- a/elements/bulbs-video/components/revealed.test.js +++ b/elements/bulbs-video/components/revealed.test.js @@ -94,6 +94,8 @@ describe(' ', () => { describe('componentDidMount globalsCheck', () => { global.BULBS_ELEMENTS_ONIONSTUDIOS_GA_ID = 'a-ga-id'; + window.isMobile = () => {}; + window.isMobile.any = false; global.ga = () => {}; const globals = [ @@ -533,6 +535,8 @@ describe(' ', () => { let videoMeta; let cacheBusterStub; let vastTestStub; + let vastUrl; + let parsed; context('default', () => { beforeEach(() => { @@ -547,20 +551,40 @@ describe(' ', () => { }); it('returns the vast url', function () { - let vastUrl = Revealed.prototype.vastUrl.call({ + vastUrl = Revealed.prototype.vastUrl.call({ cacheBuster: cacheBusterStub, vastTest: vastTestStub, }, videoMeta); - let parsed = url.parse(vastUrl, true); + parsed = url.parse(vastUrl, true); expect(parsed.protocol).to.eql('http:'); - expect(parsed.host).to.eql('us-theonion.videoplaza.tv'); - expect(parsed.pathname).to.eql('/proxy/distributor/v2'); - expect(Object.keys(parsed.query)).to.eql(['rt', 'tt', 't', 's', 'rnd']); - expect(parsed.query.rt).to.eql('vast_2.0'); - expect(parsed.query.tt).to.eql('p'); - expect(parsed.query.t).to.eql('clickhole,main,12345,html5'); - expect(parsed.query.s).to.eql('host_channel/channel_slug'); - expect(parsed.query.rnd).to.eql('456'); + expect(parsed.host).to.eql('111976v.fwmrm.net'); + expect(parsed.pathname).to.eql('/ad/g/1'); + }); + + it('populates keys for required global params', () => { + let expectedQueryKeys = [ + 'resp', 'prof', 'csid', 'caid', 'pvrn', 'vprn', 'cana' + ]; + let queryKeys = Object.keys(parsed.query); + expect(queryKeys).to.eql(expectedQueryKeys); + }); + + context('populates values for required global params', () => { + it('resp', function () { + expect(parsed.query.resp).to.eql('vmap1'); + }); + it('prof', function () { + //desktop + expect(parsed.query.prof).to.eql('theonion_desktop_html5'); + //mobile + window.isMobile.any = true; + vastUrl = Revealed.prototype.vastUrl.call({ + cacheBuster: cacheBusterStub, + vastTest: vastTestStub, + }, videoMeta); + parsed = url.parse(vastUrl, true); + expect(parsed.query.prof).to.eql('theonion_mobileweb_html5'); + }); }); }); From 57f4d6c5a139617ef4630737f40c52a0c0f8adbd Mon Sep 17 00:00:00 2001 From: Melissa Date: Mon, 10 Oct 2016 16:36:33 -0500 Subject: [PATCH 03/21] add getProfValue function --- elements/bulbs-video/components/revealed.js | 16 ++++++---- .../bulbs-video/components/revealed.test.js | 29 ++++++++++++------- 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/elements/bulbs-video/components/revealed.js b/elements/bulbs-video/components/revealed.js index 110d2161..56000ab8 100644 --- a/elements/bulbs-video/components/revealed.js +++ b/elements/bulbs-video/components/revealed.js @@ -160,16 +160,20 @@ export default class Revealed extends React.Component { return false; } + getProfValue () { + if (window.isMobile.any) { + return 'theonion_mobileweb_html5'; + } else { + return 'theonion_desktop_html5'; + } + } + vastUrl (videoMeta) { let baseUrl = `http://${SETTINGS.FREEWHEEL_NETWORK_ID}v.fwmrm.net/ad/g/1?`; let vastTestId = this.vastTest(window.location.search); - if (window.isMobile.any) { - var prof = 'theonion_mobileweb_html5'; - } else { - var prof = 'theonion_desktop_html5'; - } + let prof = this.getProfValue(); baseUrl += '&resp=' + SETTINGS.RESP; baseUrl += '&prof=' + prof; @@ -194,6 +198,8 @@ export default class Revealed extends React.Component { return baseUrl; } + + extractTrackCaptions (sources, defaultCaptions) { let captions = []; diff --git a/elements/bulbs-video/components/revealed.test.js b/elements/bulbs-video/components/revealed.test.js index 3b6973ee..84bf0bb3 100644 --- a/elements/bulbs-video/components/revealed.test.js +++ b/elements/bulbs-video/components/revealed.test.js @@ -531,17 +531,32 @@ describe(' ', () => { }); }); + describe('getProfValue', () => { + it('returns different values on desktop and mobile', () => { + // desktop + let response = Revealed.prototype.getProfValue.call(); + expect(response).to.equal('theonion_desktop_html5'); + + // mobile + window.isMobile.any = true; + response = Revealed.prototype.getProfValue.call(); + expect(response).to.equal('theonion_mobileweb_html5'); + }); + }); + describe('vastUrl', () => { let videoMeta; let cacheBusterStub; let vastTestStub; let vastUrl; + let getProfValueStub; let parsed; context('default', () => { beforeEach(() => { cacheBusterStub = sinon.stub().returns('456'); vastTestStub = sinon.stub().returns(null); + getProfValueStub = sinon.stub().returns('testy'); videoMeta = { tags: ['clickhole', 'main', '12345'], category: 'main/clickhole', @@ -554,6 +569,7 @@ describe(' ', () => { vastUrl = Revealed.prototype.vastUrl.call({ cacheBuster: cacheBusterStub, vastTest: vastTestStub, + getProfValue: getProfValueStub, }, videoMeta); parsed = url.parse(vastUrl, true); expect(parsed.protocol).to.eql('http:'); @@ -574,16 +590,7 @@ describe(' ', () => { expect(parsed.query.resp).to.eql('vmap1'); }); it('prof', function () { - //desktop - expect(parsed.query.prof).to.eql('theonion_desktop_html5'); - //mobile - window.isMobile.any = true; - vastUrl = Revealed.prototype.vastUrl.call({ - cacheBuster: cacheBusterStub, - vastTest: vastTestStub, - }, videoMeta); - parsed = url.parse(vastUrl, true); - expect(parsed.query.prof).to.eql('theonion_mobileweb_html5'); + expect(parsed.query.prof).to.eql('testy'); }); }); }); @@ -592,6 +599,7 @@ describe(' ', () => { beforeEach(() => { cacheBusterStub = sinon.stub().returns('456'); vastTestStub = sinon.stub().returns(null); + getProfValueStub = sinon.stub().returns('testy'); videoMeta = { tags: ['clickhole', 'main', '12345'], category: 'main/clickhole', @@ -605,6 +613,7 @@ describe(' ', () => { let vastUrl = Revealed.prototype.vastUrl.call({ cacheBuster: cacheBusterStub, vastTest: vastTestStub, + getProfValue: getProfValueStub, }, videoMeta); let parsed = url.parse(vastUrl, true); expect(parsed.query.s).to.eql('host_channel/channel_slug/series_slug'); From 01e1e8facfb288b0e99dcbfce42b39839766db2e Mon Sep 17 00:00:00 2001 From: Melissa Date: Tue, 11 Oct 2016 10:10:54 -0500 Subject: [PATCH 04/21] remove resp from settings update freewheel netid --- lib/bulbs-elements/settings.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/bulbs-elements/settings.js b/lib/bulbs-elements/settings.js index b86834b4..9810b2e9 100644 --- a/lib/bulbs-elements/settings.js +++ b/lib/bulbs-elements/settings.js @@ -2,7 +2,6 @@ let settings = { base: { BULBS_ELEMENTS_ONIONSTUDIOS_GA_ID: 'UA-223393-14', BULBS_ELEMENTS_COMSCORE_ID: '6036328', - RESP: 'vmap1', }, development: { FREEWHEEL_NETWORK_ID: '111976', @@ -11,7 +10,7 @@ let settings = { FREEWHEEL_NETWORK_ID: '111976', }, production: { - FREEWHEEL_NETWORK_ID: '123456', + FREEWHEEL_NETWORK_ID: '112214', } } From 67940abd71969688e9b705102bc80aa50ca221b0 Mon Sep 17 00:00:00 2001 From: Melissa Date: Tue, 11 Oct 2016 13:32:58 -0500 Subject: [PATCH 05/21] add csid logic --- elements/bulbs-video/components/revealed.js | 37 ++++++++- .../bulbs-video/components/revealed.test.js | 76 ++++++++++++++++++- 2 files changed, 109 insertions(+), 4 deletions(-) diff --git a/elements/bulbs-video/components/revealed.js b/elements/bulbs-video/components/revealed.js index 56000ab8..28a862a6 100644 --- a/elements/bulbs-video/components/revealed.js +++ b/elements/bulbs-video/components/revealed.js @@ -168,13 +168,44 @@ export default class Revealed extends React.Component { } } + setDeviceAcronym () { + if (window.isMobile.any) { + return 'm'; + } else { + return 'd'; + } + } + + getSiteName () { + return window.location.host.split('.')[1]; + } + + getDfpSection () { + if (window.TARGETING.dfp_section) { + return window.TARGETING.dfp_section; + } else if (window.TARGETING.dfp_specialcoverage) { + let slug = window.TARGETING.dfp_specialcoverage; + return `specialcoverage_${slug}`; + } else { + return 'video'; + } + } + + getCsidValue (videoMeta) { + let deviceAcronym = this.setDeviceAcronym(); + let siteName = this.getSiteName(); + let dfpSection = this.getDfpSection(); + + + return `${deviceAcronym}.${siteName}_${dfpSection}_${videoMeta.hostChannel}`; + } + vastUrl (videoMeta) { - let baseUrl = `http://${SETTINGS.FREEWHEEL_NETWORK_ID}v.fwmrm.net/ad/g/1?`; + let baseUrl = `http://${SETTINGS.FREEWHEEL_NETWORK_ID}.v.fwmrm.net/ad/g/1?`; let vastTestId = this.vastTest(window.location.search); - let prof = this.getProfValue(); - baseUrl += '&resp=' + SETTINGS.RESP; + baseUrl += '&resp=' + 'vmap1'; baseUrl += '&prof=' + prof; videoMeta.tags.push('html5'); // Force HTML 5 diff --git a/elements/bulbs-video/components/revealed.test.js b/elements/bulbs-video/components/revealed.test.js index 84bf0bb3..8530d71e 100644 --- a/elements/bulbs-video/components/revealed.test.js +++ b/elements/bulbs-video/components/revealed.test.js @@ -534,6 +534,7 @@ describe(' ', () => { describe('getProfValue', () => { it('returns different values on desktop and mobile', () => { // desktop + window.isMobile.any = false; let response = Revealed.prototype.getProfValue.call(); expect(response).to.equal('theonion_desktop_html5'); @@ -544,12 +545,84 @@ describe(' ', () => { }); }); + describe('getCsidValue', () => { + let response; + let getSiteNameStub; + let setDeviceAcronymStub; + let getDfpSectionStub; + let videoMeta; + + beforeEach(() => { + getSiteNameStub = sinon.stub().returns('website'); + setDeviceAcronymStub = sinon.stub().returns('d'); + getDfpSectionStub = sinon.stub().returns('fun'); + videoMeta = { + hostChannel: 'host_channel', + }; + response = Revealed.prototype.getCsidValue.call({ + getSiteName: getSiteNameStub, + setDeviceAcronym: setDeviceAcronymStub, + getDfpSection: getDfpSectionStub, + }, videoMeta); + }); + + // csid format: .__ + // example: d.theonion_specialcoverage_boldness_main + it('#setDeviceAcronym device acronym ', () => { + // desktop + window.isMobile.any = false; + response = Revealed.prototype.setDeviceAcronym.call(); + expect(response).to.equal('d'); + + // mobile + window.isMobile.any = true; + response = Revealed.prototype.setDeviceAcronym.call(); + expect(response).to.equal('m'); + }); + + it('sets site name', () => { + expect(response.includes('website')).to.be.true; + }); + + context('getDfpSection', () => { + it('window.TARGETING.dfp_section is set', () => { + window.TARGETING = { dfp_section: 'sunshine' }; + response = Revealed.prototype.getDfpSection.call(); + expect(response).to.eql(window.TARGETING.dfp_section); + }); + + it('special coverage page', () => { + window.TARGETING = { dfp_specialcoverage: 'forest-walk' }; + response = Revealed.prototype.getDfpSection.call(); + let expected = `specialcoverage_${window.TARGETING.dfp_specialcoverage}`; + expect(response).to.eql(expected); + }); + + it('not special coverage or dfp_section', () => { + window.TARGETING = {}; + response = Revealed.prototype.getDfpSection.call(); + expect(response).to.eql('video'); + }); + }); + + it('populates csid', () => { + response = Revealed.prototype.getCsidValue.call({ + getSiteName: getSiteNameStub, + setDeviceAcronym: setDeviceAcronymStub, + getDfpSection: getDfpSectionStub, + }, videoMeta); + let expected = 'd.website_fun_host_channel'; + expect(response).to.eql(expected); + }); + }); + describe('vastUrl', () => { let videoMeta; let cacheBusterStub; let vastTestStub; let vastUrl; let getProfValueStub; + let getSiteNameStub; let parsed; context('default', () => { @@ -557,6 +630,7 @@ describe(' ', () => { cacheBusterStub = sinon.stub().returns('456'); vastTestStub = sinon.stub().returns(null); getProfValueStub = sinon.stub().returns('testy'); + getSiteNameStub = sinon.stub().returns('website'); videoMeta = { tags: ['clickhole', 'main', '12345'], category: 'main/clickhole', @@ -573,7 +647,7 @@ describe(' ', () => { }, videoMeta); parsed = url.parse(vastUrl, true); expect(parsed.protocol).to.eql('http:'); - expect(parsed.host).to.eql('111976v.fwmrm.net'); + expect(parsed.host).to.eql('111976.v.fwmrm.net'); expect(parsed.pathname).to.eql('/ad/g/1'); }); From 80ff21e25b4ff000fe2a14df67a9c033227f4eec Mon Sep 17 00:00:00 2001 From: Melissa Date: Tue, 11 Oct 2016 15:13:06 -0500 Subject: [PATCH 06/21] pull freewheel network id from sites settings.py file --- elements/bulbs-video/components/revealed.js | 11 ++++--- .../bulbs-video/components/revealed.test.js | 3 +- lib/bulbs-elements/settings.js | 30 ------------------- 3 files changed, 9 insertions(+), 35 deletions(-) delete mode 100644 lib/bulbs-elements/settings.js diff --git a/elements/bulbs-video/components/revealed.js b/elements/bulbs-video/components/revealed.js index 28a862a6..c2dbc711 100644 --- a/elements/bulbs-video/components/revealed.js +++ b/elements/bulbs-video/components/revealed.js @@ -8,10 +8,9 @@ import Comscore from '../plugins/comscore'; import React, { PropTypes } from 'react'; import invariant from 'invariant'; -import SETTINGS from 'bulbs-elements/settings'; -global.BULBS_ELEMENTS_ONIONSTUDIOS_GA_ID = SETTINGS.BULBS_ELEMENTS_ONIONSTUDIOS_GA_ID; -global.BULBS_ELEMENTS_COMSCORE_ID = SETTINGS.BULBS_ELEMENTS_COMSCORE_ID; +global.BULBS_ELEMENTS_ONIONSTUDIOS_GA_ID = 'UA-223393-14'; +global.BULBS_ELEMENTS_COMSCORE_ID = '6036328'; let prefixCount = 0; function makeGaPrefix () { @@ -44,6 +43,10 @@ export default class Revealed extends React.Component { '`` requires `isMobile()` to be set on window.' ); + invariant( + window.FREEWHEEL_NETWORK_ID, + '`` requires `FREEWHEEL_NETWORK_ID` to be set on window.' + ); let gaPrefix = makeGaPrefix(); ga('create', BULBS_ELEMENTS_ONIONSTUDIOS_GA_ID, 'auto', { name: gaPrefix }); @@ -201,7 +204,7 @@ export default class Revealed extends React.Component { } vastUrl (videoMeta) { - let baseUrl = `http://${SETTINGS.FREEWHEEL_NETWORK_ID}.v.fwmrm.net/ad/g/1?`; + let baseUrl = `http://${window.FREEWHEEL_NETWORK_ID}.v.fwmrm.net/ad/g/1?`; let vastTestId = this.vastTest(window.location.search); let prof = this.getProfValue(); diff --git a/elements/bulbs-video/components/revealed.test.js b/elements/bulbs-video/components/revealed.test.js index 8530d71e..e67e80dd 100644 --- a/elements/bulbs-video/components/revealed.test.js +++ b/elements/bulbs-video/components/revealed.test.js @@ -627,6 +627,7 @@ describe(' ', () => { context('default', () => { beforeEach(() => { + window.FREEWHEEL_NETWORK_ID = '12345'; cacheBusterStub = sinon.stub().returns('456'); vastTestStub = sinon.stub().returns(null); getProfValueStub = sinon.stub().returns('testy'); @@ -647,7 +648,7 @@ describe(' ', () => { }, videoMeta); parsed = url.parse(vastUrl, true); expect(parsed.protocol).to.eql('http:'); - expect(parsed.host).to.eql('111976.v.fwmrm.net'); + expect(parsed.host).to.eql('12345.v.fwmrm.net'); expect(parsed.pathname).to.eql('/ad/g/1'); }); diff --git a/lib/bulbs-elements/settings.js b/lib/bulbs-elements/settings.js deleted file mode 100644 index 9810b2e9..00000000 --- a/lib/bulbs-elements/settings.js +++ /dev/null @@ -1,30 +0,0 @@ -let settings = { - base: { - BULBS_ELEMENTS_ONIONSTUDIOS_GA_ID: 'UA-223393-14', - BULBS_ELEMENTS_COMSCORE_ID: '6036328', - }, - development: { - FREEWHEEL_NETWORK_ID: '111976', - }, - test: { - FREEWHEEL_NETWORK_ID: '111976', - }, - production: { - FREEWHEEL_NETWORK_ID: '112214', - } -} - -function getEnvironment () { - let envValues; - if (process.env.NODE_ENV === 'production') { - envValues = settings.production; - } else if ( process.env.NODE_ENV === 'test') { - envValues = settings.test; - } else { - envValues = settings.development; - } - return Object.assign(settings.base, envValues); -}; - -let SETTINGS = getEnvironment(); -export default SETTINGS; From b5e393b7459fdae957270864b5fe91ab20282e46 Mon Sep 17 00:00:00 2001 From: Melissa Date: Tue, 11 Oct 2016 15:47:47 -0500 Subject: [PATCH 07/21] refactor, rename variables --- elements/bulbs-video/components/revealed.js | 13 +++---- .../bulbs-video/components/revealed.test.js | 35 ++++++++++--------- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/elements/bulbs-video/components/revealed.js b/elements/bulbs-video/components/revealed.js index c2dbc711..67371984 100644 --- a/elements/bulbs-video/components/revealed.js +++ b/elements/bulbs-video/components/revealed.js @@ -183,7 +183,7 @@ export default class Revealed extends React.Component { return window.location.host.split('.')[1]; } - getDfpSection () { + getSiteSection () { if (window.TARGETING.dfp_section) { return window.TARGETING.dfp_section; } else if (window.TARGETING.dfp_specialcoverage) { @@ -194,22 +194,23 @@ export default class Revealed extends React.Component { } } - getCsidValue (videoMeta) { + buildCsid (hostChannel) { let deviceAcronym = this.setDeviceAcronym(); let siteName = this.getSiteName(); - let dfpSection = this.getDfpSection(); + let siteSection = this.getSiteSection(); - return `${deviceAcronym}.${siteName}_${dfpSection}_${videoMeta.hostChannel}`; + return `${deviceAcronym}.${siteName}_${siteSection}_${hostChannel}`; } + vastUrl (videoMeta) { let baseUrl = `http://${window.FREEWHEEL_NETWORK_ID}.v.fwmrm.net/ad/g/1?`; let vastTestId = this.vastTest(window.location.search); - let prof = this.getProfValue(); baseUrl += '&resp=' + 'vmap1'; - baseUrl += '&prof=' + prof; + baseUrl += '&prof=' + this.getProfValue(); + baseUrl += '&csid=' + this.buildCsid(videoMeta.hostChannel); videoMeta.tags.push('html5'); // Force HTML 5 // Tags diff --git a/elements/bulbs-video/components/revealed.test.js b/elements/bulbs-video/components/revealed.test.js index e67e80dd..3df77873 100644 --- a/elements/bulbs-video/components/revealed.test.js +++ b/elements/bulbs-video/components/revealed.test.js @@ -545,25 +545,21 @@ describe(' ', () => { }); }); - describe('getCsidValue', () => { + describe('buildCsid', () => { let response; let getSiteNameStub; let setDeviceAcronymStub; - let getDfpSectionStub; - let videoMeta; + let getSiteSectionStub; beforeEach(() => { getSiteNameStub = sinon.stub().returns('website'); setDeviceAcronymStub = sinon.stub().returns('d'); - getDfpSectionStub = sinon.stub().returns('fun'); - videoMeta = { - hostChannel: 'host_channel', - }; - response = Revealed.prototype.getCsidValue.call({ + getSiteSectionStub = sinon.stub().returns('fun'); + response = Revealed.prototype.buildCsid.call({ getSiteName: getSiteNameStub, setDeviceAcronym: setDeviceAcronymStub, - getDfpSection: getDfpSectionStub, - }, videoMeta); + getSiteSection: getSiteSectionStub, + }, 'host_channel'); }); // csid format: .__ @@ -584,33 +580,33 @@ describe(' ', () => { expect(response.includes('website')).to.be.true; }); - context('getDfpSection', () => { + context('getSiteSection', () => { it('window.TARGETING.dfp_section is set', () => { window.TARGETING = { dfp_section: 'sunshine' }; - response = Revealed.prototype.getDfpSection.call(); + response = Revealed.prototype.getSiteSection.call(); expect(response).to.eql(window.TARGETING.dfp_section); }); it('special coverage page', () => { window.TARGETING = { dfp_specialcoverage: 'forest-walk' }; - response = Revealed.prototype.getDfpSection.call(); + response = Revealed.prototype.getSiteSection.call(); let expected = `specialcoverage_${window.TARGETING.dfp_specialcoverage}`; expect(response).to.eql(expected); }); it('not special coverage or dfp_section', () => { window.TARGETING = {}; - response = Revealed.prototype.getDfpSection.call(); + response = Revealed.prototype.getSiteSection.call(); expect(response).to.eql('video'); }); }); it('populates csid', () => { - response = Revealed.prototype.getCsidValue.call({ + response = Revealed.prototype.buildCsid.call({ getSiteName: getSiteNameStub, setDeviceAcronym: setDeviceAcronymStub, - getDfpSection: getDfpSectionStub, - }, videoMeta); + getSiteSection: getSiteSectionStub, + }, 'host_channel'); let expected = 'd.website_fun_host_channel'; expect(response).to.eql(expected); }); @@ -624,6 +620,7 @@ describe(' ', () => { let getProfValueStub; let getSiteNameStub; let parsed; + let buildCsidStub; context('default', () => { beforeEach(() => { @@ -632,6 +629,7 @@ describe(' ', () => { vastTestStub = sinon.stub().returns(null); getProfValueStub = sinon.stub().returns('testy'); getSiteNameStub = sinon.stub().returns('website'); + buildCsidStub = sinon.stub().returns('d.website_camping_channel'); videoMeta = { tags: ['clickhole', 'main', '12345'], category: 'main/clickhole', @@ -645,6 +643,7 @@ describe(' ', () => { cacheBuster: cacheBusterStub, vastTest: vastTestStub, getProfValue: getProfValueStub, + buildCsid: buildCsidStub, }, videoMeta); parsed = url.parse(vastUrl, true); expect(parsed.protocol).to.eql('http:'); @@ -675,6 +674,7 @@ describe(' ', () => { cacheBusterStub = sinon.stub().returns('456'); vastTestStub = sinon.stub().returns(null); getProfValueStub = sinon.stub().returns('testy'); + buildCsidStub = sinon.stub().returns('d.website_camping_channel'); videoMeta = { tags: ['clickhole', 'main', '12345'], category: 'main/clickhole', @@ -689,6 +689,7 @@ describe(' ', () => { cacheBuster: cacheBusterStub, vastTest: vastTestStub, getProfValue: getProfValueStub, + buildCsid: buildCsidStub, }, videoMeta); let parsed = url.parse(vastUrl, true); expect(parsed.query.s).to.eql('host_channel/channel_slug/series_slug'); From 1889522deb0ee1f01a0be498b1c2bab4172a128b Mon Sep 17 00:00:00 2001 From: Melissa Date: Tue, 11 Oct 2016 15:57:02 -0500 Subject: [PATCH 08/21] add caid --- elements/bulbs-video/components/revealed.js | 6 +++++- elements/bulbs-video/components/revealed.test.js | 13 +++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/elements/bulbs-video/components/revealed.js b/elements/bulbs-video/components/revealed.js index 67371984..b25b8030 100644 --- a/elements/bulbs-video/components/revealed.js +++ b/elements/bulbs-video/components/revealed.js @@ -199,10 +199,13 @@ export default class Revealed extends React.Component { let siteName = this.getSiteName(); let siteSection = this.getSiteSection(); - return `${deviceAcronym}.${siteName}_${siteSection}_${hostChannel}`; } + buildCaid (videohubReferenceId) { + return `onion_${videohubReferenceId}`; + } + vastUrl (videoMeta) { let baseUrl = `http://${window.FREEWHEEL_NETWORK_ID}.v.fwmrm.net/ad/g/1?`; @@ -211,6 +214,7 @@ export default class Revealed extends React.Component { baseUrl += '&resp=' + 'vmap1'; baseUrl += '&prof=' + this.getProfValue(); baseUrl += '&csid=' + this.buildCsid(videoMeta.hostChannel); + baseUrl += '&caid=' + this.buildCaid(videoMeta.id); videoMeta.tags.push('html5'); // Force HTML 5 // Tags diff --git a/elements/bulbs-video/components/revealed.test.js b/elements/bulbs-video/components/revealed.test.js index 3df77873..3cb834e1 100644 --- a/elements/bulbs-video/components/revealed.test.js +++ b/elements/bulbs-video/components/revealed.test.js @@ -612,6 +612,14 @@ describe(' ', () => { }); }); + describe('buildCaid', () => { + it('sets to onion studios id', () => { + let videohubReferenceId = 1234; + let response = Revealed.prototype.buildCaid.call({}, videohubReferenceId) + expect(response).to.eql('onion_1234'); + }); + }); + describe('vastUrl', () => { let videoMeta; let cacheBusterStub; @@ -621,6 +629,7 @@ describe(' ', () => { let getSiteNameStub; let parsed; let buildCsidStub; + let buildCaidStub; context('default', () => { beforeEach(() => { @@ -630,6 +639,7 @@ describe(' ', () => { getProfValueStub = sinon.stub().returns('testy'); getSiteNameStub = sinon.stub().returns('website'); buildCsidStub = sinon.stub().returns('d.website_camping_channel'); + buildCaidStub = sinon.stub().returns('onion_1234'); videoMeta = { tags: ['clickhole', 'main', '12345'], category: 'main/clickhole', @@ -644,6 +654,7 @@ describe(' ', () => { vastTest: vastTestStub, getProfValue: getProfValueStub, buildCsid: buildCsidStub, + buildCaid: buildCaidStub, }, videoMeta); parsed = url.parse(vastUrl, true); expect(parsed.protocol).to.eql('http:'); @@ -675,6 +686,7 @@ describe(' ', () => { vastTestStub = sinon.stub().returns(null); getProfValueStub = sinon.stub().returns('testy'); buildCsidStub = sinon.stub().returns('d.website_camping_channel'); + buildCaidStub = sinon.stub().returns('onion_1234'); videoMeta = { tags: ['clickhole', 'main', '12345'], category: 'main/clickhole', @@ -690,6 +702,7 @@ describe(' ', () => { vastTest: vastTestStub, getProfValue: getProfValueStub, buildCsid: buildCsidStub, + buildCaid: buildCaidStub, }, videoMeta); let parsed = url.parse(vastUrl, true); expect(parsed.query.s).to.eql('host_channel/channel_slug/series_slug'); From 74f7633c5332aa23b8e9f6eba1a423d70c4a5d9e Mon Sep 17 00:00:00 2001 From: Melissa Date: Tue, 11 Oct 2016 16:04:35 -0500 Subject: [PATCH 09/21] cleanup variable names and delete uneeded tests and code --- elements/bulbs-video/components/revealed.js | 34 ++--- .../bulbs-video/components/revealed.test.js | 125 +++++++----------- 2 files changed, 58 insertions(+), 101 deletions(-) diff --git a/elements/bulbs-video/components/revealed.js b/elements/bulbs-video/components/revealed.js index b25b8030..5ee061ff 100644 --- a/elements/bulbs-video/components/revealed.js +++ b/elements/bulbs-video/components/revealed.js @@ -183,7 +183,7 @@ export default class Revealed extends React.Component { return window.location.host.split('.')[1]; } - getSiteSection () { + getDfpSection () { if (window.TARGETING.dfp_section) { return window.TARGETING.dfp_section; } else if (window.TARGETING.dfp_specialcoverage) { @@ -195,44 +195,32 @@ export default class Revealed extends React.Component { } buildCsid (hostChannel) { + // Custom Site Section ID + // format: .__ let deviceAcronym = this.setDeviceAcronym(); let siteName = this.getSiteName(); - let siteSection = this.getSiteSection(); + let siteSection = this.getDfpSection(); return `${deviceAcronym}.${siteName}_${siteSection}_${hostChannel}`; } buildCaid (videohubReferenceId) { + // Custom content video asset id + // format: onion_ return `onion_${videohubReferenceId}`; } - vastUrl (videoMeta) { + let hostChannel = videoMeta.hostChannel; + let videohubReferenceId = videoMeta.id; let baseUrl = `http://${window.FREEWHEEL_NETWORK_ID}.v.fwmrm.net/ad/g/1?`; let vastTestId = this.vastTest(window.location.search); baseUrl += '&resp=' + 'vmap1'; baseUrl += '&prof=' + this.getProfValue(); - baseUrl += '&csid=' + this.buildCsid(videoMeta.hostChannel); - baseUrl += '&caid=' + this.buildCaid(videoMeta.id); - - videoMeta.tags.push('html5'); // Force HTML 5 - // Tags - baseUrl += '&t=' + videoMeta.tags; - //Category - let hostChannel = videoMeta.hostChannel; - let channel = videoMeta.channel_slug; - let series = videoMeta.series_slug; - let category = `${hostChannel}/${channel}`; - if (series) { - category += `/${series}`; - } - baseUrl += '&s=' + category; - baseUrl += '&rnd=' + this.cacheBuster(); - - if (vastTestId) { - baseUrl += '&xgid=' + vastTestId; - } + baseUrl += '&csid=' + this.buildCsid(hostChannel); + baseUrl += '&caid=' + this.buildCaid(videohubReferenceId); + baseUrl += '&pvrn=' + this.cacheBuster(); return baseUrl; } diff --git a/elements/bulbs-video/components/revealed.test.js b/elements/bulbs-video/components/revealed.test.js index 3cb834e1..94b3ad9c 100644 --- a/elements/bulbs-video/components/revealed.test.js +++ b/elements/bulbs-video/components/revealed.test.js @@ -549,16 +549,16 @@ describe(' ', () => { let response; let getSiteNameStub; let setDeviceAcronymStub; - let getSiteSectionStub; + let getDfpSectionStub; beforeEach(() => { getSiteNameStub = sinon.stub().returns('website'); setDeviceAcronymStub = sinon.stub().returns('d'); - getSiteSectionStub = sinon.stub().returns('fun'); + getDfpSectionStub = sinon.stub().returns('fun'); response = Revealed.prototype.buildCsid.call({ getSiteName: getSiteNameStub, setDeviceAcronym: setDeviceAcronymStub, - getSiteSection: getSiteSectionStub, + getDfpSection: getDfpSectionStub, }, 'host_channel'); }); @@ -580,23 +580,23 @@ describe(' ', () => { expect(response.includes('website')).to.be.true; }); - context('getSiteSection', () => { + context('getDfpSection', () => { it('window.TARGETING.dfp_section is set', () => { window.TARGETING = { dfp_section: 'sunshine' }; - response = Revealed.prototype.getSiteSection.call(); + response = Revealed.prototype.getDfpSection.call(); expect(response).to.eql(window.TARGETING.dfp_section); }); it('special coverage page', () => { window.TARGETING = { dfp_specialcoverage: 'forest-walk' }; - response = Revealed.prototype.getSiteSection.call(); + response = Revealed.prototype.getDfpSection.call(); let expected = `specialcoverage_${window.TARGETING.dfp_specialcoverage}`; expect(response).to.eql(expected); }); it('not special coverage or dfp_section', () => { window.TARGETING = {}; - response = Revealed.prototype.getSiteSection.call(); + response = Revealed.prototype.getDfpSection.call(); expect(response).to.eql('video'); }); }); @@ -605,7 +605,7 @@ describe(' ', () => { response = Revealed.prototype.buildCsid.call({ getSiteName: getSiteNameStub, setDeviceAcronym: setDeviceAcronymStub, - getSiteSection: getSiteSectionStub, + getDfpSection: getDfpSectionStub, }, 'host_channel'); let expected = 'd.website_fun_host_channel'; expect(response).to.eql(expected); @@ -631,81 +631,50 @@ describe(' ', () => { let buildCsidStub; let buildCaidStub; - context('default', () => { - beforeEach(() => { - window.FREEWHEEL_NETWORK_ID = '12345'; - cacheBusterStub = sinon.stub().returns('456'); - vastTestStub = sinon.stub().returns(null); - getProfValueStub = sinon.stub().returns('testy'); - getSiteNameStub = sinon.stub().returns('website'); - buildCsidStub = sinon.stub().returns('d.website_camping_channel'); - buildCaidStub = sinon.stub().returns('onion_1234'); - videoMeta = { - tags: ['clickhole', 'main', '12345'], - category: 'main/clickhole', - channel_slug: 'channel_slug', - hostChannel: 'host_channel', - }; - }); - - it('returns the vast url', function () { - vastUrl = Revealed.prototype.vastUrl.call({ - cacheBuster: cacheBusterStub, - vastTest: vastTestStub, - getProfValue: getProfValueStub, - buildCsid: buildCsidStub, - buildCaid: buildCaidStub, - }, videoMeta); - parsed = url.parse(vastUrl, true); - expect(parsed.protocol).to.eql('http:'); - expect(parsed.host).to.eql('12345.v.fwmrm.net'); - expect(parsed.pathname).to.eql('/ad/g/1'); - }); + beforeEach(() => { + window.FREEWHEEL_NETWORK_ID = '12345'; + cacheBusterStub = sinon.stub().returns('456'); + vastTestStub = sinon.stub().returns(null); + getProfValueStub = sinon.stub().returns('testy'); + getSiteNameStub = sinon.stub().returns('website'); + buildCsidStub = sinon.stub().returns('d.website_camping_channel'); + buildCaidStub = sinon.stub().returns('onion_1234'); + videoMeta = { + tags: ['clickhole', 'main', '12345'], + category: 'main/clickhole', + channel_slug: 'channel_slug', + hostChannel: 'host_channel', + }; + }); - it('populates keys for required global params', () => { - let expectedQueryKeys = [ - 'resp', 'prof', 'csid', 'caid', 'pvrn', 'vprn', 'cana' - ]; - let queryKeys = Object.keys(parsed.query); - expect(queryKeys).to.eql(expectedQueryKeys); - }); + it('returns the vast url', function () { + vastUrl = Revealed.prototype.vastUrl.call({ + cacheBuster: cacheBusterStub, + vastTest: vastTestStub, + getProfValue: getProfValueStub, + buildCsid: buildCsidStub, + buildCaid: buildCaidStub, + }, videoMeta); + parsed = url.parse(vastUrl, true); + expect(parsed.protocol).to.eql('http:'); + expect(parsed.host).to.eql('12345.v.fwmrm.net'); + expect(parsed.pathname).to.eql('/ad/g/1'); + }); - context('populates values for required global params', () => { - it('resp', function () { - expect(parsed.query.resp).to.eql('vmap1'); - }); - it('prof', function () { - expect(parsed.query.prof).to.eql('testy'); - }); - }); + it('populates keys for required global params', () => { + let expectedQueryKeys = [ + 'resp', 'prof', 'csid', 'caid', 'pvrn', 'vprn', 'cana' + ]; + let queryKeys = Object.keys(parsed.query); + expect(queryKeys).to.eql(expectedQueryKeys); }); - context('when series_slug is given', () => { - beforeEach(() => { - cacheBusterStub = sinon.stub().returns('456'); - vastTestStub = sinon.stub().returns(null); - getProfValueStub = sinon.stub().returns('testy'); - buildCsidStub = sinon.stub().returns('d.website_camping_channel'); - buildCaidStub = sinon.stub().returns('onion_1234'); - videoMeta = { - tags: ['clickhole', 'main', '12345'], - category: 'main/clickhole', - channel_slug: 'channel_slug', - series_slug: 'series_slug', - hostChannel: 'host_channel', - }; + context('populates values for required global params', () => { + it('resp', function () { + expect(parsed.query.resp).to.eql('vmap1'); }); - - it('returns the vast url', function () { - let vastUrl = Revealed.prototype.vastUrl.call({ - cacheBuster: cacheBusterStub, - vastTest: vastTestStub, - getProfValue: getProfValueStub, - buildCsid: buildCsidStub, - buildCaid: buildCaidStub, - }, videoMeta); - let parsed = url.parse(vastUrl, true); - expect(parsed.query.s).to.eql('host_channel/channel_slug/series_slug'); + it('prof', function () { + expect(parsed.query.prof).to.eql('testy'); }); }); }); From 12d2e85765fa030a2278940a9229866e0bda0e8e Mon Sep 17 00:00:00 2001 From: Melissa Date: Tue, 11 Oct 2016 16:34:03 -0500 Subject: [PATCH 10/21] fix broken specs --- elements/bulbs-video/components/revealed.test.js | 1 + 1 file changed, 1 insertion(+) diff --git a/elements/bulbs-video/components/revealed.test.js b/elements/bulbs-video/components/revealed.test.js index 94b3ad9c..38238382 100644 --- a/elements/bulbs-video/components/revealed.test.js +++ b/elements/bulbs-video/components/revealed.test.js @@ -201,6 +201,7 @@ describe(' ', () => { state = {}; global.BULBS_ELEMENTS_ONIONSTUDIOS_GA_ID = 'a-ga-id'; global.ga = sinon.spy(); + window.FREEWHEEL_NETWORK_ID = '12345'; makeVideoPlayerSpy = sinon.spy(); }); From 54018d83369ff28bbebcaa6d6120560d5df9efb3 Mon Sep 17 00:00:00 2001 From: Melissa Date: Tue, 11 Oct 2016 16:49:59 -0500 Subject: [PATCH 11/21] add vprn --- elements/bulbs-video/components/revealed.js | 9 +++++++++ elements/bulbs-video/components/revealed.test.js | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/elements/bulbs-video/components/revealed.js b/elements/bulbs-video/components/revealed.js index 5ee061ff..18f0572e 100644 --- a/elements/bulbs-video/components/revealed.js +++ b/elements/bulbs-video/components/revealed.js @@ -213,6 +213,7 @@ export default class Revealed extends React.Component { vastUrl (videoMeta) { let hostChannel = videoMeta.hostChannel; let videohubReferenceId = videoMeta.id; + let randomVideoPlayerNumber = videoMeta.vprn; let baseUrl = `http://${window.FREEWHEEL_NETWORK_ID}.v.fwmrm.net/ad/g/1?`; let vastTestId = this.vastTest(window.location.search); @@ -221,6 +222,7 @@ export default class Revealed extends React.Component { baseUrl += '&csid=' + this.buildCsid(hostChannel); baseUrl += '&caid=' + this.buildCaid(videohubReferenceId); baseUrl += '&pvrn=' + this.cacheBuster(); + baseUrl += '&vprn=' + randomVideoPlayerNumber; return baseUrl; } @@ -248,6 +250,13 @@ export default class Revealed extends React.Component { element.id = videoMeta.gaPrefix; let player = global.jwplayer(element); + // random video player number ending with video id + // to be used in vastUrl query string + let randomVideoPlayerNumber = parseInt( + `${this.cacheBuster()}${videoMeta.id}` + ); + videoMeta.vprn = randomVideoPlayerNumber; + player.videoMeta = videoMeta; let playerOptions = { diff --git a/elements/bulbs-video/components/revealed.test.js b/elements/bulbs-video/components/revealed.test.js index 38238382..46d1f279 100644 --- a/elements/bulbs-video/components/revealed.test.js +++ b/elements/bulbs-video/components/revealed.test.js @@ -685,6 +685,7 @@ describe(' ', () => { let element; let player; let videoMeta; + let cacheBusterStub; beforeEach(() => { element = {}; @@ -750,6 +751,7 @@ describe(' ', () => { gaPrefix: 'videoplayer0', }); playerSetup = sinon.spy(); + cacheBusterStub = sinon.stub().returns('456'); player = { setup: playerSetup, }; @@ -782,6 +784,7 @@ describe(' ', () => { props: {}, extractSources: extractSourcesStub, vastUrl: vastUrlStub, + cacheBuster: cacheBusterStub, extractTrackCaptions: extractTrackCaptionsStub, }, element, videoMeta); }); @@ -855,6 +858,7 @@ describe(' ', () => { props: {}, extractSources: extractSourcesStub, vastUrl: vastUrlStub, + cacheBuster: cacheBusterStub, extractTrackCaptions: extractCaptionsStub, }, element, videoMeta); }); @@ -883,6 +887,7 @@ describe(' ', () => { props: { disableSharing: true }, extractSources: extractSourcesStub, vastUrl: vastUrlStub, + cacheBuster: cacheBusterStub, extractTrackCaptions: extractTrackCaptionsStub, }, element, videoMeta); }); From c7c7150e940c0b5a4abfe0a998c94c91bf287767 Mon Sep 17 00:00:00 2001 From: Melissa Date: Tue, 11 Oct 2016 17:09:27 -0500 Subject: [PATCH 12/21] add cana value --- elements/bulbs-video/components/revealed.js | 12 ++++++++---- .../bulbs-video/components/revealed.test.js | 17 ++++++++++++++++- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/elements/bulbs-video/components/revealed.js b/elements/bulbs-video/components/revealed.js index 18f0572e..d63f1e5c 100644 --- a/elements/bulbs-video/components/revealed.js +++ b/elements/bulbs-video/components/revealed.js @@ -214,21 +214,25 @@ export default class Revealed extends React.Component { let hostChannel = videoMeta.hostChannel; let videohubReferenceId = videoMeta.id; let randomVideoPlayerNumber = videoMeta.vprn; - let baseUrl = `http://${window.FREEWHEEL_NETWORK_ID}.v.fwmrm.net/ad/g/1?`; let vastTestId = this.vastTest(window.location.search); - baseUrl += '&resp=' + 'vmap1'; + let baseUrl = `http://${window.FREEWHEEL_NETWORK_ID}.v.fwmrm.net/ad/g/1?`; + + // required global params + baseUrl += 'resp=' + 'vmap1'; baseUrl += '&prof=' + this.getProfValue(); baseUrl += '&csid=' + this.buildCsid(hostChannel); baseUrl += '&caid=' + this.buildCaid(videohubReferenceId); baseUrl += '&pvrn=' + this.cacheBuster(); baseUrl += '&vprn=' + randomVideoPlayerNumber; + // optional global param + if (vastTestId) { + baseUrl += '&cana=' + vastTestId; + } return baseUrl; } - - extractTrackCaptions (sources, defaultCaptions) { let captions = []; diff --git a/elements/bulbs-video/components/revealed.test.js b/elements/bulbs-video/components/revealed.test.js index 46d1f279..8daa1d47 100644 --- a/elements/bulbs-video/components/revealed.test.js +++ b/elements/bulbs-video/components/revealed.test.js @@ -664,12 +664,26 @@ describe(' ', () => { it('populates keys for required global params', () => { let expectedQueryKeys = [ - 'resp', 'prof', 'csid', 'caid', 'pvrn', 'vprn', 'cana' + 'resp', 'prof', 'csid', 'caid', 'pvrn', 'vprn' ]; let queryKeys = Object.keys(parsed.query); expect(queryKeys).to.eql(expectedQueryKeys); }); + it('populates cana if vastTest returns value', () => { + vastTestStub = sinon.stub().returns(5678); + vastUrl = Revealed.prototype.vastUrl.call({ + cacheBuster: cacheBusterStub, + vastTest: vastTestStub, + getProfValue: getProfValueStub, + buildCsid: buildCsidStub, + buildCaid: buildCaidStub, + }, videoMeta); + parsed = url.parse(vastUrl, true); + let queryKeys = Object.keys(parsed.query); + expect(queryKeys.includes('cana')).to.be.true; + }); + context('populates values for required global params', () => { it('resp', function () { expect(parsed.query.resp).to.eql('vmap1'); @@ -917,6 +931,7 @@ describe(' ', () => { extractSources: extractSourcesStub, extractTrackCaptions: extractTrackCaptionsStub, vastUrl: vastUrlStub, + cacheBuster: cacheBusterStub, }, element, videoMeta); }); From 2d9ea9a25cda902666136e871124702499bfd828 Mon Sep 17 00:00:00 2001 From: Melissa Date: Wed, 12 Oct 2016 10:55:56 -0500 Subject: [PATCH 13/21] add key values --- elements/bulbs-video/components/revealed.js | 15 +++- .../bulbs-video/components/revealed.test.js | 87 ++++++++++++------- 2 files changed, 69 insertions(+), 33 deletions(-) diff --git a/elements/bulbs-video/components/revealed.js b/elements/bulbs-video/components/revealed.js index d63f1e5c..bc910fd7 100644 --- a/elements/bulbs-video/components/revealed.js +++ b/elements/bulbs-video/components/revealed.js @@ -215,6 +215,9 @@ export default class Revealed extends React.Component { let videohubReferenceId = videoMeta.id; let randomVideoPlayerNumber = videoMeta.vprn; let vastTestId = this.vastTest(window.location.search); + let series = videoMeta.series_slug; + let campaignId = this.props.targetCampaignId; + let specialCoverage = this.props.targetSpecialCoverage; let baseUrl = `http://${window.FREEWHEEL_NETWORK_ID}.v.fwmrm.net/ad/g/1?`; @@ -225,10 +228,16 @@ export default class Revealed extends React.Component { baseUrl += '&caid=' + this.buildCaid(videohubReferenceId); baseUrl += '&pvrn=' + this.cacheBuster(); baseUrl += '&vprn=' + randomVideoPlayerNumber; + // optional global param - if (vastTestId) { - baseUrl += '&cana=' + vastTestId; - } + if (vastTestId) { baseUrl += '&cana=' + vastTestId; } + + // Key Values + baseUrl += ';&video_id=' + videohubReferenceId; + baseUrl += '&channel_slug=' + videoMeta.channel_slug; + if (series) { baseUrl += '&series_slug=' + series; } + if (campaignId) { baseUrl += '&campaign_id=' + campaignId; } + if (specialCoverage) { baseUrl += '&special_coverage=' + specialCoverage; } return baseUrl; } diff --git a/elements/bulbs-video/components/revealed.test.js b/elements/bulbs-video/components/revealed.test.js index 8daa1d47..08048583 100644 --- a/elements/bulbs-video/components/revealed.test.js +++ b/elements/bulbs-video/components/revealed.test.js @@ -631,25 +631,32 @@ describe(' ', () => { let parsed; let buildCsidStub; let buildCaidStub; + let queryKeys; beforeEach(() => { - window.FREEWHEEL_NETWORK_ID = '12345'; - cacheBusterStub = sinon.stub().returns('456'); - vastTestStub = sinon.stub().returns(null); + cacheBusterStub = sinon.stub().returns(456); + vastTestStub = sinon.stub().returns(5678); getProfValueStub = sinon.stub().returns('testy'); getSiteNameStub = sinon.stub().returns('website'); buildCsidStub = sinon.stub().returns('d.website_camping_channel'); buildCaidStub = sinon.stub().returns('onion_1234'); videoMeta = { + id: 765, + vprn: 456765, tags: ['clickhole', 'main', '12345'], category: 'main/clickhole', channel_slug: 'channel_slug', hostChannel: 'host_channel', + series_slug: 'series-slug', }; }); it('returns the vast url', function () { vastUrl = Revealed.prototype.vastUrl.call({ + props: { + targetCampaignId: 66, + targetSpecialCoverage: 'blooping', + }, cacheBuster: cacheBusterStub, vastTest: vastTestStub, getProfValue: getProfValueStub, @@ -657,39 +664,59 @@ describe(' ', () => { buildCaid: buildCaidStub, }, videoMeta); parsed = url.parse(vastUrl, true); - expect(parsed.protocol).to.eql('http:'); - expect(parsed.host).to.eql('12345.v.fwmrm.net'); - expect(parsed.pathname).to.eql('/ad/g/1'); - }); - it('populates keys for required global params', () => { let expectedQueryKeys = [ - 'resp', 'prof', 'csid', 'caid', 'pvrn', 'vprn' + 'resp', 'prof', 'csid', 'caid', 'pvrn', + 'vprn', 'cana', 'video_id', 'channel_slug', + 'series_slug','campaign_id', 'special_coverage', ]; - let queryKeys = Object.keys(parsed.query); - expect(queryKeys).to.eql(expectedQueryKeys); - }); + queryKeys = Object.keys(parsed.query); - it('populates cana if vastTest returns value', () => { - vastTestStub = sinon.stub().returns(5678); - vastUrl = Revealed.prototype.vastUrl.call({ - cacheBuster: cacheBusterStub, - vastTest: vastTestStub, - getProfValue: getProfValueStub, - buildCsid: buildCsidStub, - buildCaid: buildCaidStub, - }, videoMeta); - parsed = url.parse(vastUrl, true); - let queryKeys = Object.keys(parsed.query); - expect(queryKeys.includes('cana')).to.be.true; - }); + expect(queryKeys).to.eql(expectedQueryKeys); + expect(parsed.protocol).to.eql('http:'); + expect(parsed.host).to.eql('12345.v.fwmrm.net'); + expect(parsed.pathname).to.eql('/ad/g/1'); + expect(parsed.query.resp).to.eql('vmap1'); + expect(parsed.query.prof).to.eql('testy'); + expect(parsed.query.csid).to.eql('d.website_camping_channel'); + expect(parsed.query.caid).to.eql('onion_1234'); + expect(parsed.query.pvrn).to.eql('456'); + expect(parsed.query.vprn).to.eql('456765'); + expect(parsed.query.cana).to.eql('5678;'); + expect(parsed.query.video_id).to.eql('765'); + expect(parsed.query.channel_slug).to.eql('channel_slug'); + expect(parsed.query.series_slug).to.eql('series-slug'); + expect(parsed.query.campaign_id).to.eql('66'); + expect(parsed.query.special_coverage).to.eql('blooping'); + }); + + context('conditionally set parameters', () => { + beforeEach(() => { + vastTestStub = sinon.stub().returns(null); + videoMeta.series_slug = null; + vastUrl = Revealed.prototype.vastUrl.call({ + props: {}, + cacheBuster: cacheBusterStub, + vastTest: vastTestStub, + getProfValue: getProfValueStub, + buildCsid: buildCsidStub, + buildCaid: buildCaidStub, + }, videoMeta); + parsed = url.parse(vastUrl, true); + queryKeys = Object.keys(parsed.query); + }); - context('populates values for required global params', () => { - it('resp', function () { - expect(parsed.query.resp).to.eql('vmap1'); + it('null vastTestId cana not populated', () => { + expect(queryKeys.includes('cana')).to.be.false; + }); + it('no series_slug series_slug not populated', () => { + expect(queryKeys.includes('series_slug')).to.be.false; + }); + it('no targetCampaignId campaign_id not populated', () => { + expect(queryKeys.includes('campaign_id')).to.be.false; }); - it('prof', function () { - expect(parsed.query.prof).to.eql('testy'); + it('no targetSpecialCoverage special_coverage not populated', () => { + expect(queryKeys.includes('special_coverage')).to.be.false; }); }); }); From 16c0d31787ee040e9bb5406e978506a8f6e0fced Mon Sep 17 00:00:00 2001 From: Melissa Date: Wed, 12 Oct 2016 10:59:41 -0500 Subject: [PATCH 14/21] add slot params --- elements/bulbs-video/components/revealed.js | 5 +++++ elements/bulbs-video/components/revealed.test.js | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/elements/bulbs-video/components/revealed.js b/elements/bulbs-video/components/revealed.js index bc910fd7..88f93eb6 100644 --- a/elements/bulbs-video/components/revealed.js +++ b/elements/bulbs-video/components/revealed.js @@ -239,6 +239,11 @@ export default class Revealed extends React.Component { if (campaignId) { baseUrl += '&campaign_id=' + campaignId; } if (specialCoverage) { baseUrl += '&special_coverage=' + specialCoverage; } + // Slot Params *Required Fields* + baseUrl += ';&slid=' + 'Preroll'; + baseUrl += '&tpcl=' + 'PREROLL'; + baseUrl += '&ptgt=' + 'a'; + return baseUrl; } diff --git a/elements/bulbs-video/components/revealed.test.js b/elements/bulbs-video/components/revealed.test.js index 08048583..ef7b70fd 100644 --- a/elements/bulbs-video/components/revealed.test.js +++ b/elements/bulbs-video/components/revealed.test.js @@ -669,6 +669,7 @@ describe(' ', () => { 'resp', 'prof', 'csid', 'caid', 'pvrn', 'vprn', 'cana', 'video_id', 'channel_slug', 'series_slug','campaign_id', 'special_coverage', + 'slid', 'tpcl', 'ptgt', ]; queryKeys = Object.keys(parsed.query); @@ -687,7 +688,10 @@ describe(' ', () => { expect(parsed.query.channel_slug).to.eql('channel_slug'); expect(parsed.query.series_slug).to.eql('series-slug'); expect(parsed.query.campaign_id).to.eql('66'); - expect(parsed.query.special_coverage).to.eql('blooping'); + expect(parsed.query.special_coverage).to.eql('blooping;'); + expect(parsed.query.slid).to.eql('Preroll'); + expect(parsed.query.tpcl).to.eql('PREROLL'); + expect(parsed.query.ptgt).to.eql('a'); }); context('conditionally set parameters', () => { From de5e7a28a1a5a4ecc461070a42d6f3b44f56fa66 Mon Sep 17 00:00:00 2001 From: Melissa Date: Wed, 12 Oct 2016 11:35:18 -0500 Subject: [PATCH 15/21] linter fixes --- elements/bulbs-video/bulbs-video.js | 2 +- elements/bulbs-video/components/revealed.js | 35 ++++++++++++------- .../bulbs-video/components/revealed.test.js | 17 ++++----- 3 files changed, 33 insertions(+), 21 deletions(-) diff --git a/elements/bulbs-video/bulbs-video.js b/elements/bulbs-video/bulbs-video.js index f9eb10d9..099d8ca9 100644 --- a/elements/bulbs-video/bulbs-video.js +++ b/elements/bulbs-video/bulbs-video.js @@ -1,7 +1,7 @@ import React, { PropTypes } from 'react'; import { registerReactElement } from 'bulbs-elements/register'; import BulbsElement from 'bulbs-elements/bulbs-element'; -import { loadOnDemand } from 'bulbs-elements/util' +import { loadOnDemand } from 'bulbs-elements/util'; import VideoField from './fields/video'; import VideoRequest from './fields/video-request'; diff --git a/elements/bulbs-video/components/revealed.js b/elements/bulbs-video/components/revealed.js index 88f93eb6..d6147f98 100644 --- a/elements/bulbs-video/components/revealed.js +++ b/elements/bulbs-video/components/revealed.js @@ -164,19 +164,25 @@ export default class Revealed extends React.Component { } getProfValue () { + let prof; if (window.isMobile.any) { - return 'theonion_mobileweb_html5'; - } else { - return 'theonion_desktop_html5'; + prof = 'theonion_mobileweb_html5'; } + else { + prof = 'theonion_desktop_html5'; + } + return prof; } setDeviceAcronym () { + let deviceAcronym; if (window.isMobile.any) { - return 'm'; - } else { - return 'd'; + deviceAcronym = 'm'; + } + else { + deviceAcronym = 'd'; } + return deviceAcronym; } getSiteName () { @@ -184,14 +190,18 @@ export default class Revealed extends React.Component { } getDfpSection () { + let dfpSection; if (window.TARGETING.dfp_section) { - return window.TARGETING.dfp_section; - } else if (window.TARGETING.dfp_specialcoverage) { + dfpSection = window.TARGETING.dfp_section; + } + else if (window.TARGETING.dfp_specialcoverage) { let slug = window.TARGETING.dfp_specialcoverage; - return `specialcoverage_${slug}`; - } else { - return 'video'; + dfpSection = `specialcoverage_${slug}`; + } + else { + dfpSection = 'video'; } + return dfpSection; } buildCsid (hostChannel) { @@ -271,7 +281,8 @@ export default class Revealed extends React.Component { // random video player number ending with video id // to be used in vastUrl query string let randomVideoPlayerNumber = parseInt( - `${this.cacheBuster()}${videoMeta.id}` + `${this.cacheBuster()}${videoMeta.id}`, + 10 ); videoMeta.vprn = randomVideoPlayerNumber; diff --git a/elements/bulbs-video/components/revealed.test.js b/elements/bulbs-video/components/revealed.test.js index ef7b70fd..12f57224 100644 --- a/elements/bulbs-video/components/revealed.test.js +++ b/elements/bulbs-video/components/revealed.test.js @@ -1,4 +1,5 @@ /* eslint-disable max-len */ +/* eslint-disable no-unused-vars */ import React, { PropTypes } from 'react'; import { shallow } from 'enzyme'; @@ -557,9 +558,9 @@ describe(' ', () => { setDeviceAcronymStub = sinon.stub().returns('d'); getDfpSectionStub = sinon.stub().returns('fun'); response = Revealed.prototype.buildCsid.call({ - getSiteName: getSiteNameStub, - setDeviceAcronym: setDeviceAcronymStub, - getDfpSection: getDfpSectionStub, + getSiteName: getSiteNameStub, + setDeviceAcronym: setDeviceAcronymStub, + getDfpSection: getDfpSectionStub, }, 'host_channel'); }); @@ -604,9 +605,9 @@ describe(' ', () => { it('populates csid', () => { response = Revealed.prototype.buildCsid.call({ - getSiteName: getSiteNameStub, - setDeviceAcronym: setDeviceAcronymStub, - getDfpSection: getDfpSectionStub, + getSiteName: getSiteNameStub, + setDeviceAcronym: setDeviceAcronymStub, + getDfpSection: getDfpSectionStub, }, 'host_channel'); let expected = 'd.website_fun_host_channel'; expect(response).to.eql(expected); @@ -616,7 +617,7 @@ describe(' ', () => { describe('buildCaid', () => { it('sets to onion studios id', () => { let videohubReferenceId = 1234; - let response = Revealed.prototype.buildCaid.call({}, videohubReferenceId) + let response = Revealed.prototype.buildCaid.call({}, videohubReferenceId); expect(response).to.eql('onion_1234'); }); }); @@ -627,7 +628,7 @@ describe(' ', () => { let vastTestStub; let vastUrl; let getProfValueStub; - let getSiteNameStub; + let getSiteNameStub; // eslint-disable no-unused-vars let parsed; let buildCsidStub; let buildCaidStub; From 197df85cdff2ed6ec9b08e57ace91035e832cb3c Mon Sep 17 00:00:00 2001 From: Melissa Date: Wed, 12 Oct 2016 12:05:20 -0500 Subject: [PATCH 16/21] get site name from targeting channel --- elements/bulbs-video/components/revealed.js | 5 ++++- .../bulbs-video/components/revealed.test.js | 21 ++++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/elements/bulbs-video/components/revealed.js b/elements/bulbs-video/components/revealed.js index d6147f98..0315692b 100644 --- a/elements/bulbs-video/components/revealed.js +++ b/elements/bulbs-video/components/revealed.js @@ -9,6 +9,8 @@ import Comscore from '../plugins/comscore'; import React, { PropTypes } from 'react'; import invariant from 'invariant'; +// FIXME: where should this be defined? Per-app? +// or in some better sort of settings file here? global.BULBS_ELEMENTS_ONIONSTUDIOS_GA_ID = 'UA-223393-14'; global.BULBS_ELEMENTS_COMSCORE_ID = '6036328'; @@ -186,7 +188,8 @@ export default class Revealed extends React.Component { } getSiteName () { - return window.location.host.split('.')[1]; + let targetChannel = this.props.video.targeting.target_channel; + return targetChannel.replace(/-/g, ''); } getDfpSection () { diff --git a/elements/bulbs-video/components/revealed.test.js b/elements/bulbs-video/components/revealed.test.js index 12f57224..927ec7bd 100644 --- a/elements/bulbs-video/components/revealed.test.js +++ b/elements/bulbs-video/components/revealed.test.js @@ -547,6 +547,25 @@ describe(' ', () => { }); }); + describe('#getSiteName', () => { + let props; + let response; + + beforeEach(() => { + props = { video: { targeting: { target_channel: 'avclub' } } }; + }); + + it('pulls site name from props.video.targeting.target_channel', () => { + response = Revealed.prototype.getSiteName.call({ props }); + expect(response).to.eql(props.video.targeting.target_channel); + }); + it('it removes hypens from props.video.targeting.target_channel', () => { + props.video.targeting.target_channel = 'the-freakin-onion'; + response = Revealed.prototype.getSiteName.call({ props }); + expect(response).to.eql('thefreakinonion'); + }); + }); + describe('buildCsid', () => { let response; let getSiteNameStub; @@ -578,7 +597,7 @@ describe(' ', () => { expect(response).to.equal('m'); }); - it('sets site name', () => { + it('includes site name', () => { expect(response.includes('website')).to.be.true; }); From b716fdd07ef3a3d6fee1741e7ecb83a943770eab Mon Sep 17 00:00:00 2001 From: Melissa Date: Wed, 12 Oct 2016 13:15:08 -0500 Subject: [PATCH 17/21] make tests safari friendly --- elements/bulbs-video/components/revealed.test.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/elements/bulbs-video/components/revealed.test.js b/elements/bulbs-video/components/revealed.test.js index 927ec7bd..1a809463 100644 --- a/elements/bulbs-video/components/revealed.test.js +++ b/elements/bulbs-video/components/revealed.test.js @@ -598,7 +598,7 @@ describe(' ', () => { }); it('includes site name', () => { - expect(response.includes('website')).to.be.true; + expect(response.indexOf('website') !== -1).to.be.true; }); context('getDfpSection', () => { @@ -731,16 +731,16 @@ describe(' ', () => { }); it('null vastTestId cana not populated', () => { - expect(queryKeys.includes('cana')).to.be.false; + expect(queryKeys.indexOf('cana') === -1).to.be.true; }); it('no series_slug series_slug not populated', () => { - expect(queryKeys.includes('series_slug')).to.be.false; + expect(queryKeys.indexOf('series_slug') === -1).to.be.true; }); it('no targetCampaignId campaign_id not populated', () => { - expect(queryKeys.includes('campaign_id')).to.be.false; + expect(queryKeys.indexOf('campaign_id') === -1).to.be.true; }); it('no targetSpecialCoverage special_coverage not populated', () => { - expect(queryKeys.includes('special_coverage')).to.be.false; + expect(queryKeys.indexOf('special_coverage') === -1).to.be.true; }); }); }); From e8acadbdbd4b25988b0942b2500b39d70fb674ba Mon Sep 17 00:00:00 2001 From: Melissa Date: Thu, 13 Oct 2016 15:02:13 -0500 Subject: [PATCH 18/21] update variable names, replace xgid property with apid "ad placement id" and add nw parameter to vastUrl --- elements/bulbs-video/components/revealed.js | 32 ++--- .../bulbs-video/components/revealed.test.js | 110 ++++++++++++------ 2 files changed, 89 insertions(+), 53 deletions(-) diff --git a/elements/bulbs-video/components/revealed.js b/elements/bulbs-video/components/revealed.js index 0315692b..d987a52b 100644 --- a/elements/bulbs-video/components/revealed.js +++ b/elements/bulbs-video/components/revealed.js @@ -46,9 +46,10 @@ export default class Revealed extends React.Component { ); invariant( - window.FREEWHEEL_NETWORK_ID, - '`` requires `FREEWHEEL_NETWORK_ID` to be set on window.' + window.FREEWHEEL_AD_SERVER, + '`` requires `FREEWHEEL_AD_SERVER` to be set on window.' ); + let gaPrefix = makeGaPrefix(); ga('create', BULBS_ELEMENTS_ONIONSTUDIOS_GA_ID, 'auto', { name: gaPrefix }); @@ -155,7 +156,7 @@ export default class Revealed extends React.Component { vastTest (searchString) { // eslint-disable-line consistent-return if (searchString !== '') { - let vastId = this.parseParam('xgid', searchString); + let vastId = this.parseParam('apid', searchString); if (vastId) { return vastId; @@ -176,7 +177,7 @@ export default class Revealed extends React.Component { return prof; } - setDeviceAcronym () { + getDeviceAcronym () { let deviceAcronym; if (window.isMobile.any) { deviceAcronym = 'm'; @@ -207,23 +208,23 @@ export default class Revealed extends React.Component { return dfpSection; } - buildCsid (hostChannel) { - // Custom Site Section ID + buildCustomSiteSectionId (hostChannel) { // format: .__ - let deviceAcronym = this.setDeviceAcronym(); + let deviceAcronym = this.getDeviceAcronym(); let siteName = this.getSiteName(); let siteSection = this.getDfpSection(); return `${deviceAcronym}.${siteName}_${siteSection}_${hostChannel}`; } - buildCaid (videohubReferenceId) { - // Custom content video asset id + buildCustomContentVideoAssetId (videohubReferenceId) { // format: onion_ return `onion_${videohubReferenceId}`; } vastUrl (videoMeta) { + let networkHash = window.FREEWHEEL_AD_SERVER.NETWORK_HASH; + let networkId = window.FREEWHEEL_AD_SERVER.NETWORK_ID; let hostChannel = videoMeta.hostChannel; let videohubReferenceId = videoMeta.id; let randomVideoPlayerNumber = videoMeta.vprn; @@ -232,13 +233,14 @@ export default class Revealed extends React.Component { let campaignId = this.props.targetCampaignId; let specialCoverage = this.props.targetSpecialCoverage; - let baseUrl = `http://${window.FREEWHEEL_NETWORK_ID}.v.fwmrm.net/ad/g/1?`; + let baseUrl = `http://${networkHash}.v.fwmrm.net/ad/g/1?`; // required global params - baseUrl += 'resp=' + 'vmap1'; + baseUrl += 'nw=' + `${networkId}`; + baseUrl += '&resp=' + 'vmap1'; baseUrl += '&prof=' + this.getProfValue(); - baseUrl += '&csid=' + this.buildCsid(hostChannel); - baseUrl += '&caid=' + this.buildCaid(videohubReferenceId); + baseUrl += '&csid=' + this.buildCustomSiteSectionId(hostChannel); + baseUrl += '&caid=' + this.buildCustomContentVideoAssetId(videohubReferenceId); baseUrl += '&pvrn=' + this.cacheBuster(); baseUrl += '&vprn=' + randomVideoPlayerNumber; @@ -246,14 +248,14 @@ export default class Revealed extends React.Component { if (vastTestId) { baseUrl += '&cana=' + vastTestId; } // Key Values - baseUrl += ';&video_id=' + videohubReferenceId; + baseUrl += ';video_id=' + videohubReferenceId; baseUrl += '&channel_slug=' + videoMeta.channel_slug; if (series) { baseUrl += '&series_slug=' + series; } if (campaignId) { baseUrl += '&campaign_id=' + campaignId; } if (specialCoverage) { baseUrl += '&special_coverage=' + specialCoverage; } // Slot Params *Required Fields* - baseUrl += ';&slid=' + 'Preroll'; + baseUrl += ';slid=' + 'Preroll'; baseUrl += '&tpcl=' + 'PREROLL'; baseUrl += '&ptgt=' + 'a'; diff --git a/elements/bulbs-video/components/revealed.test.js b/elements/bulbs-video/components/revealed.test.js index 1a809463..5697ef0c 100644 --- a/elements/bulbs-video/components/revealed.test.js +++ b/elements/bulbs-video/components/revealed.test.js @@ -202,7 +202,10 @@ describe(' ', () => { state = {}; global.BULBS_ELEMENTS_ONIONSTUDIOS_GA_ID = 'a-ga-id'; global.ga = sinon.spy(); - window.FREEWHEEL_NETWORK_ID = '12345'; + window.FREEWHEEL_AD_SERVER = { + "NETWORK_HASH": "1a345", + "NETWORK_ID": "12345", + }; makeVideoPlayerSpy = sinon.spy(); }); @@ -566,34 +569,34 @@ describe(' ', () => { }); }); - describe('buildCsid', () => { + describe('buildCustomSiteSectionId', () => { let response; let getSiteNameStub; - let setDeviceAcronymStub; + let getDeviceAcronymStub; let getDfpSectionStub; beforeEach(() => { getSiteNameStub = sinon.stub().returns('website'); - setDeviceAcronymStub = sinon.stub().returns('d'); + getDeviceAcronymStub = sinon.stub().returns('d'); getDfpSectionStub = sinon.stub().returns('fun'); - response = Revealed.prototype.buildCsid.call({ + response = Revealed.prototype.buildCustomSiteSectionId.call({ getSiteName: getSiteNameStub, - setDeviceAcronym: setDeviceAcronymStub, + getDeviceAcronym: getDeviceAcronymStub, getDfpSection: getDfpSectionStub, }, 'host_channel'); }); // csid format: .__ // example: d.theonion_specialcoverage_boldness_main - it('#setDeviceAcronym device acronym ', () => { + it('#getDeviceAcronym device acronym ', () => { // desktop window.isMobile.any = false; - response = Revealed.prototype.setDeviceAcronym.call(); + response = Revealed.prototype.getDeviceAcronym.call(); expect(response).to.equal('d'); // mobile window.isMobile.any = true; - response = Revealed.prototype.setDeviceAcronym.call(); + response = Revealed.prototype.getDeviceAcronym.call(); expect(response).to.equal('m'); }); @@ -623,9 +626,9 @@ describe(' ', () => { }); it('populates csid', () => { - response = Revealed.prototype.buildCsid.call({ + response = Revealed.prototype.buildCustomSiteSectionId.call({ getSiteName: getSiteNameStub, - setDeviceAcronym: setDeviceAcronymStub, + getDeviceAcronym: getDeviceAcronymStub, getDfpSection: getDfpSectionStub, }, 'host_channel'); let expected = 'd.website_fun_host_channel'; @@ -633,10 +636,10 @@ describe(' ', () => { }); }); - describe('buildCaid', () => { + describe('buildCustomContentVideoAssetId', () => { it('sets to onion studios id', () => { let videohubReferenceId = 1234; - let response = Revealed.prototype.buildCaid.call({}, videohubReferenceId); + let response = Revealed.prototype.buildCustomContentVideoAssetId.call({}, videohubReferenceId); expect(response).to.eql('onion_1234'); }); }); @@ -649,8 +652,8 @@ describe(' ', () => { let getProfValueStub; let getSiteNameStub; // eslint-disable no-unused-vars let parsed; - let buildCsidStub; - let buildCaidStub; + let buildCustomSiteSectionIdStub; + let buildCustomContentVideoAssetIdStub; let queryKeys; beforeEach(() => { @@ -658,8 +661,8 @@ describe(' ', () => { vastTestStub = sinon.stub().returns(5678); getProfValueStub = sinon.stub().returns('testy'); getSiteNameStub = sinon.stub().returns('website'); - buildCsidStub = sinon.stub().returns('d.website_camping_channel'); - buildCaidStub = sinon.stub().returns('onion_1234'); + buildCustomSiteSectionIdStub = sinon.stub().returns('d.website_camping_channel'); + buildCustomContentVideoAssetIdStub = sinon.stub().returns('onion_1234'); videoMeta = { id: 765, vprn: 456765, @@ -669,9 +672,6 @@ describe(' ', () => { hostChannel: 'host_channel', series_slug: 'series-slug', }; - }); - - it('returns the vast url', function () { vastUrl = Revealed.prototype.vastUrl.call({ props: { targetCampaignId: 66, @@ -680,37 +680,71 @@ describe(' ', () => { cacheBuster: cacheBusterStub, vastTest: vastTestStub, getProfValue: getProfValueStub, - buildCsid: buildCsidStub, - buildCaid: buildCaidStub, + buildCustomSiteSectionId: buildCustomSiteSectionIdStub, + buildCustomContentVideoAssetId: buildCustomContentVideoAssetIdStub, }, videoMeta); parsed = url.parse(vastUrl, true); + }); - let expectedQueryKeys = [ - 'resp', 'prof', 'csid', 'caid', 'pvrn', - 'vprn', 'cana', 'video_id', 'channel_slug', - 'series_slug','campaign_id', 'special_coverage', - 'slid', 'tpcl', 'ptgt', - ]; - queryKeys = Object.keys(parsed.query); - - expect(queryKeys).to.eql(expectedQueryKeys); + it('sets the http: protocol', function () { expect(parsed.protocol).to.eql('http:'); - expect(parsed.host).to.eql('12345.v.fwmrm.net'); + }); + it('sets host', function () { + expect(parsed.host).to.eql('1a345.v.fwmrm.net'); + }); + it('sets pathname', function () { expect(parsed.pathname).to.eql('/ad/g/1'); + }); + it('sets nw', function () { + expect(parsed.query.nw).to.eql('12345'); + }); + it('sets resp', function () { expect(parsed.query.resp).to.eql('vmap1'); + }); + it('sets prof', function () { expect(parsed.query.prof).to.eql('testy'); + }); + it('sets csid', function () { expect(parsed.query.csid).to.eql('d.website_camping_channel'); + }); + it('sets caid', function () { expect(parsed.query.caid).to.eql('onion_1234'); + }); + it('sets pvrn', function () { expect(parsed.query.pvrn).to.eql('456'); + }); + it('sets vprn', function () { expect(parsed.query.vprn).to.eql('456765'); - expect(parsed.query.cana).to.eql('5678;'); - expect(parsed.query.video_id).to.eql('765'); + }); + it('sets cana', function () { + let canaIndex = parsed.search.indexOf('cana=5678'); + expect(canaIndex !== -1).to.be.true; + }); + it('sets video_id', function () { + let vidoeIdIndex = parsed.search.indexOf('video_id=765'); + expect(vidoeIdIndex !== -1).to.be.true; + }); + it('sets channel_slug', function () { expect(parsed.query.channel_slug).to.eql('channel_slug'); + }); + it('sets series_slug', function () { expect(parsed.query.series_slug).to.eql('series-slug'); + }); + it('sets campaign_id', function () { expect(parsed.query.campaign_id).to.eql('66'); - expect(parsed.query.special_coverage).to.eql('blooping;'); - expect(parsed.query.slid).to.eql('Preroll'); + }); + it('sets special_coverage', function () { + let specCovIndex = parsed.search.indexOf('special_coverage=blooping'); + expect(specCovIndex !== -1).to.be.true; + }); + it('sets slid', function () { + let slidIndex = parsed.search.indexOf('slid=Preroll'); + expect(slidIndex !== -1).to.be.true; + }); + it('sets tpcl', function () { expect(parsed.query.tpcl).to.eql('PREROLL'); + }); + it('sets ptgt', function () { expect(parsed.query.ptgt).to.eql('a'); }); @@ -723,8 +757,8 @@ describe(' ', () => { cacheBuster: cacheBusterStub, vastTest: vastTestStub, getProfValue: getProfValueStub, - buildCsid: buildCsidStub, - buildCaid: buildCaidStub, + buildCustomSiteSectionId: buildCustomSiteSectionIdStub, + buildCustomContentVideoAssetId: buildCustomContentVideoAssetIdStub, }, videoMeta); parsed = url.parse(vastUrl, true); queryKeys = Object.keys(parsed.query); From aeca9b96ff557d153ee6b77e26356f595c003d77 Mon Sep 17 00:00:00 2001 From: Melissa Date: Thu, 13 Oct 2016 15:26:40 -0500 Subject: [PATCH 19/21] fix linting errors --- elements/bulbs-video/components/revealed.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/elements/bulbs-video/components/revealed.test.js b/elements/bulbs-video/components/revealed.test.js index 5697ef0c..f9cbce12 100644 --- a/elements/bulbs-video/components/revealed.test.js +++ b/elements/bulbs-video/components/revealed.test.js @@ -203,8 +203,8 @@ describe(' ', () => { global.BULBS_ELEMENTS_ONIONSTUDIOS_GA_ID = 'a-ga-id'; global.ga = sinon.spy(); window.FREEWHEEL_AD_SERVER = { - "NETWORK_HASH": "1a345", - "NETWORK_ID": "12345", + 'NETWORK_HASH': '1a345', + 'NETWORK_ID': '12345', }; makeVideoPlayerSpy = sinon.spy(); }); From 4f97e9b812c5da5fddea3ab4520dc8f6ffb7dc28 Mon Sep 17 00:00:00 2001 From: Melissa Date: Fri, 14 Oct 2016 10:38:58 -0500 Subject: [PATCH 20/21] python and js objects werent playing well together, changed window to contain FREEWHEEL_NETWORK_ID and FREEWHEEL_NETWORK_HASH properties --- elements/bulbs-video/components/revealed.js | 15 +++++++++------ elements/bulbs-video/components/revealed.test.js | 6 ++---- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/elements/bulbs-video/components/revealed.js b/elements/bulbs-video/components/revealed.js index d987a52b..4cf0d396 100644 --- a/elements/bulbs-video/components/revealed.js +++ b/elements/bulbs-video/components/revealed.js @@ -46,8 +46,13 @@ export default class Revealed extends React.Component { ); invariant( - window.FREEWHEEL_AD_SERVER, - '`` requires `FREEWHEEL_AD_SERVER` to be set on window.' + window.FREEWHEEL_NETWORK_ID, + '`` requires `FREEWHEEL_NETWORK_ID` to be set on window.' + ); + + invariant( + window.FREEWHEEL_NETWORK_HASH, + '`` requires `FREEWHEEL_NETWORK_HASH` to be set on window.' ); let gaPrefix = makeGaPrefix(); @@ -223,8 +228,6 @@ export default class Revealed extends React.Component { } vastUrl (videoMeta) { - let networkHash = window.FREEWHEEL_AD_SERVER.NETWORK_HASH; - let networkId = window.FREEWHEEL_AD_SERVER.NETWORK_ID; let hostChannel = videoMeta.hostChannel; let videohubReferenceId = videoMeta.id; let randomVideoPlayerNumber = videoMeta.vprn; @@ -233,10 +236,10 @@ export default class Revealed extends React.Component { let campaignId = this.props.targetCampaignId; let specialCoverage = this.props.targetSpecialCoverage; - let baseUrl = `http://${networkHash}.v.fwmrm.net/ad/g/1?`; + let baseUrl = `http://${window.FREEWHEEL_NETWORK_HASH}.v.fwmrm.net/ad/g/1?`; // required global params - baseUrl += 'nw=' + `${networkId}`; + baseUrl += 'nw=' + `${window.FREEWHEEL_NETWORK_ID}`; baseUrl += '&resp=' + 'vmap1'; baseUrl += '&prof=' + this.getProfValue(); baseUrl += '&csid=' + this.buildCustomSiteSectionId(hostChannel); diff --git a/elements/bulbs-video/components/revealed.test.js b/elements/bulbs-video/components/revealed.test.js index f9cbce12..9d242866 100644 --- a/elements/bulbs-video/components/revealed.test.js +++ b/elements/bulbs-video/components/revealed.test.js @@ -202,10 +202,8 @@ describe(' ', () => { state = {}; global.BULBS_ELEMENTS_ONIONSTUDIOS_GA_ID = 'a-ga-id'; global.ga = sinon.spy(); - window.FREEWHEEL_AD_SERVER = { - 'NETWORK_HASH': '1a345', - 'NETWORK_ID': '12345', - }; + window.FREEWHEEL_NETWORK_ID = '12345'; + window.FREEWHEEL_NETWORK_HASH = '1a345'; makeVideoPlayerSpy = sinon.spy(); }); From fe7e83136247361c99bed82ea053aa332c5c1f6f Mon Sep 17 00:00:00 2001 From: Melissa Date: Fri, 14 Oct 2016 12:09:37 -0500 Subject: [PATCH 21/21] rm comments --- elements/bulbs-video/components/revealed.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/elements/bulbs-video/components/revealed.js b/elements/bulbs-video/components/revealed.js index 4cf0d396..61fc34d6 100644 --- a/elements/bulbs-video/components/revealed.js +++ b/elements/bulbs-video/components/revealed.js @@ -214,7 +214,6 @@ export default class Revealed extends React.Component { } buildCustomSiteSectionId (hostChannel) { - // format: .__ let deviceAcronym = this.getDeviceAcronym(); let siteName = this.getSiteName(); let siteSection = this.getDfpSection(); @@ -223,7 +222,6 @@ export default class Revealed extends React.Component { } buildCustomContentVideoAssetId (videohubReferenceId) { - // format: onion_ return `onion_${videohubReferenceId}`; }