Skip to content

Commit

Permalink
Minor freewheel-ssp update (#3119)
Browse files Browse the repository at this point in the history
* add stickyadsTV bidder adapter

* init unit test file

* ad some unit tests

* fix unit test on ad format with parameters

* add some unit tests

* add unit tests on getBid method

* add some test cases in unit tests

* minor fix on component id tag.

* remove adapters-sticky.json test file

* use top most accessible window instead of window.top

* Pass in the bid request in the createBid call.

* use top most accessible window instead of window.top

* add unit tests

* update unit tests

* fix unit test.

* fix CI build

* add alias freewheel-ssp

* update unit tests on bidderCode value

* fix component id values and add unit tests

* allws to use any outstream format.

* fix ASLoader on futur outstream format versions

* minor: fix code format.

* update unit tests

* minor fix code format

* minor: add missing new line at eof

* replace StickyAdsTVAdapter by freewheel ssp bd adapter (for prebid 1.0)

* remove old stickyadstv unittest spec.

* fix server response parsing if sent as object with 'body' field

* use the vastXml field for video mediatype

* add user sync pixel in freewheel ssp adapter

* remove all console log calls (replaced using util helper)

* remove useless bidderCode (automatically added by the bidderFactory)

* Return the SYNC pixel to be added in the page by Prebid.js

* remove instance level properties to enable concurrent bids with the same adapter instance.

* fix the request apss through and corresponding unit tests

* fix 'freeheelssp' typo

* add vast parameters feature and GDPR params in VAST request

* fix lint issues

* add gdpr parameter support on freewheelSSPBidAdapter

* use bidderrequest to read gdpr parameters and update unit tests

* fix lint errors

* fix lint errors

* fix typo and bidderRequest reference.

* fix bidderRequest reference.

* add missing declaration for 'key' variable

* rename frewheel ssp bid adapter files to match the bidder code (fix custom download issues)

* update unit tests using the new name freewheel-ssp

* update documented test zone to a more recent one

* target created div insitead of original placement (avoid some misplaced ad)

* fix target div size

* add key and timestamp parameters for a better request identification.

* Remove the arrow function call so the style  is consistent throughout the file

* update position configuration for freewheel-sspBidAdapter

* add unit tests for the new display case
  • Loading branch information
guillaume-sticky authored and harpere committed Sep 28, 2018
1 parent 0bd1d1a commit 41c68ad
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 26 deletions.
6 changes: 5 additions & 1 deletion modules/freewheel-sspBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,11 @@ var getOutstreamScript = function(bid) {

// default placement if no placement is set
if (!config.hasOwnProperty('domId') && !config.hasOwnProperty('auto') && !config.hasOwnProperty('p') && !config.hasOwnProperty('article')) {
config.domId = 'freewheelssp_prebid_target';
if (config.format === 'intext-roll') {
config.iframeMode = 'dfp';
} else {
config.domId = 'freewheelssp_prebid_target';
}
}

var script = 'var config = {' +
Expand Down
90 changes: 65 additions & 25 deletions test/spec/modules/freewheel-sspBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ describe('freewheel-ssp BidAdapter Test', function () {
{
'bidder': 'freewheel-ssp',
'params': {
'zoneId': '277225'
'zoneId': '277225',
'vastUrlParams': {'ownerId': 'kombRJ'}
},
'adUnitCode': 'adunit-code',
'sizes': [[300, 250], [300, 600]],
Expand All @@ -66,6 +67,7 @@ describe('freewheel-ssp BidAdapter Test', function () {
expect(payload.protocolVersion).to.equal('2.0');
expect(payload.zoneId).to.equal('277225');
expect(payload.componentId).to.equal('mustang');
expect(payload.ownerId).to.equal('kombRJ');
expect(payload.playerSize).to.equal('300x600');
expect(payload._fw_gdpr).to.equal(true);
expect(payload._fw_gdpr_consent).to.equal('BOJ/P2HOJ/P2HABABMAAAAAZ+A==');
Expand All @@ -76,29 +78,15 @@ describe('freewheel-ssp BidAdapter Test', function () {
expect(request.url).to.contain(ENDPOINT);
expect(request.method).to.equal('GET');
});
})

describe('interpretResponse', function () {
let bidRequests = [
{
'bidder': 'freewheel-ssp',
'params': {
'zoneId': '277225'
},
'adUnitCode': 'adunit-code',
'sizes': [[300, 250], [300, 600]],
'bidId': '30b31c1838de1e',
'bidderRequestId': '22edbae2733bf6',
'auctionId': '1d1a030790a475',
}
];
});

let formattedBidRequests = [
describe('interpretResponse - formated', function () {
let intextBidRequests = [
{
'bidder': 'freewheel-ssp',
'params': {
'zoneId': '277225',
'format': 'floorad'
'format': 'intext-roll'
},
'adUnitCode': 'adunit-code',
'sizes': [[600, 250], [300, 600]],
Expand All @@ -120,6 +108,36 @@ describe('freewheel-ssp BidAdapter Test', function () {
}
];

let expandBidRequests = [
{
'bidder': 'freewheel-ssp',
'params': {
'zoneId': '277225',
'format': 'expand-banner',
'vastUrlParams': {'ownerId': 'kombRJ'}
},
'adUnitCode': 'adunit-code',
'sizes': [[600, 250], [300, 600]],
'bidId': '30b3other1c1838de1e',
'bidderRequestId': '22edbae273other3bf6',
'auctionId': '1d1a03079test0a475',
}
];

let bannerBidRequests = [
{
'bidder': 'freewheel-ssp',
'params': {
'zoneId': '277225'
},
'adUnitCode': 'adunit-code',
'sizes': [[600, 250], [300, 600]],
'bidId': '30b3other1c1838de1e',
'bidderRequestId': '22edbae273other3bf6',
'auctionId': '1d1a03079test0a475',
}
];

let response = '<?xml version=\'1.0\' encoding=\'UTF-8\'?><VAST version=\'2.0\'>' +
'<Ad id=\'AdswizzAd28517153\'>' +
' <InLine>' +
Expand All @@ -142,10 +160,11 @@ describe('freewheel-ssp BidAdapter Test', function () {
'</VAST>';

let ad = '<div id="freewheelssp_prebid_target"></div><script type=\'text/javascript\'>(function() { var st = document.createElement(\'script\'); st.type = \'text/javascript\'; st.async = true; st.src = \'http://cdn.stickyadstv.com/mustang/mustang.min.js\'; st.onload = function(){ var vastLoader = new window.com.stickyadstv.vast.VastLoader(); var vast = vastLoader.getVast(); var topWindow = (function(){var res=window; try{while(top != res){if(res.parent.location.href.length)res=res.parent;}}catch(e){}return res;})(); vast.setXmlString(topWindow.freeheelssp_cache["adunit-code"]); vastLoader.parseAds(vast, { onSuccess: function() {var config = { preloadedVast:vast, autoPlay:true }; var ad = new window.com.stickyadstv.vpaid.Ad(document.getElementById("freewheelssp_prebid_target"),config); (new window.com.stickyadstv.tools.ASLoader(277225, \'mustang\')).registerEvents(ad); ad.initAd(300,600,"",0,"",""); } }); }; document.head.appendChild(st);})();</script>';
let formattedAd = '<div id="freewheelssp_prebid_target"></div><script type=\'text/javascript\'>(function() { var st = document.createElement(\'script\'); st.type = \'text/javascript\'; st.async = true; st.src = \'http://cdn.stickyadstv.com/prime-time/floorad.min.js\'; st.onload = function(){ var vastLoader = new window.com.stickyadstv.vast.VastLoader(); var vast = vastLoader.getVast(); var topWindow = (function(){var res=window; try{while(top != res){if(res.parent.location.href.length)res=res.parent;}}catch(e){}return res;})(); vast.setXmlString(topWindow.freeheelssp_cache["adunit-code"]); vastLoader.parseAds(vast, { onSuccess: function() {var config = { preloadedVast:vast, ASLoader:new window.com.stickyadstv.tools.ASLoader(277225, \'floorad\'),domId:"adunit-code"};window.com.stickyadstv.floorad.start(config); } }); }; document.head.appendChild(st);})();</script>';
let intextAd = '<div id="freewheelssp_prebid_target"></div><script type=\'text/javascript\'>(function() { var st = document.createElement(\'script\'); st.type = \'text/javascript\'; st.async = true; st.src = \'http://cdn.stickyadstv.com/prime-time/intext-roll.min.js\'; st.onload = function(){ var vastLoader = new window.com.stickyadstv.vast.VastLoader(); var vast = vastLoader.getVast(); var topWindow = (function(){var res=window; try{while(top != res){if(res.parent.location.href.length)res=res.parent;}}catch(e){}return res;})(); vast.setXmlString(topWindow.freeheelssp_cache["adunit-code"]); vastLoader.parseAds(vast, { onSuccess: function() {var config = { preloadedVast:vast, ASLoader:new window.com.stickyadstv.tools.ASLoader(277225, \'intext-roll\'),iframeMode:"dfp"};window.com.stickyadstv.intextroll.start(config); } }); }; document.head.appendChild(st);})();</script>';
let expandAd = '<div id="freewheelssp_prebid_target"></div><script type=\'text/javascript\'>(function() { var st = document.createElement(\'script\'); st.type = \'text/javascript\'; st.async = true; st.src = \'http://cdn.stickyadstv.com/prime-time/expand-banner.min.js\'; st.onload = function(){ var vastLoader = new window.com.stickyadstv.vast.VastLoader(); var vast = vastLoader.getVast(); var topWindow = (function(){var res=window; try{while(top != res){if(res.parent.location.href.length)res=res.parent;}}catch(e){}return res;})(); vast.setXmlString(topWindow.freeheelssp_cache["adunit-code"]); vastLoader.parseAds(vast, { onSuccess: function() {var config = { preloadedVast:vast, ASLoader:new window.com.stickyadstv.tools.ASLoader(277225, \'expand-banner\'),domId:"adunit-code"};window.com.stickyadstv.intextroll.start(config); } }); }; document.head.appendChild(st);})();</script>';

it('should get correct bid response', function () {
var request = spec.buildRequests(formattedBidRequests, formattedBidRequests[0]);
it('should get correct intext bid response', function () {
var request = spec.buildRequests(bannerBidRequests, bannerBidRequests[0]);

let expectedResponse = [
{
Expand All @@ -165,8 +184,29 @@ describe('freewheel-ssp BidAdapter Test', function () {
expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0]));
});

it('should get correct expand bid response', function () {
var request = spec.buildRequests(expandBidRequests, expandBidRequests[0]);

let expectedResponse = [
{
requestId: '30b31c1838de1e',
cpm: '0.2000',
width: 300,
height: 600,
creativeId: '28517153',
currency: 'EUR',
netRevenue: true,
ttl: 360,
ad: expandAd
}
];

let result = spec.interpretResponse(response, request);
expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0]));
});

it('should get correct bid response with formated ad', function () {
var request = spec.buildRequests(formattedBidRequests, formattedBidRequests[0]);
var request = spec.buildRequests(intextBidRequests, intextBidRequests[0]);

let expectedResponse = [
{
Expand All @@ -178,7 +218,7 @@ describe('freewheel-ssp BidAdapter Test', function () {
currency: 'EUR',
netRevenue: true,
ttl: 360,
ad: formattedAd
ad: intextAd
}
];

Expand All @@ -187,7 +227,7 @@ describe('freewheel-ssp BidAdapter Test', function () {
});

it('handles nobid responses', function () {
var reqest = spec.buildRequests(formattedBidRequests, formattedBidRequests[0]);
var reqest = spec.buildRequests(intextBidRequests, intextBidRequests[0]);
let response = '<?xml version=\'1.0\' encoding=\'UTF-8\'?><VAST version=\'2.0\'></VAST>';

let result = spec.interpretResponse(response, reqest);
Expand Down

0 comments on commit 41c68ad

Please sign in to comment.