From c80ed238c12ab96c9c716d761a56cd2e5a9eb03e Mon Sep 17 00:00:00 2001 From: guillaume-sticky Date: Sat, 29 Sep 2018 00:23:28 +0200 Subject: [PATCH] Minor freewheel-ssp update (#3119) * 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 --- modules/freewheel-sspBidAdapter.js | 6 +- .../modules/freewheel-sspBidAdapter_spec.js | 90 +++++++++++++------ 2 files changed, 70 insertions(+), 26 deletions(-) diff --git a/modules/freewheel-sspBidAdapter.js b/modules/freewheel-sspBidAdapter.js index 321d5ee95e8..c85edd9188c 100644 --- a/modules/freewheel-sspBidAdapter.js +++ b/modules/freewheel-sspBidAdapter.js @@ -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 = {' + diff --git a/test/spec/modules/freewheel-sspBidAdapter_spec.js b/test/spec/modules/freewheel-sspBidAdapter_spec.js index a1123cee151..177deaca7e7 100644 --- a/test/spec/modules/freewheel-sspBidAdapter_spec.js +++ b/test/spec/modules/freewheel-sspBidAdapter_spec.js @@ -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]], @@ -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=='); @@ -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]], @@ -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 = '' + '' + ' ' + @@ -142,10 +160,11 @@ describe('freewheel-ssp BidAdapter Test', function () { ''; let ad = '
'; - let formattedAd = '
'; + let intextAd = '
'; + let expandAd = '
'; - 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 = [ { @@ -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 = [ { @@ -178,7 +218,7 @@ describe('freewheel-ssp BidAdapter Test', function () { currency: 'EUR', netRevenue: true, ttl: 360, - ad: formattedAd + ad: intextAd } ]; @@ -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 = ''; let result = spec.interpretResponse(response, reqest);