From 6f1e6625cea75401d128f2fe8b151c17d2eb5f4a Mon Sep 17 00:00:00 2001 From: Llywelyn OWEN Date: Thu, 3 Jun 2021 12:04:11 +0200 Subject: [PATCH 01/14] SmartAdServer-Version5.0Compliance adomain added --- modules/smartadserverBidAdapter.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/smartadserverBidAdapter.js b/modules/smartadserverBidAdapter.js index bb9364c72c3..bbe6f2aa334 100644 --- a/modules/smartadserverBidAdapter.js +++ b/modules/smartadserverBidAdapter.js @@ -161,6 +161,11 @@ export const spec = { bidResponse.ad = response.ad; } + // WE DON'T FULLY SUPPORT THIS ATM - future spot for adomain code; creating a stub for 5.0 compliance + if (response.adomain) { + bidResponse.meta = Object.assign({}, bidResponse.meta, { advertiserDomains: [] }); + } + bidResponses.push(bidResponse); } } catch (error) { From 4c77cb81d8a09de39612aae3e283b372ee6b5ba5 Mon Sep 17 00:00:00 2001 From: Llywelyn OWEN Date: Thu, 3 Jun 2021 15:38:55 +0200 Subject: [PATCH 02/14] Updating prebid to 5.0 now lets test. --- modules/smartadserverBidAdapter.js | 39 ++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/modules/smartadserverBidAdapter.js b/modules/smartadserverBidAdapter.js index bbe6f2aa334..4306395bed7 100644 --- a/modules/smartadserverBidAdapter.js +++ b/modules/smartadserverBidAdapter.js @@ -12,6 +12,7 @@ import { import { createEidsArray } from './userId/eids.js'; +import { defaultConfig } from 'sinon'; const BIDDER_CODE = 'smartadserver'; const GVL_ID = 45; export const spec = { @@ -86,15 +87,39 @@ export const spec = { h: size[1] })); } else if (videoMediaType && (videoMediaType.context === 'instream' || videoMediaType.context === 'outstream')) { + + //We use the mediaType.Video.params when availabe however we override with bidder.param if available. + var protocol = bid.params.video.protocol ? bid.params.video.protocol : Math.max(videoMediaType.protocol) + var startDelay = -1; + if (!bid.params.video.startDelay){ + switch (videoMediaType.startdelay) + { + case 0: + startDelay = 1; + break; + case -1: + startDelay = 2; + break; + case -2: + startDelay = 3; + break; + default: + startDelay = -1; + } + } + else{ + startDelay = bid.params.video.startDelay; + } + // Specific attributes for instream. let playerSize = videoMediaType.playerSize[0]; payload.isVideo = videoMediaType.context === 'instream'; payload.mediaType = VIDEO; payload.videoData = { - videoProtocol: bid.params.video.protocol, + videoProtocol: protocol, playerWidth: playerSize[0], playerHeight: playerSize[1], - adBreak: bid.params.video.startDelay || 1 + adBreak: startDelay }; } else { return {}; @@ -148,7 +173,9 @@ export const spec = { currency: response.currency, netRevenue: response.isNetCpm, ttl: response.ttl, - dspPixels: response.dspPixels + dspPixels: response.dspPixels, + // WE DON'T FULLY SUPPORT THIS ATM - will always return empty array until implemented on our side. + meta: { advertiserDomains: response.adomain ? response.adomain : [] } }; if (bidRequest.mediaType === VIDEO) { @@ -161,10 +188,8 @@ export const spec = { bidResponse.ad = response.ad; } - // WE DON'T FULLY SUPPORT THIS ATM - future spot for adomain code; creating a stub for 5.0 compliance - if (response.adomain) { - bidResponse.meta = Object.assign({}, bidResponse.meta, { advertiserDomains: [] }); - } + // use IAB ORTB values if the corresponding values weren't already set by bid.params.video + bidResponses.push(bidResponse); } From ace715fca177e09399fffdb72d03e7e239036515 Mon Sep 17 00:00:00 2001 From: Llywelyn OWEN Date: Thu, 3 Jun 2021 15:47:31 +0200 Subject: [PATCH 03/14] Improving the switch case --- modules/smartadserverBidAdapter.js | 36 +++++++++++++----------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/modules/smartadserverBidAdapter.js b/modules/smartadserverBidAdapter.js index 4306395bed7..9cc2730f7ef 100644 --- a/modules/smartadserverBidAdapter.js +++ b/modules/smartadserverBidAdapter.js @@ -88,27 +88,24 @@ export const spec = { })); } else if (videoMediaType && (videoMediaType.context === 'instream' || videoMediaType.context === 'outstream')) { - //We use the mediaType.Video.params when availabe however we override with bidder.param if available. + // use IAB ORTB values if the corresponding values weren't already set by bid.params.video var protocol = bid.params.video.protocol ? bid.params.video.protocol : Math.max(videoMediaType.protocol) var startDelay = -1; - if (!bid.params.video.startDelay){ - switch (videoMediaType.startdelay) - { - case 0: - startDelay = 1; - break; - case -1: - startDelay = 2; - break; - case -2: - startDelay = 3; - break; - default: - startDelay = -1; - } + + if (bid.params.video.startDelay){ + startDelay = bid.params.video.startDelay + } + else if (videoMediaType.startdelay == 0) + { + startDelay = 1; + } + else if (videoMediaType.startdelay == -1) + { + startDelay = 2; } - else{ - startDelay = bid.params.video.startDelay; + else if (videoMediaType.startdelay == -2) + { + startDelay = 3; } // Specific attributes for instream. @@ -188,9 +185,6 @@ export const spec = { bidResponse.ad = response.ad; } - // use IAB ORTB values if the corresponding values weren't already set by bid.params.video - - bidResponses.push(bidResponse); } } catch (error) { From 1b937cdb6a4b392537e39545bc98ada20bb327b0 Mon Sep 17 00:00:00 2001 From: Llywelyn OWEN Date: Thu, 3 Jun 2021 16:49:08 +0200 Subject: [PATCH 04/14] Fixing tests. --- modules/smartadserverBidAdapter.js | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/modules/smartadserverBidAdapter.js b/modules/smartadserverBidAdapter.js index 9cc2730f7ef..5cb2b643cfc 100644 --- a/modules/smartadserverBidAdapter.js +++ b/modules/smartadserverBidAdapter.js @@ -12,7 +12,6 @@ import { import { createEidsArray } from './userId/eids.js'; -import { defaultConfig } from 'sinon'; const BIDDER_CODE = 'smartadserver'; const GVL_ID = 45; export const spec = { @@ -87,24 +86,17 @@ export const spec = { h: size[1] })); } else if (videoMediaType && (videoMediaType.context === 'instream' || videoMediaType.context === 'outstream')) { - // use IAB ORTB values if the corresponding values weren't already set by bid.params.video var protocol = bid.params.video.protocol ? bid.params.video.protocol : Math.max(videoMediaType.protocol) var startDelay = -1; - if (bid.params.video.startDelay){ + if (bid.params.video.startDelay) { startDelay = bid.params.video.startDelay - } - else if (videoMediaType.startdelay == 0) - { + } else if (videoMediaType.startdelay == 0) { startDelay = 1; - } - else if (videoMediaType.startdelay == -1) - { + } else if (videoMediaType.startdelay == -1) { startDelay = 2; - } - else if (videoMediaType.startdelay == -2) - { + } else if (videoMediaType.startdelay == -2) { startDelay = 3; } From f9e9a9b1c78e547606650718e0a56c5a111c8eee Mon Sep 17 00:00:00 2001 From: Llywelyn OWEN Date: Thu, 3 Jun 2021 17:50:01 +0200 Subject: [PATCH 05/14] Fixing startdelay default val and remove comment --- modules/smartadserverBidAdapter.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/smartadserverBidAdapter.js b/modules/smartadserverBidAdapter.js index 5cb2b643cfc..5666da9eb01 100644 --- a/modules/smartadserverBidAdapter.js +++ b/modules/smartadserverBidAdapter.js @@ -86,9 +86,8 @@ export const spec = { h: size[1] })); } else if (videoMediaType && (videoMediaType.context === 'instream' || videoMediaType.context === 'outstream')) { - // use IAB ORTB values if the corresponding values weren't already set by bid.params.video var protocol = bid.params.video.protocol ? bid.params.video.protocol : Math.max(videoMediaType.protocol) - var startDelay = -1; + var startDelay = 2; if (bid.params.video.startDelay) { startDelay = bid.params.video.startDelay From d65914e65f1643a6be556bd85bfbfe6430e10295 Mon Sep 17 00:00:00 2001 From: Llywelyn OWEN Date: Thu, 3 Jun 2021 17:55:11 +0200 Subject: [PATCH 06/14] Removed wrong comment and protocol to protocols --- modules/smartadserverBidAdapter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/smartadserverBidAdapter.js b/modules/smartadserverBidAdapter.js index 5666da9eb01..0ffe2767bfb 100644 --- a/modules/smartadserverBidAdapter.js +++ b/modules/smartadserverBidAdapter.js @@ -86,7 +86,8 @@ export const spec = { h: size[1] })); } else if (videoMediaType && (videoMediaType.context === 'instream' || videoMediaType.context === 'outstream')) { - var protocol = bid.params.video.protocol ? bid.params.video.protocol : Math.max(videoMediaType.protocol) + // use IAB ORTB values if the corresponding values weren't already set by bid.params.video + var protocol = bid.params.video.protocol ? bid.params.video.protocol : Math.max(videoMediaType.protocols) var startDelay = 2; if (bid.params.video.startDelay) { @@ -162,7 +163,6 @@ export const spec = { netRevenue: response.isNetCpm, ttl: response.ttl, dspPixels: response.dspPixels, - // WE DON'T FULLY SUPPORT THIS ATM - will always return empty array until implemented on our side. meta: { advertiserDomains: response.adomain ? response.adomain : [] } }; From 76c312703966828be84a50a0b26c03ff2b2fc515 Mon Sep 17 00:00:00 2001 From: Llywelyn OWEN Date: Thu, 3 Jun 2021 18:21:32 +0200 Subject: [PATCH 07/14] Making sure the value we math.Max is valid --- modules/smartadserverBidAdapter.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/modules/smartadserverBidAdapter.js b/modules/smartadserverBidAdapter.js index 0ffe2767bfb..2d6541fe84f 100644 --- a/modules/smartadserverBidAdapter.js +++ b/modules/smartadserverBidAdapter.js @@ -87,9 +87,18 @@ export const spec = { })); } else if (videoMediaType && (videoMediaType.context === 'instream' || videoMediaType.context === 'outstream')) { // use IAB ORTB values if the corresponding values weren't already set by bid.params.video - var protocol = bid.params.video.protocol ? bid.params.video.protocol : Math.max(videoMediaType.protocols) - var startDelay = 2; + // Assign a default protocol, the higher value means we are retrocompatible. Increase this to latest version when necessary. + var protocol = 4.0; + if (bid.params.video.protocol){ + protocol = bid.params.video.protocol; + } + //Checks if not : null, undefined, Nan, emptyString, 0 or false + else if (videoMediaType.protocols) + { + protocol = Math.max(videoMediaType.protocols); + } + var startDelay = 2; if (bid.params.video.startDelay) { startDelay = bid.params.video.startDelay } else if (videoMediaType.startdelay == 0) { From 8fd62ea7712356c42b0cc3f78fed1714794ad915 Mon Sep 17 00:00:00 2001 From: Llywelyn OWEN Date: Thu, 3 Jun 2021 18:34:43 +0200 Subject: [PATCH 08/14] checked protocol valid & default val added --- modules/smartadserverBidAdapter.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/smartadserverBidAdapter.js b/modules/smartadserverBidAdapter.js index 2d6541fe84f..277c67e660b 100644 --- a/modules/smartadserverBidAdapter.js +++ b/modules/smartadserverBidAdapter.js @@ -87,17 +87,17 @@ export const spec = { })); } else if (videoMediaType && (videoMediaType.context === 'instream' || videoMediaType.context === 'outstream')) { // use IAB ORTB values if the corresponding values weren't already set by bid.params.video - // Assign a default protocol, the higher value means we are retrocompatible. Increase this to latest version when necessary. - var protocol = 4.0; + // Assign a default protocol, the highest value possible means we are retrocompatible with all older values. + var protocol = 8; if (bid.params.video.protocol){ protocol = bid.params.video.protocol; } - //Checks if not : null, undefined, Nan, emptyString, 0 or false else if (videoMediaType.protocols) { protocol = Math.max(videoMediaType.protocols); } + //Default value for all exotic cases set to bid.params.video.startDelay midroll hence 2. var startDelay = 2; if (bid.params.video.startDelay) { startDelay = bid.params.video.startDelay From f69f7eec82ab1e721ee7954efdd0f03275be6323 Mon Sep 17 00:00:00 2001 From: Llywelyn OWEN Date: Fri, 4 Jun 2021 10:37:53 +0200 Subject: [PATCH 09/14] Default protocol is null --- modules/smartadserverBidAdapter.js | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/modules/smartadserverBidAdapter.js b/modules/smartadserverBidAdapter.js index 277c67e660b..bc66b3f035f 100644 --- a/modules/smartadserverBidAdapter.js +++ b/modules/smartadserverBidAdapter.js @@ -88,16 +88,9 @@ export const spec = { } else if (videoMediaType && (videoMediaType.context === 'instream' || videoMediaType.context === 'outstream')) { // use IAB ORTB values if the corresponding values weren't already set by bid.params.video // Assign a default protocol, the highest value possible means we are retrocompatible with all older values. - var protocol = 8; - if (bid.params.video.protocol){ - protocol = bid.params.video.protocol; - } - else if (videoMediaType.protocols) - { - protocol = Math.max(videoMediaType.protocols); - } + var protocol = bid.params.video.protocol ? bid.params.video.protocol : videoMediaType.protocols ? Math.max(videoMediaType.protocols) : null; - //Default value for all exotic cases set to bid.params.video.startDelay midroll hence 2. + // Default value for all exotic cases set to bid.params.video.startDelay midroll hence 2. var startDelay = 2; if (bid.params.video.startDelay) { startDelay = bid.params.video.startDelay From 892225a8b4c908570e38d7f88d6583d5d2d5f604 Mon Sep 17 00:00:00 2001 From: Llywelyn OWEN Date: Fri, 4 Jun 2021 14:17:02 +0200 Subject: [PATCH 10/14] easier to read code --- modules/smartadserverBidAdapter.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/smartadserverBidAdapter.js b/modules/smartadserverBidAdapter.js index bc66b3f035f..9809929ec66 100644 --- a/modules/smartadserverBidAdapter.js +++ b/modules/smartadserverBidAdapter.js @@ -88,7 +88,12 @@ export const spec = { } else if (videoMediaType && (videoMediaType.context === 'instream' || videoMediaType.context === 'outstream')) { // use IAB ORTB values if the corresponding values weren't already set by bid.params.video // Assign a default protocol, the highest value possible means we are retrocompatible with all older values. - var protocol = bid.params.video.protocol ? bid.params.video.protocol : videoMediaType.protocols ? Math.max(videoMediaType.protocols) : null; + var protocol = null; + if (bid.params.video.protocol){ + protocol = bid.params.video.protocol; + } else if (videoMediaType.protocols) { + Math.max(videoMediaType.protocols); + } // Default value for all exotic cases set to bid.params.video.startDelay midroll hence 2. var startDelay = 2; From ad0c2d0cee4b1a4863510c5adb7fa294ab25a051 Mon Sep 17 00:00:00 2001 From: Llywelyn OWEN Date: Fri, 4 Jun 2021 17:00:38 +0200 Subject: [PATCH 11/14] added assignement of protocols = --- modules/smartadserverBidAdapter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/smartadserverBidAdapter.js b/modules/smartadserverBidAdapter.js index 9809929ec66..9597025fbbe 100644 --- a/modules/smartadserverBidAdapter.js +++ b/modules/smartadserverBidAdapter.js @@ -89,10 +89,10 @@ export const spec = { // use IAB ORTB values if the corresponding values weren't already set by bid.params.video // Assign a default protocol, the highest value possible means we are retrocompatible with all older values. var protocol = null; - if (bid.params.video.protocol){ + if (bid.params.video.protocol) { protocol = bid.params.video.protocol; } else if (videoMediaType.protocols) { - Math.max(videoMediaType.protocols); + protocol = Math.max(videoMediaType.protocols); } // Default value for all exotic cases set to bid.params.video.startDelay midroll hence 2. From df32ac77b8432bdd26ee4d8cc7e4e204ea209385 Mon Sep 17 00:00:00 2001 From: Llywelyn OWEN Date: Mon, 7 Jun 2021 12:27:00 +0200 Subject: [PATCH 12/14] Added tests and fixed adapter thanks to test --- modules/smartadserverBidAdapter.js | 8 +- .../modules/smartadserverBidAdapter_spec.js | 124 +++++++++++++++++- 2 files changed, 127 insertions(+), 5 deletions(-) diff --git a/modules/smartadserverBidAdapter.js b/modules/smartadserverBidAdapter.js index 9597025fbbe..54c58084dff 100644 --- a/modules/smartadserverBidAdapter.js +++ b/modules/smartadserverBidAdapter.js @@ -89,15 +89,15 @@ export const spec = { // use IAB ORTB values if the corresponding values weren't already set by bid.params.video // Assign a default protocol, the highest value possible means we are retrocompatible with all older values. var protocol = null; - if (bid.params.video.protocol) { + if (bid.params.video && bid.params.video.protocol) { protocol = bid.params.video.protocol; - } else if (videoMediaType.protocols) { - protocol = Math.max(videoMediaType.protocols); + } else if (Array.isArray(videoMediaType.protocols)) { + protocol = Math.max.apply(Math, videoMediaType.protocols); } // Default value for all exotic cases set to bid.params.video.startDelay midroll hence 2. var startDelay = 2; - if (bid.params.video.startDelay) { + if (bid.params.video && bid.params.video.startDelay) { startDelay = bid.params.video.startDelay } else if (videoMediaType.startdelay == 0) { startDelay = 1; diff --git a/test/spec/modules/smartadserverBidAdapter_spec.js b/test/spec/modules/smartadserverBidAdapter_spec.js index 749de43b9af..9c2adf10b06 100644 --- a/test/spec/modules/smartadserverBidAdapter_spec.js +++ b/test/spec/modules/smartadserverBidAdapter_spec.js @@ -432,7 +432,7 @@ describe('Smart bid adapter tests', function () { appName: 'Mozilla', ckId: 42, video: { - protocol: 6 + protocol: 6, } }, requestId: 'efgh5678', @@ -539,6 +539,128 @@ describe('Smart bid adapter tests', function () { expect(request[0]).to.be.empty; expect(request[1]).to.not.be.empty; }); + + it('Verify videoData assigns values from meta', function () { + config.setConfig({ + 'currency': { + 'adServerCurrency': 'EUR' + } + }); + const request = spec.buildRequests([{ + adUnitCode: 'sas_42', + bidId: 'abcd1234', + bidder: 'smartadserver', + mediaTypes: { + video: { + context: 'instream', + playerSize: [[640, 480]], // It seems prebid.js transforms the player size array into an array of array... + protocols: [8, 2], + startdelay: 0 + } + }, + params: { + siteId: '1234', + pageId: '5678', + formatId: '90', + target: 'test=prebid', + bidfloor: 0.420, + buId: '7569', + appName: 'Mozilla', + ckId: 42, + }, + requestId: 'efgh5678', + transactionId: 'zsfgzzg' + }]); + + expect(request[0]).to.have.property('url').and.to.equal('https://prg.smartadserver.com/prebid/v1'); + expect(request[0]).to.have.property('method').and.to.equal('POST'); + const requestContent = JSON.parse(request[0].data); + expect(requestContent).to.have.property('videoData'); + expect(requestContent.videoData).to.have.property('videoProtocol').and.to.equal(8); + expect(requestContent.videoData).to.have.property('adBreak').and.to.equal(1); + }); + + it('Verify videoData default values assigned', function () { + config.setConfig({ + 'currency': { + 'adServerCurrency': 'EUR' + } + }); + const request = spec.buildRequests([{ + adUnitCode: 'sas_42', + bidId: 'abcd1234', + bidder: 'smartadserver', + mediaTypes: { + video: { + context: 'instream', + playerSize: [[640, 480]] // It seems prebid.js transforms the player size array into an array of array... + } + }, + params: { + siteId: '1234', + pageId: '5678', + formatId: '90', + target: 'test=prebid', + bidfloor: 0.420, + buId: '7569', + appName: 'Mozilla', + ckId: 42, + }, + requestId: 'efgh5678', + transactionId: 'zsfgzzg' + }]); + + expect(request[0]).to.have.property('url').and.to.equal('https://prg.smartadserver.com/prebid/v1'); + expect(request[0]).to.have.property('method').and.to.equal('POST'); + const requestContent = JSON.parse(request[0].data); + expect(requestContent).to.have.property('videoData'); + expect(requestContent.videoData).to.have.property('videoProtocol').and.to.equal(null); + expect(requestContent.videoData).to.have.property('adBreak').and.to.equal(2); + }); + + it('Verify videoData params override meta values', function () { + config.setConfig({ + 'currency': { + 'adServerCurrency': 'EUR' + } + }); + const request = spec.buildRequests([{ + adUnitCode: 'sas_42', + bidId: 'abcd1234', + bidder: 'smartadserver', + mediaTypes: { + video: { + context: 'instream', + playerSize: [[640, 480]], // It seems prebid.js transforms the player size array into an array of array... + protocols: [8, 2], + startdelay: 0 + } + }, + params: { + siteId: '1234', + pageId: '5678', + formatId: '90', + target: 'test=prebid', + bidfloor: 0.420, + buId: '7569', + appName: 'Mozilla', + ckId: 42, + video: { + protocol: 6, + startDelay: 3 + } + }, + requestId: 'efgh5678', + transactionId: 'zsfgzzg' + }]); + + expect(request[0]).to.have.property('url').and.to.equal('https://prg.smartadserver.com/prebid/v1'); + expect(request[0]).to.have.property('method').and.to.equal('POST'); + const requestContent = JSON.parse(request[0].data); + expect(requestContent).to.have.property('videoData'); + expect(requestContent.videoData).to.have.property('videoProtocol').and.to.equal(6); + expect(requestContent.videoData).to.have.property('adBreak').and.to.equal(3); + }); }); describe('Outstream video tests', function () { From 0bcfe66ed76f7135c780342c435774ccec861740 Mon Sep 17 00:00:00 2001 From: Llywelyn OWEN Date: Mon, 7 Jun 2021 14:24:33 +0200 Subject: [PATCH 13/14] added outstream test --- .../modules/smartadserverBidAdapter_spec.js | 344 ++++++++++++------ 1 file changed, 235 insertions(+), 109 deletions(-) diff --git a/test/spec/modules/smartadserverBidAdapter_spec.js b/test/spec/modules/smartadserverBidAdapter_spec.js index 9c2adf10b06..27d856dd7df 100644 --- a/test/spec/modules/smartadserverBidAdapter_spec.js +++ b/test/spec/modules/smartadserverBidAdapter_spec.js @@ -540,6 +540,235 @@ describe('Smart bid adapter tests', function () { expect(request[1]).to.not.be.empty; }); + describe('Instream videoData meta & params tests', function () { + it('Verify videoData assigns values from meta', function () { + config.setConfig({ + 'currency': { + 'adServerCurrency': 'EUR' + } + }); + const request = spec.buildRequests([{ + adUnitCode: 'sas_42', + bidId: 'abcd1234', + bidder: 'smartadserver', + mediaTypes: { + video: { + context: 'instream', + playerSize: [[640, 480]], // It seems prebid.js transforms the player size array into an array of array... + protocols: [8, 2], + startdelay: 0 + } + }, + params: { + siteId: '1234', + pageId: '5678', + formatId: '90', + target: 'test=prebid', + bidfloor: 0.420, + buId: '7569', + appName: 'Mozilla', + ckId: 42, + }, + requestId: 'efgh5678', + transactionId: 'zsfgzzg' + }]); + + expect(request[0]).to.have.property('url').and.to.equal('https://prg.smartadserver.com/prebid/v1'); + expect(request[0]).to.have.property('method').and.to.equal('POST'); + const requestContent = JSON.parse(request[0].data); + expect(requestContent).to.have.property('videoData'); + expect(requestContent.videoData).to.have.property('videoProtocol').and.to.equal(8); + expect(requestContent.videoData).to.have.property('adBreak').and.to.equal(1); + }); + + it('Verify videoData default values assigned', function () { + config.setConfig({ + 'currency': { + 'adServerCurrency': 'EUR' + } + }); + const request = spec.buildRequests([{ + adUnitCode: 'sas_42', + bidId: 'abcd1234', + bidder: 'smartadserver', + mediaTypes: { + video: { + context: 'instream', + playerSize: [[640, 480]] // It seems prebid.js transforms the player size array into an array of array... + } + }, + params: { + siteId: '1234', + pageId: '5678', + formatId: '90', + target: 'test=prebid', + bidfloor: 0.420, + buId: '7569', + appName: 'Mozilla', + ckId: 42, + }, + requestId: 'efgh5678', + transactionId: 'zsfgzzg' + }]); + + expect(request[0]).to.have.property('url').and.to.equal('https://prg.smartadserver.com/prebid/v1'); + expect(request[0]).to.have.property('method').and.to.equal('POST'); + const requestContent = JSON.parse(request[0].data); + expect(requestContent).to.have.property('videoData'); + expect(requestContent.videoData).to.have.property('videoProtocol').and.to.equal(null); + expect(requestContent.videoData).to.have.property('adBreak').and.to.equal(2); + }); + + it('Verify videoData params override meta values', function () { + config.setConfig({ + 'currency': { + 'adServerCurrency': 'EUR' + } + }); + const request = spec.buildRequests([{ + adUnitCode: 'sas_42', + bidId: 'abcd1234', + bidder: 'smartadserver', + mediaTypes: { + video: { + context: 'instream', + playerSize: [[640, 480]], // It seems prebid.js transforms the player size array into an array of array... + protocols: [8, 2], + startdelay: 0 + } + }, + params: { + siteId: '1234', + pageId: '5678', + formatId: '90', + target: 'test=prebid', + bidfloor: 0.420, + buId: '7569', + appName: 'Mozilla', + ckId: 42, + video: { + protocol: 6, + startDelay: 3 + } + }, + requestId: 'efgh5678', + transactionId: 'zsfgzzg' + }]); + + expect(request[0]).to.have.property('url').and.to.equal('https://prg.smartadserver.com/prebid/v1'); + expect(request[0]).to.have.property('method').and.to.equal('POST'); + const requestContent = JSON.parse(request[0].data); + expect(requestContent).to.have.property('videoData'); + expect(requestContent.videoData).to.have.property('videoProtocol').and.to.equal(6); + expect(requestContent.videoData).to.have.property('adBreak').and.to.equal(3); + }); + }); + }); + + describe('Outstream video tests', function () { + afterEach(function () { + config.resetConfig(); + $$PREBID_GLOBAL$$.requestBids.removeAll(); + }); + + const OUTSTREAM_DEFAULT_PARAMS = [{ + adUnitCode: 'sas_43', + bidId: 'abcd1234', + bidder: 'smartadserver', + mediaTypes: { + video: { + context: 'outstream', + playerSize: [[800, 600]] // It seems prebid.js transforms the player size array into an array of array... + } + }, + params: { + siteId: '1234', + pageId: '5678', + formatId: '91', + target: 'test=prebid-outstream', + bidfloor: 0.430, + buId: '7579', + appName: 'Mozilla', + ckId: 43, + video: { + protocol: 7 + } + }, + requestId: 'efgh5679', + transactionId: 'zsfgzzga' + }]; + + var OUTSTREAM_BID_RESPONSE = { + body: { + cpm: 14, + width: 800, + height: 600, + creativeId: 'zioeufga', + currency: 'USD', + isNetCpm: true, + ttl: 300, + adUrl: 'http://awesome.fake-vast2.url', + ad: '', + cSyncUrl: 'http://awesome.fake2.csync.url' + } + }; + + it('Verify outstream video build request', function () { + config.setConfig({ + 'currency': { + 'adServerCurrency': 'EUR' + } + }); + const request = spec.buildRequests(OUTSTREAM_DEFAULT_PARAMS); + expect(request[0]).to.have.property('url').and.to.equal('https://prg.smartadserver.com/prebid/v1'); + expect(request[0]).to.have.property('method').and.to.equal('POST'); + const requestContent = JSON.parse(request[0].data); + expect(requestContent).to.have.property('siteid').and.to.equal('1234'); + expect(requestContent).to.have.property('pageid').and.to.equal('5678'); + expect(requestContent).to.have.property('formatid').and.to.equal('91'); + expect(requestContent).to.have.property('currencyCode').and.to.equal('EUR'); + expect(requestContent).to.have.property('bidfloor').and.to.equal(0.43); + expect(requestContent).to.have.property('targeting').and.to.equal('test=prebid-outstream'); + expect(requestContent).to.have.property('tagId').and.to.equal('sas_43'); + expect(requestContent).to.not.have.property('pageDomain'); + expect(requestContent).to.have.property('transactionId').and.to.not.equal(null).and.to.not.be.undefined; + expect(requestContent).to.have.property('buid').and.to.equal('7579'); + expect(requestContent).to.have.property('appname').and.to.equal('Mozilla'); + expect(requestContent).to.have.property('ckid').and.to.equal(43); + expect(requestContent).to.have.property('isVideo').and.to.equal(false); + expect(requestContent).to.have.property('videoData'); + expect(requestContent.videoData).to.have.property('videoProtocol').and.to.equal(7); + expect(requestContent.videoData).to.have.property('playerWidth').and.to.equal(800); + expect(requestContent.videoData).to.have.property('playerHeight').and.to.equal(600); + }); + + it('Verify outstream parse response', function () { + const request = spec.buildRequests(OUTSTREAM_DEFAULT_PARAMS); + const bids = spec.interpretResponse(OUTSTREAM_BID_RESPONSE, request[0]); + expect(bids).to.have.lengthOf(1); + const bid = bids[0]; + expect(bid.cpm).to.equal(14); + expect(bid.mediaType).to.equal('video'); + expect(bid.vastUrl).to.equal('http://awesome.fake-vast2.url'); + expect(bid.vastXml).to.equal(''); + expect(bid.content).to.equal(''); + expect(bid.width).to.equal(800); + expect(bid.height).to.equal(600); + expect(bid.creativeId).to.equal('zioeufga'); + expect(bid.currency).to.equal('USD'); + expect(bid.netRevenue).to.equal(true); + expect(bid.ttl).to.equal(300); + expect(bid.requestId).to.equal(OUTSTREAM_DEFAULT_PARAMS[0].bidId); + + expect(function () { + spec.interpretResponse(OUTSTREAM_BID_RESPONSE, { + data: 'invalid Json' + }) + }).to.not.throw(); + }); + }); + + describe('Outstream videoData meta & params tests', function () { it('Verify videoData assigns values from meta', function () { config.setConfig({ 'currency': { @@ -552,7 +781,7 @@ describe('Smart bid adapter tests', function () { bidder: 'smartadserver', mediaTypes: { video: { - context: 'instream', + context: 'outstream', playerSize: [[640, 480]], // It seems prebid.js transforms the player size array into an array of array... protocols: [8, 2], startdelay: 0 @@ -562,7 +791,7 @@ describe('Smart bid adapter tests', function () { siteId: '1234', pageId: '5678', formatId: '90', - target: 'test=prebid', + target: 'test=prebid-outstream', bidfloor: 0.420, buId: '7569', appName: 'Mozilla', @@ -592,7 +821,7 @@ describe('Smart bid adapter tests', function () { bidder: 'smartadserver', mediaTypes: { video: { - context: 'instream', + context: 'outstream', playerSize: [[640, 480]] // It seems prebid.js transforms the player size array into an array of array... } }, @@ -600,7 +829,7 @@ describe('Smart bid adapter tests', function () { siteId: '1234', pageId: '5678', formatId: '90', - target: 'test=prebid', + target: 'test=prebid-outstream', bidfloor: 0.420, buId: '7569', appName: 'Mozilla', @@ -630,7 +859,7 @@ describe('Smart bid adapter tests', function () { bidder: 'smartadserver', mediaTypes: { video: { - context: 'instream', + context: 'outstream', playerSize: [[640, 480]], // It seems prebid.js transforms the player size array into an array of array... protocols: [8, 2], startdelay: 0 @@ -640,7 +869,7 @@ describe('Smart bid adapter tests', function () { siteId: '1234', pageId: '5678', formatId: '90', - target: 'test=prebid', + target: 'test=prebid-outstream', bidfloor: 0.420, buId: '7569', appName: 'Mozilla', @@ -663,109 +892,6 @@ describe('Smart bid adapter tests', function () { }); }); - describe('Outstream video tests', function () { - afterEach(function () { - config.resetConfig(); - $$PREBID_GLOBAL$$.requestBids.removeAll(); - }); - - const OUTSTREAM_DEFAULT_PARAMS = [{ - adUnitCode: 'sas_43', - bidId: 'abcd1234', - bidder: 'smartadserver', - mediaTypes: { - video: { - context: 'outstream', - playerSize: [[800, 600]] // It seems prebid.js transforms the player size array into an array of array... - } - }, - params: { - siteId: '1234', - pageId: '5678', - formatId: '91', - target: 'test=prebid-outstream', - bidfloor: 0.430, - buId: '7579', - appName: 'Mozilla', - ckId: 43, - video: { - protocol: 7 - } - }, - requestId: 'efgh5679', - transactionId: 'zsfgzzga' - }]; - - var OUTSTREAM_BID_RESPONSE = { - body: { - cpm: 14, - width: 800, - height: 600, - creativeId: 'zioeufga', - currency: 'USD', - isNetCpm: true, - ttl: 300, - adUrl: 'http://awesome.fake-vast2.url', - ad: '', - cSyncUrl: 'http://awesome.fake2.csync.url' - } - }; - - it('Verify outstream video build request', function () { - config.setConfig({ - 'currency': { - 'adServerCurrency': 'EUR' - } - }); - const request = spec.buildRequests(OUTSTREAM_DEFAULT_PARAMS); - expect(request[0]).to.have.property('url').and.to.equal('https://prg.smartadserver.com/prebid/v1'); - expect(request[0]).to.have.property('method').and.to.equal('POST'); - const requestContent = JSON.parse(request[0].data); - expect(requestContent).to.have.property('siteid').and.to.equal('1234'); - expect(requestContent).to.have.property('pageid').and.to.equal('5678'); - expect(requestContent).to.have.property('formatid').and.to.equal('91'); - expect(requestContent).to.have.property('currencyCode').and.to.equal('EUR'); - expect(requestContent).to.have.property('bidfloor').and.to.equal(0.43); - expect(requestContent).to.have.property('targeting').and.to.equal('test=prebid-outstream'); - expect(requestContent).to.have.property('tagId').and.to.equal('sas_43'); - expect(requestContent).to.not.have.property('pageDomain'); - expect(requestContent).to.have.property('transactionId').and.to.not.equal(null).and.to.not.be.undefined; - expect(requestContent).to.have.property('buid').and.to.equal('7579'); - expect(requestContent).to.have.property('appname').and.to.equal('Mozilla'); - expect(requestContent).to.have.property('ckid').and.to.equal(43); - expect(requestContent).to.have.property('isVideo').and.to.equal(false); - expect(requestContent).to.have.property('videoData'); - expect(requestContent.videoData).to.have.property('videoProtocol').and.to.equal(7); - expect(requestContent.videoData).to.have.property('playerWidth').and.to.equal(800); - expect(requestContent.videoData).to.have.property('playerHeight').and.to.equal(600); - }); - - it('Verify outstream parse response', function () { - const request = spec.buildRequests(OUTSTREAM_DEFAULT_PARAMS); - const bids = spec.interpretResponse(OUTSTREAM_BID_RESPONSE, request[0]); - expect(bids).to.have.lengthOf(1); - const bid = bids[0]; - expect(bid.cpm).to.equal(14); - expect(bid.mediaType).to.equal('video'); - expect(bid.vastUrl).to.equal('http://awesome.fake-vast2.url'); - expect(bid.vastXml).to.equal(''); - expect(bid.content).to.equal(''); - expect(bid.width).to.equal(800); - expect(bid.height).to.equal(600); - expect(bid.creativeId).to.equal('zioeufga'); - expect(bid.currency).to.equal('USD'); - expect(bid.netRevenue).to.equal(true); - expect(bid.ttl).to.equal(300); - expect(bid.requestId).to.equal(OUTSTREAM_DEFAULT_PARAMS[0].bidId); - - expect(function () { - spec.interpretResponse(OUTSTREAM_BID_RESPONSE, { - data: 'invalid Json' - }) - }).to.not.throw(); - }); - }); - describe('External ids tests', function () { it('Verify external ids in request and ids found', function () { config.setConfig({ From b35ebd276afbd0041439f145db2cb0df87bb5e3c Mon Sep 17 00:00:00 2001 From: Llywelyn OWEN Date: Mon, 7 Jun 2021 14:29:54 +0200 Subject: [PATCH 14/14] removing minor extra character --- test/spec/modules/smartadserverBidAdapter_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/modules/smartadserverBidAdapter_spec.js b/test/spec/modules/smartadserverBidAdapter_spec.js index 27d856dd7df..f9206740535 100644 --- a/test/spec/modules/smartadserverBidAdapter_spec.js +++ b/test/spec/modules/smartadserverBidAdapter_spec.js @@ -432,7 +432,7 @@ describe('Smart bid adapter tests', function () { appName: 'Mozilla', ckId: 42, video: { - protocol: 6, + protocol: 6 } }, requestId: 'efgh5678',