From 2f8a35c9371bebab85c6b7a0837f9c33536b28fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?El=C5=BCbieta=20SZPONDER?= Date: Mon, 19 Aug 2024 14:00:29 +0200 Subject: [PATCH 01/33] add support of dsa --- modules/smartadserverBidAdapter.js | 27 ++++++-- .../modules/smartadserverBidAdapter_spec.js | 61 +++++++++++++++++-- 2 files changed, 77 insertions(+), 11 deletions(-) diff --git a/modules/smartadserverBidAdapter.js b/modules/smartadserverBidAdapter.js index a90f99da2f7..10a31cb8903 100644 --- a/modules/smartadserverBidAdapter.js +++ b/modules/smartadserverBidAdapter.js @@ -1,4 +1,14 @@ -import { deepAccess, deepClone, isArrayOfNums, isFn, isInteger, isPlainObject, logError } from '../src/utils.js'; +import { + deepAccess, + deepClone, + isArray, + isArrayOfNums, + isEmpty, + isFn, + isInteger, + isPlainObject, + logError +} from '../src/utils.js'; import { BANNER, VIDEO } from '../src/mediaTypes.js'; import { config } from '../src/config.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; @@ -156,9 +166,6 @@ export const spec = { method: 'POST', url: (domain !== undefined ? domain : 'https://prg.smartadserver.com') + '/prebid/v1', data: JSON.stringify(payload), - options: { - browsingTopics: false - } }; }, @@ -199,11 +206,16 @@ export const spec = { sdc: sellerDefinedContext }; - const gpid = deepAccess(bid, 'ortb2Imp.ext.gpid') || deepAccess(bid, 'ortb2Imp.ext.data.pbadslot'); + const gpid = deepAccess(bid, 'ortb2Imp.ext.gpid', deepAccess(bid, 'ortb2Imp.ext.data.pbadslot', '')); if (gpid) { payload.gpid = gpid; } + const dsa = deepAccess(bid, 'ortb2.regs.ext.dsa'); + if (dsa) { + payload.dsa = dsa; + } + if (bidderRequest) { if (bidderRequest.gdprConsent) { payload.addtl_consent = bidderRequest.gdprConsent.addtlConsent; @@ -285,7 +297,10 @@ export const spec = { netRevenue: response.isNetCpm, ttl: response.ttl, dspPixels: response.dspPixels, - meta: { advertiserDomains: response.adomain ? response.adomain : [] } + meta: { + ...isArray(response.adomain) && !isEmpty(response.adomain) ? { advertiserDomains: response.adomain } : {}, + ...!isEmpty(response.dsa) ? { dsa: response.dsa } : {} + } }; if (bidRequest.mediaType === VIDEO) { diff --git a/test/spec/modules/smartadserverBidAdapter_spec.js b/test/spec/modules/smartadserverBidAdapter_spec.js index 2f06331f616..f5f9751dba8 100644 --- a/test/spec/modules/smartadserverBidAdapter_spec.js +++ b/test/spec/modules/smartadserverBidAdapter_spec.js @@ -458,11 +458,30 @@ describe('Smart bid adapter tests', function () { expect(syncs).to.have.lengthOf(0); }); - it('should set browsingTopics=false in request.options', () => { - const requests = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL); - expect(requests[0]).to.have.property('options').and.to.deep.equal({ - browsingTopics: false - }); + it('Verify metadata', function () { + const adomain = ['advertiser-domain.com']; + const dsa = { + dsarequired: 1, + pubrender: 0, + datatopub: 1, + transparency: [{ + domain: 'smartadserver.com', + dsaparams: [1, 2] + }] + }; + const request = spec.buildRequests(DEFAULT_PARAMS); + const bids = spec.interpretResponse({ + body: { + ...BID_RESPONSE.body, + adomain, + dsa, + } + }, request[0]); + + expect(bids[0].cpm).to.equal(12); + expect(bids[0]).to.have.property('meta'); + expect(bids[0].meta).to.have.property('advertiserDomains').and.to.deep.equal(adomain); + expect(bids[0].meta).to.have.property('dsa').and.to.deep.equal(dsa); }); describe('gdpr tests', function () { @@ -1512,6 +1531,38 @@ describe('Smart bid adapter tests', function () { }); }); + describe('Digital Services Act (DSA)', function () { + it('should include dsa if ortb2.regs.ext.dsa available', function () { + const dsa = { + dsarequired: 1, + pubrender: 0, + datatopub: 1, + transparency: [ + { + domain: 'ok.domain.com', + dsaparams: [1, 2] + }, + { + domain: 'ko.domain.com', + dsaparams: [1, '3'] + } + ] + }; + + const bidRequests = deepClone(DEFAULT_PARAMS_WO_OPTIONAL); + bidRequests[0].ortb2 = { + regs: { + ext: { dsa } + } + }; + + const request = spec.buildRequests(bidRequests); + const requestContent = JSON.parse(request[0].data); + + expect(requestContent).to.have.property('dsa').and.to.deep.equal(dsa); + }); + }); + describe('#getValuableProperty method', function () { it('should return an object when calling with a number value', () => { const obj = spec.getValuableProperty('prop', 3); From 9483a8123371222193ca414ed3021f7cb7b33468 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?El=C5=BCbieta=20SZPONDER?= Date: Mon, 19 Aug 2024 14:19:03 +0200 Subject: [PATCH 02/33] restore topics --- modules/smartadserverBidAdapter.js | 5 ++++- test/spec/modules/smartadserverBidAdapter_spec.js | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/smartadserverBidAdapter.js b/modules/smartadserverBidAdapter.js index 10a31cb8903..840ba8a82aa 100644 --- a/modules/smartadserverBidAdapter.js +++ b/modules/smartadserverBidAdapter.js @@ -166,6 +166,9 @@ export const spec = { method: 'POST', url: (domain !== undefined ? domain : 'https://prg.smartadserver.com') + '/prebid/v1', data: JSON.stringify(payload), + options: { + browsingTopics: false + } }; }, @@ -206,7 +209,7 @@ export const spec = { sdc: sellerDefinedContext }; - const gpid = deepAccess(bid, 'ortb2Imp.ext.gpid', deepAccess(bid, 'ortb2Imp.ext.data.pbadslot', '')); + const gpid = deepAccess(bid, 'ortb2Imp.ext.gpid') || deepAccess(bid, 'ortb2Imp.ext.data.pbadslot'); if (gpid) { payload.gpid = gpid; } diff --git a/test/spec/modules/smartadserverBidAdapter_spec.js b/test/spec/modules/smartadserverBidAdapter_spec.js index f5f9751dba8..fa7993f768b 100644 --- a/test/spec/modules/smartadserverBidAdapter_spec.js +++ b/test/spec/modules/smartadserverBidAdapter_spec.js @@ -458,6 +458,12 @@ describe('Smart bid adapter tests', function () { expect(syncs).to.have.lengthOf(0); }); + it('should set browsingTopics=false in request.options', () => { + const requests = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL); + expect(requests[0]).to.have.property('options').and.to.deep.equal({ + browsingTopics: false + }); + it('Verify metadata', function () { const adomain = ['advertiser-domain.com']; const dsa = { From 6acff45ab7732c493ef9a97985e16287da46ca8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?El=C5=BCbieta=20SZPONDER?= Date: Tue, 20 Aug 2024 10:13:57 +0200 Subject: [PATCH 03/33] DSA fix for UT --- test/spec/modules/smartadserverBidAdapter_spec.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/spec/modules/smartadserverBidAdapter_spec.js b/test/spec/modules/smartadserverBidAdapter_spec.js index fa7993f768b..08b9f616551 100644 --- a/test/spec/modules/smartadserverBidAdapter_spec.js +++ b/test/spec/modules/smartadserverBidAdapter_spec.js @@ -462,6 +462,7 @@ describe('Smart bid adapter tests', function () { const requests = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL); expect(requests[0]).to.have.property('options').and.to.deep.equal({ browsingTopics: false + }); }); it('Verify metadata', function () { From d5a31781032e3d4face9598f3464f8323f290569 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Sok=C3=B3=C5=82?= Date: Wed, 11 Sep 2024 12:00:25 +0200 Subject: [PATCH 04/33] drafy of adapter --- modules/equativBidAdapter.js | 113 +++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 modules/equativBidAdapter.js diff --git a/modules/equativBidAdapter.js b/modules/equativBidAdapter.js new file mode 100644 index 00000000000..3330b78d62f --- /dev/null +++ b/modules/equativBidAdapter.js @@ -0,0 +1,113 @@ +import {BANNER} from '../src/mediaTypes.js'; +import {ortbConverter} from '../libraries/ortbConverter/converter.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {deepAccess, deepSetValue, mergeDeep} from '../src/utils.js'; + +/** + * @typedef {import('../src/adapters/bidderFactory.js').Bid} Bid + * @typedef {import('../src/adapters/bidderFactory.js').ServerRequest} ServerRequest + */ + +registerBidder({ + code: 'equativ', + gvlid: 45, + supportedMediaTypes: [BANNER], + + /** + * @param bidRequests + * @param bidderRequest + * @returns {ServerRequest[]} + */ + buildRequests: (bidRequests, bidderRequest) => { + return { + data: converter.toORTB({bidderRequest, bidRequests}), + method: 'POST', + // url: 'https://ssb-global.smartadserver.com/api/bid?callerId=169' + url: 'https://feature-ssb-engine-pips-2655-testenv.internal.smartadserver.com/api/bid?callerId=169' + }; + }, + + /** + * @param serverResponse + * @param bidRequest + * @return {Bid[]} + */ + interpretResponse: (serverResponse, bidRequest) => converter.fromORTB({request: bidRequest.data, response: serverResponse.body}), + + /** + * @param bidRequest + * @return {boolean} + */ + isBidRequestValid: (bidRequest) => { + return !(!bidRequest.params.networkId && + !deepAccess(bidRequest, 'ortb2Imp.site.publisher.id') && + !deepAccess(bidRequest, 'ortb2Imp.app.publisher.id') && + !deepAccess(bidRequest, 'ortb2Imp.dooh.publisher.id')); + }, + + /** + * @param syncOptions + * @param serverResponses + * @return {{type: (string), url: (*|string)}[]} + */ + getUserSyncs: (syncOptions, serverResponses) => { + if (syncOptions.iframeEnabled && serverResponses[0]?.body.cSyncUrl) { + return { + type: 'iframe', + url: serverResponses[0].body.cSyncUrl + }; + } else if (syncOptions.pixelEnabled && serverResponses[0]?.body.dspPixels) { + serverResponses[0].body.dspPixels.forEach((pixel) => { + return { + type: 'image', + url: pixel + }; + }); + } + } +}); + +const converter = ortbConverter({ + context: { + netRevenue: true, + ttl: 300 + }, + + imp(buildImp, bidRequest, context) { + const imp = buildImp(bidRequest, context); + const { siteId, pageId, formatId } = bidRequest.params; + + if (siteId || pageId || formatId) { + const bidder = {}; + + if (siteId) { + bidder.siteId = siteId; + } + + if (pageId) { + bidder.pageId = pageId; + } + + if (formatId) { + bidder.formatId = formatId; + } + + mergeDeep(imp, { + ext: { bidder } + }); + } + + return imp; + }, + + request(buildRequest, imps, bidderRequest, context) { + const bid = context.bidRequests[0]; + const req = buildRequest(imps, bidderRequest, context); + + if (bid.params.networkId) { + deepSetValue(req, 'site.publisher.id', bid.params.networkId); + } + + return req; + } +}); From 92091d401f1ce0ab4f134707fbcc4989f7cdfb89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Sok=C3=B3=C5=82?= Date: Thu, 12 Sep 2024 13:33:20 +0200 Subject: [PATCH 05/33] fixes after dev test --- modules/equativBidAdapter.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/modules/equativBidAdapter.js b/modules/equativBidAdapter.js index 3330b78d62f..f0f48b7eb1c 100644 --- a/modules/equativBidAdapter.js +++ b/modules/equativBidAdapter.js @@ -39,10 +39,10 @@ registerBidder({ * @return {boolean} */ isBidRequestValid: (bidRequest) => { - return !(!bidRequest.params.networkId && - !deepAccess(bidRequest, 'ortb2Imp.site.publisher.id') && - !deepAccess(bidRequest, 'ortb2Imp.app.publisher.id') && - !deepAccess(bidRequest, 'ortb2Imp.dooh.publisher.id')); + return bidRequest.params.networkId || + deepAccess(bidRequest, 'ortb2Imp.site.publisher.id') || + deepAccess(bidRequest, 'ortb2Imp.app.publisher.id') || + deepAccess(bidRequest, 'ortb2Imp.dooh.publisher.id'); }, /** @@ -52,17 +52,19 @@ registerBidder({ */ getUserSyncs: (syncOptions, serverResponses) => { if (syncOptions.iframeEnabled && serverResponses[0]?.body.cSyncUrl) { - return { + return [{ type: 'iframe', url: serverResponses[0].body.cSyncUrl - }; + }]; } else if (syncOptions.pixelEnabled && serverResponses[0]?.body.dspPixels) { + const syncs = []; serverResponses[0].body.dspPixels.forEach((pixel) => { - return { + syncs.push({ type: 'image', url: pixel - }; + }); }); + return syncs; } } }); From 23eac335ff99da9a8f8ce2463a6cd4be569e9474 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Sok=C3=B3=C5=82?= Date: Thu, 12 Sep 2024 14:39:47 +0200 Subject: [PATCH 06/33] make world simpler --- modules/equativBidAdapter.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/modules/equativBidAdapter.js b/modules/equativBidAdapter.js index f0f48b7eb1c..55e13fb9862 100644 --- a/modules/equativBidAdapter.js +++ b/modules/equativBidAdapter.js @@ -57,14 +57,10 @@ registerBidder({ url: serverResponses[0].body.cSyncUrl }]; } else if (syncOptions.pixelEnabled && serverResponses[0]?.body.dspPixels) { - const syncs = []; - serverResponses[0].body.dspPixels.forEach((pixel) => { - syncs.push({ - type: 'image', - url: pixel - }); - }); - return syncs; + return serverResponses[0].body.dspPixels.forEach((pixel) => ({ + type: 'image', + url: pixel + })); } } }); From 3a5eda0a5127e46f159d55efff599146a659162a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Sok=C3=B3=C5=82?= Date: Thu, 12 Sep 2024 14:45:20 +0200 Subject: [PATCH 07/33] fix prev commit --- modules/equativBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/equativBidAdapter.js b/modules/equativBidAdapter.js index 55e13fb9862..a19f026786a 100644 --- a/modules/equativBidAdapter.js +++ b/modules/equativBidAdapter.js @@ -57,7 +57,7 @@ registerBidder({ url: serverResponses[0].body.cSyncUrl }]; } else if (syncOptions.pixelEnabled && serverResponses[0]?.body.dspPixels) { - return serverResponses[0].body.dspPixels.forEach((pixel) => ({ + return serverResponses[0].body.dspPixels.map((pixel) => ({ type: 'image', url: pixel })); From 86a7845161c4d1544ff4a2fa6ce6dae25d9b6497 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Sok=C3=B3=C5=82?= Date: Thu, 12 Sep 2024 14:56:06 +0200 Subject: [PATCH 08/33] return empty userSyncs array by default --- modules/equativBidAdapter.js | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/equativBidAdapter.js b/modules/equativBidAdapter.js index a19f026786a..6261b8fe416 100644 --- a/modules/equativBidAdapter.js +++ b/modules/equativBidAdapter.js @@ -62,6 +62,7 @@ registerBidder({ url: pixel })); } + return []; } }); From 52752e7772e5c530c74681e338c05667014c56ba Mon Sep 17 00:00:00 2001 From: janzych-smart Date: Mon, 16 Sep 2024 13:44:52 +0200 Subject: [PATCH 09/33] adjustments --- modules/equativBidAdapter.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/modules/equativBidAdapter.js b/modules/equativBidAdapter.js index 6261b8fe416..5b012f60678 100644 --- a/modules/equativBidAdapter.js +++ b/modules/equativBidAdapter.js @@ -8,7 +8,7 @@ import {deepAccess, deepSetValue, mergeDeep} from '../src/utils.js'; * @typedef {import('../src/adapters/bidderFactory.js').ServerRequest} ServerRequest */ -registerBidder({ +export const spec = { code: 'equativ', gvlid: 45, supportedMediaTypes: [BANNER], @@ -39,10 +39,10 @@ registerBidder({ * @return {boolean} */ isBidRequestValid: (bidRequest) => { - return bidRequest.params.networkId || + return !!(deepAccess(bidRequest, 'params.networkId') || deepAccess(bidRequest, 'ortb2Imp.site.publisher.id') || deepAccess(bidRequest, 'ortb2Imp.app.publisher.id') || - deepAccess(bidRequest, 'ortb2Imp.dooh.publisher.id'); + deepAccess(bidRequest, 'ortb2Imp.dooh.publisher.id')); }, /** @@ -64,9 +64,9 @@ registerBidder({ } return []; } -}); +}; -const converter = ortbConverter({ +export const converter = ortbConverter({ context: { netRevenue: true, ttl: 300 @@ -110,3 +110,5 @@ const converter = ortbConverter({ return req; } }); + +registerBidder(spec); From b75a5c2a6b45b8c8ff00835e10fcc97f02ee1c8b Mon Sep 17 00:00:00 2001 From: janzych-smart Date: Mon, 16 Sep 2024 13:45:29 +0200 Subject: [PATCH 10/33] apply prettier --- modules/equativBidAdapter.js | 44 +++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/modules/equativBidAdapter.js b/modules/equativBidAdapter.js index 5b012f60678..7230214cdf4 100644 --- a/modules/equativBidAdapter.js +++ b/modules/equativBidAdapter.js @@ -1,7 +1,7 @@ -import {BANNER} from '../src/mediaTypes.js'; -import {ortbConverter} from '../libraries/ortbConverter/converter.js'; -import {registerBidder} from '../src/adapters/bidderFactory.js'; -import {deepAccess, deepSetValue, mergeDeep} from '../src/utils.js'; +import { BANNER } from '../src/mediaTypes.js'; +import { ortbConverter } from '../libraries/ortbConverter/converter.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { deepAccess, deepSetValue, mergeDeep } from '../src/utils.js'; /** * @typedef {import('../src/adapters/bidderFactory.js').Bid} Bid @@ -20,10 +20,10 @@ export const spec = { */ buildRequests: (bidRequests, bidderRequest) => { return { - data: converter.toORTB({bidderRequest, bidRequests}), + data: converter.toORTB({ bidderRequest, bidRequests }), method: 'POST', // url: 'https://ssb-global.smartadserver.com/api/bid?callerId=169' - url: 'https://feature-ssb-engine-pips-2655-testenv.internal.smartadserver.com/api/bid?callerId=169' + url: 'https://feature-ssb-engine-pips-2655-testenv.internal.smartadserver.com/api/bid?callerId=169', }; }, @@ -32,17 +32,23 @@ export const spec = { * @param bidRequest * @return {Bid[]} */ - interpretResponse: (serverResponse, bidRequest) => converter.fromORTB({request: bidRequest.data, response: serverResponse.body}), + interpretResponse: (serverResponse, bidRequest) => + converter.fromORTB({ + request: bidRequest.data, + response: serverResponse.body, + }), /** * @param bidRequest * @return {boolean} */ isBidRequestValid: (bidRequest) => { - return !!(deepAccess(bidRequest, 'params.networkId') || + return !!( + deepAccess(bidRequest, 'params.networkId') || deepAccess(bidRequest, 'ortb2Imp.site.publisher.id') || deepAccess(bidRequest, 'ortb2Imp.app.publisher.id') || - deepAccess(bidRequest, 'ortb2Imp.dooh.publisher.id')); + deepAccess(bidRequest, 'ortb2Imp.dooh.publisher.id') + ); }, /** @@ -52,24 +58,26 @@ export const spec = { */ getUserSyncs: (syncOptions, serverResponses) => { if (syncOptions.iframeEnabled && serverResponses[0]?.body.cSyncUrl) { - return [{ - type: 'iframe', - url: serverResponses[0].body.cSyncUrl - }]; + return [ + { + type: 'iframe', + url: serverResponses[0].body.cSyncUrl, + }, + ]; } else if (syncOptions.pixelEnabled && serverResponses[0]?.body.dspPixels) { return serverResponses[0].body.dspPixels.map((pixel) => ({ type: 'image', - url: pixel + url: pixel, })); } return []; - } + }, }; export const converter = ortbConverter({ context: { netRevenue: true, - ttl: 300 + ttl: 300, }, imp(buildImp, bidRequest, context) { @@ -92,7 +100,7 @@ export const converter = ortbConverter({ } mergeDeep(imp, { - ext: { bidder } + ext: { bidder }, }); } @@ -108,7 +116,7 @@ export const converter = ortbConverter({ } return req; - } + }, }); registerBidder(spec); From 9ec6fe4d1480178c0304e9431e8989849b898015 Mon Sep 17 00:00:00 2001 From: janzych-smart Date: Tue, 17 Sep 2024 15:45:14 +0200 Subject: [PATCH 11/33] unit tests for Equativ adapter --- modules/equativBidAdapter.js | 32 ++-- test/spec/modules/equativBidAdapter_spec.js | 202 ++++++++++++++++++++ 2 files changed, 218 insertions(+), 16 deletions(-) create mode 100644 test/spec/modules/equativBidAdapter_spec.js diff --git a/modules/equativBidAdapter.js b/modules/equativBidAdapter.js index 7230214cdf4..600bf498580 100644 --- a/modules/equativBidAdapter.js +++ b/modules/equativBidAdapter.js @@ -56,22 +56,22 @@ export const spec = { * @param serverResponses * @return {{type: (string), url: (*|string)}[]} */ - getUserSyncs: (syncOptions, serverResponses) => { - if (syncOptions.iframeEnabled && serverResponses[0]?.body.cSyncUrl) { - return [ - { - type: 'iframe', - url: serverResponses[0].body.cSyncUrl, - }, - ]; - } else if (syncOptions.pixelEnabled && serverResponses[0]?.body.dspPixels) { - return serverResponses[0].body.dspPixels.map((pixel) => ({ - type: 'image', - url: pixel, - })); - } - return []; - }, + // getUserSyncs: (syncOptions, serverResponses) => { + // if (syncOptions.iframeEnabled && serverResponses[0]?.body.cSyncUrl) { + // return [ + // { + // type: 'iframe', + // url: serverResponses[0].body.cSyncUrl, + // }, + // ]; + // } else if (syncOptions.pixelEnabled && serverResponses[0]?.body.dspPixels) { + // return serverResponses[0].body.dspPixels.map((pixel) => ({ + // type: 'image', + // url: pixel, + // })); + // } + // return []; + // }, }; export const converter = ortbConverter({ diff --git a/test/spec/modules/equativBidAdapter_spec.js b/test/spec/modules/equativBidAdapter_spec.js new file mode 100644 index 00000000000..5e4416bcb7e --- /dev/null +++ b/test/spec/modules/equativBidAdapter_spec.js @@ -0,0 +1,202 @@ +import { spec, converter } from 'modules/equativBidAdapter.js'; + +describe('Equativ bid adapter tests', function () { + const DEFAULT_BID_REQUESTS = [ + { + adUnitCode: 'eqtv_42', + bidId: 'abcd1234', + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [300, 200], + ], + }, + }, + bidder: 'equativ', + params: { + siteId: '1234', + pageId: '5678', + formatId: '90', + networkId: 111, + }, + requestId: 'efgh5678', + ortb2Imp: { + ext: { + tid: 'zsfgzzg', + }, + }, + }, + ]; + + const DEFAULT_BIDDER_REQUEST = { + bidderCode: 'equativ', + bids: DEFAULT_BID_REQUESTS, + }; + + const SAMPLE_RESPONSE = { + body: { + id: '12h712u7-k22g-8124-ab7a-h268s22dy271', + seatbid: [ + { + bid: [ + { + id: '1bh7jku7-ko2g-8654-ab72-h268shvwy271', + impid: 'r12gwgf231', + price: 0.6565, + adm: '

AD

', + adomain: ['abc.com'], + cid: '1242512', + crid: '535231', + w: 300, + h: 600, + mtype: 1, + cat: ['IAB19', 'IAB19-1'], + cattax: 1, + }, + ], + seat: '4212', + }, + ], + cur: 'USD', + statuscode: 0, + }, + }; + + describe('buildRequests', () => { + it('should build correct request using ORTB converter', () => { + const request = spec.buildRequests( + DEFAULT_BID_REQUESTS, + DEFAULT_BIDDER_REQUEST + ); + const dataFromConverter = converter.toORTB({ + bidderRequest: DEFAULT_BIDDER_REQUEST, + bidRequests: DEFAULT_BID_REQUESTS, + }); + expect(request).to.deep.equal({ + data: { ...dataFromConverter, id: request.data.id }, + method: 'POST', + url: 'https://ssb-global.smartadserver.com/api/bid?callerId=169', + }); + }); + + it('should add ext.bidder to imp object when siteId is defined', () => { + const bidRequests = [ + { ...DEFAULT_BID_REQUESTS[0], params: { siteId: 123 } }, + ]; + const bidderRequest = { ...DEFAULT_BIDDER_REQUEST, bids: bidRequests }; + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.imp[0].ext.bidder).to.deep.equal({ + siteId: 123, + }); + }); + + it('should add ext.bidder to imp object when pageId is defined', () => { + const bidRequests = [ + { ...DEFAULT_BID_REQUESTS[0], params: { pageId: 123 } }, + ]; + const bidderRequest = { ...DEFAULT_BIDDER_REQUEST, bids: bidRequests }; + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.imp[0].ext.bidder).to.deep.equal({ + pageId: 123, + }); + }); + + it('should add ext.bidder to imp object when formatId is defined', () => { + const bidRequests = [ + { ...DEFAULT_BID_REQUESTS[0], params: { formatId: 123 } }, + ]; + const bidderRequest = { ...DEFAULT_BIDDER_REQUEST, bids: bidRequests }; + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.imp[0].ext.bidder).to.deep.equal({ + formatId: 123, + }); + }); + + it('should not add ext.bidder to imp object when siteId, pageId, formatId are not defined', () => { + const bidRequests = [{ ...DEFAULT_BID_REQUESTS[0], params: {} }]; + const bidderRequest = { ...DEFAULT_BIDDER_REQUEST, bids: bidRequests }; + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.imp[0].ext.bidder).to.be.undefined; + }); + + it('should add site.publisher.id param', () => { + const request = spec.buildRequests( + DEFAULT_BID_REQUESTS, + DEFAULT_BIDDER_REQUEST + ); + expect(request.data.site.publisher.id).to.equal(111); + }); + }); + + describe('interpretResponse', () => { + it('should return data returned by ORTB converter', () => { + const request = spec.buildRequests( + DEFAULT_BID_REQUESTS, + DEFAULT_BIDDER_REQUEST + ); + const bids = spec.interpretResponse(SAMPLE_RESPONSE, request); + expect(bids).to.deep.equal( + converter.fromORTB({ + request: request.data, + response: SAMPLE_RESPONSE.body, + }) + ); + }); + }); + + describe('isBidRequestValid', () => { + it('should return true if params.networkId is set', () => { + const bidRequest = { + params: { + networkId: 123, + }, + }; + expect(spec.isBidRequestValid(bidRequest)).to.equal(true); + }); + + it('should return true if ortb2Imp.site.publisher.id is set', () => { + const bidRequest = { + ortb2Imp: { + site: { + publisher: { + id: 123, + }, + }, + }, + }; + expect(spec.isBidRequestValid(bidRequest)).to.equal(true); + }); + + it('should return true if ortb2Imp.app.publisher.id is set', () => { + const bidRequest = { + ortb2Imp: { + app: { + publisher: { + id: 123, + }, + }, + }, + }; + expect(spec.isBidRequestValid(bidRequest)).to.equal(true); + }); + + it('should return true if ortb2Imp.dooh.publisher.id is set', () => { + const bidRequest = { + ortb2Imp: { + dooh: { + publisher: { + id: 123, + }, + }, + }, + }; + expect(spec.isBidRequestValid(bidRequest)).to.equal(true); + }); + + it('should return false if networkId is not set', () => { + const bidRequest = {}; + expect(spec.isBidRequestValid(bidRequest)).to.equal(false); + }); + }); +}); From 259cba2db674bae271eed22ea9f1de69bf50fefd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Sok=C3=B3=C5=82?= Date: Fri, 20 Sep 2024 11:53:21 +0200 Subject: [PATCH 12/33] add dsp user sync --- modules/equativBidAdapter.js | 38 ++++++++++----------- test/spec/modules/equativBidAdapter_spec.js | 37 ++++++++++++++++++-- 2 files changed, 52 insertions(+), 23 deletions(-) diff --git a/modules/equativBidAdapter.js b/modules/equativBidAdapter.js index 600bf498580..828ca74eea2 100644 --- a/modules/equativBidAdapter.js +++ b/modules/equativBidAdapter.js @@ -22,8 +22,7 @@ export const spec = { return { data: converter.toORTB({ bidderRequest, bidRequests }), method: 'POST', - // url: 'https://ssb-global.smartadserver.com/api/bid?callerId=169' - url: 'https://feature-ssb-engine-pips-2655-testenv.internal.smartadserver.com/api/bid?callerId=169', + url: 'https://ssb-global.smartadserver.com/api/bid?callerId=169', }; }, @@ -53,25 +52,24 @@ export const spec = { /** * @param syncOptions - * @param serverResponses - * @return {{type: (string), url: (*|string)}[]} + * @param serverResponse + * @return {{type: string, url: string}[]} */ - // getUserSyncs: (syncOptions, serverResponses) => { - // if (syncOptions.iframeEnabled && serverResponses[0]?.body.cSyncUrl) { - // return [ - // { - // type: 'iframe', - // url: serverResponses[0].body.cSyncUrl, - // }, - // ]; - // } else if (syncOptions.pixelEnabled && serverResponses[0]?.body.dspPixels) { - // return serverResponses[0].body.dspPixels.map((pixel) => ({ - // type: 'image', - // url: pixel, - // })); - // } - // return []; - // }, + getUserSyncs: (syncOptions, serverResponse) => { + // if (syncOptions.iframeEnabled && serverResponses[0]?.body.cSyncUrl) { + // return [ + // { + // type: 'iframe', + // url: serverResponses[0].body.cSyncUrl, + // }, + // ]; + // } + return (syncOptions.pixelEnabled && serverResponse.body.dspPixels) + ? serverResponse.body.dspPixels.map((pixel) => ({ + type: 'image', + url: pixel, + })) : []; + }, }; export const converter = ortbConverter({ diff --git a/test/spec/modules/equativBidAdapter_spec.js b/test/spec/modules/equativBidAdapter_spec.js index 5e4416bcb7e..e92fd1666fa 100644 --- a/test/spec/modules/equativBidAdapter_spec.js +++ b/test/spec/modules/equativBidAdapter_spec.js @@ -15,9 +15,6 @@ describe('Equativ bid adapter tests', function () { }, bidder: 'equativ', params: { - siteId: '1234', - pageId: '5678', - formatId: '90', networkId: 111, }, requestId: 'efgh5678', @@ -63,6 +60,13 @@ describe('Equativ bid adapter tests', function () { }, }; + const RESPONSE_WITH_DSP_PIXELS = { + ...SAMPLE_RESPONSE, + body: { + dspPixels: ['1st-pixel', '2nd-pixel', '3rd-pixel'] + } + }; + describe('buildRequests', () => { it('should build correct request using ORTB converter', () => { const request = spec.buildRequests( @@ -129,6 +133,33 @@ describe('Equativ bid adapter tests', function () { }); }); + describe('getUserSyncs', () => { + it('should return empty array if no pixel sync not enabled', function () { + const syncs = spec.getUserSyncs({}, RESPONSE_WITH_DSP_PIXELS); + expect(syncs).to.deep.equal([]); + }); + + it('should return empty array if no pixels available', function () { + const syncs = spec.getUserSyncs( + { pixelEnabled: true }, + SAMPLE_RESPONSE + ); + expect(syncs).to.deep.equal([]); + }); + + it('should register dsp pixels', function () { + const syncs = spec.getUserSyncs( + { pixelEnabled: true }, + RESPONSE_WITH_DSP_PIXELS + ); + expect(syncs).to.have.lengthOf(3); + expect(syncs[1]).to.deep.equal({ + type: 'image', + url: '2nd-pixel', + }); + }); + }); + describe('interpretResponse', () => { it('should return data returned by ORTB converter', () => { const request = spec.buildRequests( From 9a92f9d243159d1e3cf971cc6c56a98b8fd653fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Sok=C3=B3=C5=82?= Date: Fri, 20 Sep 2024 11:53:30 +0200 Subject: [PATCH 13/33] add readme --- modules/equativBidAdapter.md | 40 ++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 modules/equativBidAdapter.md diff --git a/modules/equativBidAdapter.md b/modules/equativBidAdapter.md new file mode 100644 index 00000000000..7d1210b9a5d --- /dev/null +++ b/modules/equativBidAdapter.md @@ -0,0 +1,40 @@ +# Overview + +``` +Module Name: Equativ Bidder Adapter (beta) +Module Type: Bidder Adapter +Maintainer: support@equativ.com +``` + +# Description + +Connect to Equativ for bids. + +The Equativ adapter requires setup and approval from the Equativ team. Please reach out to your technical account manager for more information. + +# Test Parameters + +## Web or In-app +```javascript +var adUnits = [ + { + code: '/589236/banner_1', + mediaTypes: { + banner: { + sizes: [[300, 250]] + } + }, + bids: [ + { + bidder: 'equativ', + params: { + networkId: 10, // mandatory if no ortb2Imp.(site or app).publisher.id defined + siteId: 20743, // optional + pageId: 89653, // optional + formatId: 291, // optional + } + } + ] + } +]; +``` \ No newline at end of file From 811932cbbe8b869192295e3d4655b63ea2a45f9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Sok=C3=B3=C5=82?= Date: Fri, 20 Sep 2024 13:59:29 +0200 Subject: [PATCH 14/33] body can be undef --- modules/equativBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/equativBidAdapter.js b/modules/equativBidAdapter.js index 828ca74eea2..f4ddba0d840 100644 --- a/modules/equativBidAdapter.js +++ b/modules/equativBidAdapter.js @@ -64,7 +64,7 @@ export const spec = { // }, // ]; // } - return (syncOptions.pixelEnabled && serverResponse.body.dspPixels) + return (syncOptions.pixelEnabled && serverResponse.body?.dspPixels) ? serverResponse.body.dspPixels.map((pixel) => ({ type: 'image', url: pixel, From ae67b8ae7911427fbf99a580dd419d886bae9f17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Sok=C3=B3=C5=82?= Date: Wed, 25 Sep 2024 14:44:43 +0200 Subject: [PATCH 15/33] support additional br params --- modules/equativBidAdapter.js | 6 +++- test/spec/modules/equativBidAdapter_spec.js | 32 ++++++++++++++++++--- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/modules/equativBidAdapter.js b/modules/equativBidAdapter.js index f4ddba0d840..6b3b5cf2da3 100644 --- a/modules/equativBidAdapter.js +++ b/modules/equativBidAdapter.js @@ -22,7 +22,7 @@ export const spec = { return { data: converter.toORTB({ bidderRequest, bidRequests }), method: 'POST', - url: 'https://ssb-global.smartadserver.com/api/bid?callerId=169', + url: 'https://ssb-global.smartadserver.com/api/bid?callerId=169' }; }, @@ -82,6 +82,10 @@ export const converter = ortbConverter({ const imp = buildImp(bidRequest, context); const { siteId, pageId, formatId } = bidRequest.params; + imp.bidfloor = imp.bidfloor || 0.0; + imp.secure = Number(window.location.protocol === 'https:'); + imp.tagid = bidRequest.adUnitCode; + if (siteId || pageId || formatId) { const bidder = {}; diff --git a/test/spec/modules/equativBidAdapter_spec.js b/test/spec/modules/equativBidAdapter_spec.js index e92fd1666fa..bd6f2410f44 100644 --- a/test/spec/modules/equativBidAdapter_spec.js +++ b/test/spec/modules/equativBidAdapter_spec.js @@ -1,6 +1,6 @@ import { spec, converter } from 'modules/equativBidAdapter.js'; -describe('Equativ bid adapter tests', function () { +describe('Equativ bid adapter tests', () => { const DEFAULT_BID_REQUESTS = [ { adUnitCode: 'eqtv_42', @@ -131,15 +131,39 @@ describe('Equativ bid adapter tests', function () { ); expect(request.data.site.publisher.id).to.equal(111); }); + + it('should send default floor of 0.0', () => { + const request = spec.buildRequests( + DEFAULT_BID_REQUESTS, + DEFAULT_BIDDER_REQUEST + ); + expect(request.data.imp[0]).to.have.property('bidfloor').that.eq(0.0); + }); + + it('should send secure connection', () => { + const request = spec.buildRequests( + DEFAULT_BID_REQUESTS, + DEFAULT_BIDDER_REQUEST + ); + expect(request.data.imp[0]).to.have.property('secure').that.within(0, 1); + }); + + it('should have tagid', () => { + const request = spec.buildRequests( + DEFAULT_BID_REQUESTS, + DEFAULT_BIDDER_REQUEST + ); + expect(request.data.imp[0]).to.have.property('tagid').that.eq(DEFAULT_BID_REQUESTS[0].adUnitCode); + }); }); describe('getUserSyncs', () => { - it('should return empty array if no pixel sync not enabled', function () { + it('should return empty array if no pixel sync not enabled', () => { const syncs = spec.getUserSyncs({}, RESPONSE_WITH_DSP_PIXELS); expect(syncs).to.deep.equal([]); }); - it('should return empty array if no pixels available', function () { + it('should return empty array if no pixels available', () => { const syncs = spec.getUserSyncs( { pixelEnabled: true }, SAMPLE_RESPONSE @@ -147,7 +171,7 @@ describe('Equativ bid adapter tests', function () { expect(syncs).to.deep.equal([]); }); - it('should register dsp pixels', function () { + it('should register dsp pixels', () => { const syncs = spec.getUserSyncs( { pixelEnabled: true }, RESPONSE_WITH_DSP_PIXELS From bc4e78a3cce7775d25208fef2c6dabd7a41dd454 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Sok=C3=B3=C5=82?= Date: Fri, 27 Sep 2024 08:27:59 +0200 Subject: [PATCH 16/33] remove user sync --- modules/equativBidAdapter.js | 30 ++++++------- test/spec/modules/equativBidAdapter_spec.js | 48 ++++++++++----------- 2 files changed, 39 insertions(+), 39 deletions(-) diff --git a/modules/equativBidAdapter.js b/modules/equativBidAdapter.js index 6b3b5cf2da3..d89a6a9f461 100644 --- a/modules/equativBidAdapter.js +++ b/modules/equativBidAdapter.js @@ -55,21 +55,21 @@ export const spec = { * @param serverResponse * @return {{type: string, url: string}[]} */ - getUserSyncs: (syncOptions, serverResponse) => { - // if (syncOptions.iframeEnabled && serverResponses[0]?.body.cSyncUrl) { - // return [ - // { - // type: 'iframe', - // url: serverResponses[0].body.cSyncUrl, - // }, - // ]; - // } - return (syncOptions.pixelEnabled && serverResponse.body?.dspPixels) - ? serverResponse.body.dspPixels.map((pixel) => ({ - type: 'image', - url: pixel, - })) : []; - }, + // getUserSyncs: (syncOptions, serverResponse) => { + // if (syncOptions.iframeEnabled && serverResponses[0]?.body.cSyncUrl) { + // return [ + // { + // type: 'iframe', + // url: serverResponses[0].body.cSyncUrl, + // }, + // ]; + // } + // return (syncOptions.pixelEnabled && serverResponse.body?.dspPixels) + // ? serverResponse.body.dspPixels.map((pixel) => ({ + // type: 'image', + // url: pixel, + // })) : []; + // }, }; export const converter = ortbConverter({ diff --git a/test/spec/modules/equativBidAdapter_spec.js b/test/spec/modules/equativBidAdapter_spec.js index bd6f2410f44..80a31adb9b9 100644 --- a/test/spec/modules/equativBidAdapter_spec.js +++ b/test/spec/modules/equativBidAdapter_spec.js @@ -157,32 +157,32 @@ describe('Equativ bid adapter tests', () => { }); }); - describe('getUserSyncs', () => { - it('should return empty array if no pixel sync not enabled', () => { - const syncs = spec.getUserSyncs({}, RESPONSE_WITH_DSP_PIXELS); - expect(syncs).to.deep.equal([]); - }); + // describe('getUserSyncs', () => { + // it('should return empty array if no pixel sync not enabled', () => { + // const syncs = spec.getUserSyncs({}, RESPONSE_WITH_DSP_PIXELS); + // expect(syncs).to.deep.equal([]); + // }); - it('should return empty array if no pixels available', () => { - const syncs = spec.getUserSyncs( - { pixelEnabled: true }, - SAMPLE_RESPONSE - ); - expect(syncs).to.deep.equal([]); - }); + // it('should return empty array if no pixels available', () => { + // const syncs = spec.getUserSyncs( + // { pixelEnabled: true }, + // SAMPLE_RESPONSE + // ); + // expect(syncs).to.deep.equal([]); + // }); - it('should register dsp pixels', () => { - const syncs = spec.getUserSyncs( - { pixelEnabled: true }, - RESPONSE_WITH_DSP_PIXELS - ); - expect(syncs).to.have.lengthOf(3); - expect(syncs[1]).to.deep.equal({ - type: 'image', - url: '2nd-pixel', - }); - }); - }); + // it('should register dsp pixels', () => { + // const syncs = spec.getUserSyncs( + // { pixelEnabled: true }, + // RESPONSE_WITH_DSP_PIXELS + // ); + // expect(syncs).to.have.lengthOf(3); + // expect(syncs[1]).to.deep.equal({ + // type: 'image', + // url: '2nd-pixel', + // }); + // }); + // }); describe('interpretResponse', () => { it('should return data returned by ORTB converter', () => { From 3148ed83e475dde83ecf875eb317a21cced9162e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Sok=C3=B3=C5=82?= Date: Tue, 8 Oct 2024 10:38:25 +0200 Subject: [PATCH 17/33] do not send dt param --- modules/equativBidAdapter.js | 2 ++ test/spec/modules/equativBidAdapter_spec.js | 21 +++++++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/modules/equativBidAdapter.js b/modules/equativBidAdapter.js index d89a6a9f461..80b34f86243 100644 --- a/modules/equativBidAdapter.js +++ b/modules/equativBidAdapter.js @@ -82,6 +82,8 @@ export const converter = ortbConverter({ const imp = buildImp(bidRequest, context); const { siteId, pageId, formatId } = bidRequest.params; + delete imp.dt; + imp.bidfloor = imp.bidfloor || 0.0; imp.secure = Number(window.location.protocol === 'https:'); imp.tagid = bidRequest.adUnitCode; diff --git a/test/spec/modules/equativBidAdapter_spec.js b/test/spec/modules/equativBidAdapter_spec.js index 80a31adb9b9..ae89cf8d61d 100644 --- a/test/spec/modules/equativBidAdapter_spec.js +++ b/test/spec/modules/equativBidAdapter_spec.js @@ -60,12 +60,12 @@ describe('Equativ bid adapter tests', () => { }, }; - const RESPONSE_WITH_DSP_PIXELS = { - ...SAMPLE_RESPONSE, - body: { - dspPixels: ['1st-pixel', '2nd-pixel', '3rd-pixel'] - } - }; + // const RESPONSE_WITH_DSP_PIXELS = { + // ...SAMPLE_RESPONSE, + // body: { + // dspPixels: ['1st-pixel', '2nd-pixel', '3rd-pixel'] + // } + // }; describe('buildRequests', () => { it('should build correct request using ORTB converter', () => { @@ -155,6 +155,15 @@ describe('Equativ bid adapter tests', () => { ); expect(request.data.imp[0]).to.have.property('tagid').that.eq(DEFAULT_BID_REQUESTS[0].adUnitCode); }); + + it('should remove dt', () => { + const bidRequests = [ + { ...DEFAULT_BID_REQUESTS[0], ortb2Imp: { dt: 1728377558235 } } + ]; + const bidderRequest = { ...DEFAULT_BIDDER_REQUEST, bids: bidRequests }; + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.imp[0]).to.not.have.property('dt'); + }); }); // describe('getUserSyncs', () => { From f08f05d91cf7f16382894b97e66e299de99b985d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Sok=C3=B3=C5=82?= Date: Wed, 9 Oct 2024 08:30:48 +0200 Subject: [PATCH 18/33] handle floors and network id --- modules/equativBidAdapter.js | 45 ++++-- modules/equativBidAdapter.md | 2 +- test/spec/modules/equativBidAdapter_spec.js | 165 +++++++++++++++++++- 3 files changed, 195 insertions(+), 17 deletions(-) diff --git a/modules/equativBidAdapter.js b/modules/equativBidAdapter.js index 80b34f86243..9b63904abf4 100644 --- a/modules/equativBidAdapter.js +++ b/modules/equativBidAdapter.js @@ -1,7 +1,7 @@ import { BANNER } from '../src/mediaTypes.js'; import { ortbConverter } from '../libraries/ortbConverter/converter.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { deepAccess, deepSetValue, mergeDeep } from '../src/utils.js'; +import { deepAccess, deepSetValue, isFn, mergeDeep } from '../src/utils.js'; /** * @typedef {import('../src/adapters/bidderFactory.js').Bid} Bid @@ -26,10 +26,31 @@ export const spec = { }; }, + /** + * @param bidRequest + * @returns {number} + */ + getMinFloor: (bidRequest) => { + const floors = []; + + if (isFn(bidRequest.getFloor)) { + deepAccess(bidRequest, 'mediaTypes.banner.sizes').forEach(size => { + const floor = bidRequest.getFloor({ size }).floor; + if (!isNaN(floor)) { + floors.push(floor); + } else { + floors.push(0.0); + } + }); + } + + return floors.length ? Math.min(...floors) : 0.0; + }, + /** * @param serverResponse * @param bidRequest - * @return {Bid[]} + * @returns {Bid[]} */ interpretResponse: (serverResponse, bidRequest) => converter.fromORTB({ @@ -39,21 +60,21 @@ export const spec = { /** * @param bidRequest - * @return {boolean} + * @returns {boolean} */ isBidRequestValid: (bidRequest) => { return !!( deepAccess(bidRequest, 'params.networkId') || - deepAccess(bidRequest, 'ortb2Imp.site.publisher.id') || - deepAccess(bidRequest, 'ortb2Imp.app.publisher.id') || - deepAccess(bidRequest, 'ortb2Imp.dooh.publisher.id') + deepAccess(bidRequest, 'ortb2.site.publisher.id') || + deepAccess(bidRequest, 'ortb2.app.publisher.id') || + deepAccess(bidRequest, 'ortb2.dooh.publisher.id') ); }, /** * @param syncOptions * @param serverResponse - * @return {{type: string, url: string}[]} + * @returns {{type: string, url: string}[]} */ // getUserSyncs: (syncOptions, serverResponse) => { // if (syncOptions.iframeEnabled && serverResponses[0]?.body.cSyncUrl) { @@ -84,7 +105,7 @@ export const converter = ortbConverter({ delete imp.dt; - imp.bidfloor = imp.bidfloor || 0.0; + imp.bidfloor = imp.bidfloor || spec.getMinFloor(bidRequest); imp.secure = Number(window.location.protocol === 'https:'); imp.tagid = bidRequest.adUnitCode; @@ -115,7 +136,13 @@ export const converter = ortbConverter({ const bid = context.bidRequests[0]; const req = buildRequest(imps, bidderRequest, context); - if (bid.params.networkId) { + if (deepAccess(bid, 'ortb2.site.publisher')) { + deepSetValue(req, 'site.publisher.id', bid.ortb2.site.publisher.id || bid.params.networkId); + } else if (deepAccess(bid, 'ortb2.app.publisher')) { + deepSetValue(req, 'app.publisher.id', bid.ortb2.app.publisher.id || bid.params.networkId); + } else if (deepAccess(bid, 'ortb2.dooh.publisher')) { + deepSetValue(req, 'dooh.publisher.id', bid.ortb2.dooh.publisher.id || bid.params.networkId); + } else { deepSetValue(req, 'site.publisher.id', bid.params.networkId); } diff --git a/modules/equativBidAdapter.md b/modules/equativBidAdapter.md index 7d1210b9a5d..ceee6d19bdc 100644 --- a/modules/equativBidAdapter.md +++ b/modules/equativBidAdapter.md @@ -28,7 +28,7 @@ var adUnits = [ { bidder: 'equativ', params: { - networkId: 10, // mandatory if no ortb2Imp.(site or app).publisher.id defined + networkId: 13, // mandatory if no ortb2.(site or app).publisher.id set siteId: 20743, // optional pageId: 89653, // optional formatId: 291, // optional diff --git a/test/spec/modules/equativBidAdapter_spec.js b/test/spec/modules/equativBidAdapter_spec.js index ae89cf8d61d..0310b102145 100644 --- a/test/spec/modules/equativBidAdapter_spec.js +++ b/test/spec/modules/equativBidAdapter_spec.js @@ -9,7 +9,7 @@ describe('Equativ bid adapter tests', () => { banner: { sizes: [ [300, 250], - [300, 200], + [300, 600], ], }, }, @@ -132,6 +132,99 @@ describe('Equativ bid adapter tests', () => { expect(request.data.site.publisher.id).to.equal(111); }); + it('should pass ortb2.site.publisher.id', () => { + const bidRequests = [{ + ...DEFAULT_BID_REQUESTS[0], + ortb2: { + site: { + publisher: { + id: 98, + } + } + } + }]; + delete bidRequests[0].params; + const bidderRequest = { ...DEFAULT_BIDDER_REQUEST, bids: bidRequests }; + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.site.publisher.id).to.equal(98); + }); + + it('should pass networkId as site.publisher.id', () => { + const bidRequests = [{ + ...DEFAULT_BID_REQUESTS[0], + ortb2: { + site: { + publisher: {} + } + } + }]; + const bidderRequest = { ...DEFAULT_BIDDER_REQUEST, bids: bidRequests }; + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.site.publisher.id).to.equal(111); + }); + + it('should pass ortb2.app.publisher.id', () => { + const bidRequests = [{ + ...DEFAULT_BID_REQUESTS[0], + ortb2: { + app: { + publisher: { + id: 27, + } + } + } + }]; + delete bidRequests[0].params; + const bidderRequest = { ...DEFAULT_BIDDER_REQUEST, bids: bidRequests }; + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.app.publisher.id).to.equal(27); + }); + + it('should pass networkId as app.publisher.id', () => { + const bidRequests = [{ + ...DEFAULT_BID_REQUESTS[0], + ortb2: { + app: { + publisher: {} + } + } + }]; + const bidderRequest = { ...DEFAULT_BIDDER_REQUEST, bids: bidRequests }; + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.app.publisher.id).to.equal(111); + }); + + it('should pass ortb2.dooh.publisher.id', () => { + const bidRequests = [{ + ...DEFAULT_BID_REQUESTS[0], + ortb2: { + dooh: { + publisher: { + id: 35, + } + } + } + }]; + delete bidRequests[0].params; + const bidderRequest = { ...DEFAULT_BIDDER_REQUEST, bids: bidRequests }; + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.dooh.publisher.id).to.equal(35); + }); + + it('should pass networkId as dooh.publisher.id', () => { + const bidRequests = [{ + ...DEFAULT_BID_REQUESTS[0], + ortb2: { + dooh: { + publisher: {} + } + } + }]; + const bidderRequest = { ...DEFAULT_BIDDER_REQUEST, bids: bidRequests }; + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.dooh.publisher.id).to.equal(111); + }); + it('should send default floor of 0.0', () => { const request = spec.buildRequests( DEFAULT_BID_REQUESTS, @@ -166,6 +259,64 @@ describe('Equativ bid adapter tests', () => { }); }); + describe('getMinFloor', () => { + it('should return floor of 0.0 if floor module not available', () => { + const bid = { + ...DEFAULT_BID_REQUESTS[0], + getFloor: false, + }; + expect(spec.getMinFloor(bid)).to.deep.eq(0.0); + }); + + it('should return proper min floor', () => { + const bid = { + ...DEFAULT_BID_REQUESTS[0], + getFloor: data => { + if (data.size[0] === 300 && data.size[1] === 250) { + return { floor: 1.13 }; + } else if (data.size[0] === 300 && data.size[1] === 600) { + return { floor: 1.39 }; + } else { + return { floor: 0.52 }; + } + } + }; + expect(spec.getMinFloor(bid)).to.deep.eq(1.13); + }); + + it('should return global media type floor if no rule for size', () => { + const bid = { + ...DEFAULT_BID_REQUESTS[0], + getFloor: data => { + if (data.size[0] === 728 && data.size[1] === 90) { + return { floor: 1.13 }; + } else if (data.size[0] === 300 && data.size[1] === 600) { + return { floor: 1.36 }; + } else { + return { floor: 0.34 }; + } + } + }; + expect(spec.getMinFloor(bid)).to.deep.eq(0.34); + }); + + it('should return floor of 0 if no rule for size', () => { + const bid = { + ...DEFAULT_BID_REQUESTS[0], + getFloor: data => { + if (data.size[0] === 728 && data.size[1] === 90) { + return { floor: 1.13 }; + } else if (data.size[0] === 300 && data.size[1] === 600) { + return { floor: 1.36 }; + } else { + return {}; + } + } + }; + expect(spec.getMinFloor(bid)).to.deep.eq(0.0); + }); + }); + // describe('getUserSyncs', () => { // it('should return empty array if no pixel sync not enabled', () => { // const syncs = spec.getUserSyncs({}, RESPONSE_WITH_DSP_PIXELS); @@ -219,9 +370,9 @@ describe('Equativ bid adapter tests', () => { expect(spec.isBidRequestValid(bidRequest)).to.equal(true); }); - it('should return true if ortb2Imp.site.publisher.id is set', () => { + it('should return true if ortb2.site.publisher.id is set', () => { const bidRequest = { - ortb2Imp: { + ortb2: { site: { publisher: { id: 123, @@ -232,9 +383,9 @@ describe('Equativ bid adapter tests', () => { expect(spec.isBidRequestValid(bidRequest)).to.equal(true); }); - it('should return true if ortb2Imp.app.publisher.id is set', () => { + it('should return true if ortb2.app.publisher.id is set', () => { const bidRequest = { - ortb2Imp: { + ortb2: { app: { publisher: { id: 123, @@ -245,9 +396,9 @@ describe('Equativ bid adapter tests', () => { expect(spec.isBidRequestValid(bidRequest)).to.equal(true); }); - it('should return true if ortb2Imp.dooh.publisher.id is set', () => { + it('should return true if ortb2.dooh.publisher.id is set', () => { const bidRequest = { - ortb2Imp: { + ortb2: { dooh: { publisher: { id: 123, From 3fac9a9998b6bb09a328d6d4576823e5d54a0ad6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Sok=C3=B3=C5=82?= Date: Thu, 10 Oct 2024 12:10:21 +0200 Subject: [PATCH 19/33] handle empty media types --- modules/equativBidAdapter.js | 2 +- test/spec/modules/equativBidAdapter_spec.js | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/modules/equativBidAdapter.js b/modules/equativBidAdapter.js index 9b63904abf4..c5c96039f67 100644 --- a/modules/equativBidAdapter.js +++ b/modules/equativBidAdapter.js @@ -34,7 +34,7 @@ export const spec = { const floors = []; if (isFn(bidRequest.getFloor)) { - deepAccess(bidRequest, 'mediaTypes.banner.sizes').forEach(size => { + (deepAccess(bidRequest, 'mediaTypes.banner.sizes') || []).forEach(size => { const floor = bidRequest.getFloor({ size }).floor; if (!isNaN(floor)) { floors.push(floor); diff --git a/test/spec/modules/equativBidAdapter_spec.js b/test/spec/modules/equativBidAdapter_spec.js index 0310b102145..c2465176ac1 100644 --- a/test/spec/modules/equativBidAdapter_spec.js +++ b/test/spec/modules/equativBidAdapter_spec.js @@ -268,6 +268,14 @@ describe('Equativ bid adapter tests', () => { expect(spec.getMinFloor(bid)).to.deep.eq(0.0); }); + it('should return floor of 0.0 if mediaTypes not defined', () => { + const bid = { + getFloor: () => ({}) + }; + expect(bid.mediaTypes).to.be.undefined; + expect(spec.getMinFloor(bid)).to.deep.eq(0.0); + }); + it('should return proper min floor', () => { const bid = { ...DEFAULT_BID_REQUESTS[0], From e65525d565c6e7706f283161a33ffcf7ee194b97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Sok=C3=B3=C5=82?= Date: Tue, 15 Oct 2024 16:21:11 +0200 Subject: [PATCH 20/33] get min floor --- modules/smartadserverBidAdapter.js | 27 +++--- .../modules/smartadserverBidAdapter_spec.js | 92 ++++++++++++++++--- 2 files changed, 96 insertions(+), 23 deletions(-) diff --git a/modules/smartadserverBidAdapter.js b/modules/smartadserverBidAdapter.js index 840ba8a82aa..53b13ecf944 100644 --- a/modules/smartadserverBidAdapter.js +++ b/modules/smartadserverBidAdapter.js @@ -6,7 +6,6 @@ import { isEmpty, isFn, isInteger, - isPlainObject, logError } from '../src/utils.js'; import { BANNER, VIDEO } from '../src/mediaTypes.js'; @@ -176,7 +175,7 @@ export const spec = { * Makes server requests from the list of BidRequests. * * @param {BidRequest[]} validBidRequests an array of bids - * @param {BidderRequest} bidderRequest bidder request object + * @param {BidRequest} bidderRequest bidder request object * @return {ServerRequest[]} Info describing the request to the server. */ buildRequests: function (validBidRequests, bidderRequest) { @@ -332,18 +331,22 @@ export const spec = { * @param {string} mediaType Bid media type * @return {number} Floor price */ - getBidFloor: function (bid, currency, mediaType) { - if (!isFn(bid.getFloor)) { - return DEFAULT_FLOOR; + getBidFloor: (bid, currency, mediaType) => { + const floors = []; + + if (isFn(bid.getFloor)) { + (deepAccess(bid, `mediaTypes.${mediaType}.${mediaType === BANNER ? 'sizes' : 'playerSize'}`) || []).forEach(size => { + const floor = bid.getFloor({ + currency: currency || 'USD', + mediaType, + size + }).floor; + + floors.push(!isNaN(floor) ? floor : DEFAULT_FLOOR); + }); } - const floor = bid.getFloor({ - currency: currency || 'USD', - mediaType, - size: '*' - }); - - return isPlainObject(floor) && !isNaN(floor.floor) ? floor.floor : DEFAULT_FLOOR; + return floors.length ? Math.min(...floors) : DEFAULT_FLOOR; }, /** diff --git a/test/spec/modules/smartadserverBidAdapter_spec.js b/test/spec/modules/smartadserverBidAdapter_spec.js index 08b9f616551..cbc680fd313 100644 --- a/test/spec/modules/smartadserverBidAdapter_spec.js +++ b/test/spec/modules/smartadserverBidAdapter_spec.js @@ -1311,17 +1311,6 @@ describe('Smart bid adapter tests', function () { expect(bidRequest.bidfloor).to.deep.equal(DEFAULT_PARAMS[0].params.bidfloor); }); - it('should return floor from module', function() { - const moduleFloor = 1.5; - const bidRequest = JSON.parse((spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL))[0].data); - bidRequest.getFloor = function () { - return { floor: moduleFloor }; - }; - - const floor = spec.getBidFloor(bidRequest, 'EUR'); - expect(floor).to.deep.equal(moduleFloor); - }); - it('should return default floor when module not activated', function() { const bidRequest = JSON.parse((spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL))[0].data); @@ -1425,6 +1414,87 @@ describe('Smart bid adapter tests', function () { expect(bannerRequest).to.not.equal(null).and.to.not.be.undefined; expect(bannerRequest).to.have.property('bidfloor').and.to.equal(1.93); }); + + describe('#getBidFloor', () => { + let bid; + beforeEach(() => { + bid = { + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [300, 600] + ] + } + }, + getFloor: (data) => { + if (data.mediaType === BANNER) { + if (data.size[0] === 300 && data.size[1] === 250) { + return { floor: 1.2 }; + } else if (data.size[0] === 300 && data.size[1] === 600) { + return { floor: 1.4 }; + } else if (data.size[0] === 30 && data.size[1] === 60) { + return 'string'; + } else { + return { floor: 1.0 }; + } + } else if (data.mediaType === VIDEO) { + if (data.size[0] === 640 && data.size[1] === 480) { + return { floor: 2.3 }; + } else { + return { floor: 2.1 }; + } + } else { + return {}; + } + } + }; + }); + + it('should return lowest floor from specified ones', () => { + expect(spec.getBidFloor(bid, 'DKK', BANNER)).to.deep.eq(1.2); + }); + + it('should return default floor for media type whatever size', () => { + bid.mediaTypes.banner.sizes.push([300, 400]); + expect(spec.getBidFloor(bid, 'DKK', BANNER)).to.deep.eq(1.0); + }); + + it('should return default floor', () => { + expect(spec.getBidFloor(bid, 'DKK', VIDEO)).to.deep.eq(0); + }); + + it('should return default floor when currency not passed', () => { + expect(spec.getBidFloor(bid, undefined, BANNER)).to.deep.eq(1.2); + }); + + it('should return handle not number from floor module', () => { + bid.mediaTypes.banner.sizes.push([30, 60]); + expect(spec.getBidFloor(bid, 'DKK', BANNER)).to.deep.eq(0); + }); + + it('should return proper video floor', () => { + bid.mediaTypes = { + video: { + playerSize: [ + [640, 480] + ] + } + }; + expect(spec.getBidFloor(bid, 'DKK', VIDEO)).to.deep.eq(2.3); + }); + + it('should return default video floor', () => { + bid.mediaTypes = { + video: { + playerSize: [ + [640, 490] + ] + } + }; + expect(spec.getBidFloor(bid, 'DKK', VIDEO)).to.deep.eq(2.1); + }); + }); }); describe('Verify bid requests with multiple mediaTypes', function () { From 9ce2bc29020b3078c7c25273f8c9b74bcd8c20c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Sok=C3=B3=C5=82?= Date: Wed, 16 Oct 2024 12:23:13 +0200 Subject: [PATCH 21/33] fix desc for u.t. --- 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 cbc680fd313..62c1b0de92c 100644 --- a/test/spec/modules/smartadserverBidAdapter_spec.js +++ b/test/spec/modules/smartadserverBidAdapter_spec.js @@ -1468,7 +1468,7 @@ describe('Smart bid adapter tests', function () { expect(spec.getBidFloor(bid, undefined, BANNER)).to.deep.eq(1.2); }); - it('should return handle not number from floor module', () => { + it('should handle not number returned by floor module', () => { bid.mediaTypes.banner.sizes.push([30, 60]); expect(spec.getBidFloor(bid, 'DKK', BANNER)).to.deep.eq(0); }); From fb9b8936bce3ff4f1174ddd0508014d619babf28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Sok=C3=B3=C5=82?= Date: Wed, 16 Oct 2024 12:25:42 +0200 Subject: [PATCH 22/33] better name for u.t. --- 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 62c1b0de92c..5800a967c8c 100644 --- a/test/spec/modules/smartadserverBidAdapter_spec.js +++ b/test/spec/modules/smartadserverBidAdapter_spec.js @@ -1468,7 +1468,7 @@ describe('Smart bid adapter tests', function () { expect(spec.getBidFloor(bid, undefined, BANNER)).to.deep.eq(1.2); }); - it('should handle not number returned by floor module', () => { + it('should return DEFAULT_FLOOR in case of not a number value from floor module', () => { bid.mediaTypes.banner.sizes.push([30, 60]); expect(spec.getBidFloor(bid, 'DKK', BANNER)).to.deep.eq(0); }); From 9f9c13325ce38e51b2495d327bac2d67b474f34f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Sok=C3=B3=C5=82?= Date: Wed, 16 Oct 2024 12:32:10 +0200 Subject: [PATCH 23/33] add u.t. for not supported media type --- test/spec/modules/smartadserverBidAdapter_spec.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/spec/modules/smartadserverBidAdapter_spec.js b/test/spec/modules/smartadserverBidAdapter_spec.js index 5800a967c8c..0a62d5207db 100644 --- a/test/spec/modules/smartadserverBidAdapter_spec.js +++ b/test/spec/modules/smartadserverBidAdapter_spec.js @@ -1494,6 +1494,10 @@ describe('Smart bid adapter tests', function () { }; expect(spec.getBidFloor(bid, 'DKK', VIDEO)).to.deep.eq(2.1); }); + + it('should return DEFAULT_FLOOR for not supported media type', () => { + expect(spec.getBidFloor(bid, 'USD', 'test')).to.deep.eq(0); + }); }); }); From 08e3c525e94ad3250a62c2f99001a00338565bb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Sok=C3=B3=C5=82?= Date: Wed, 16 Oct 2024 12:52:15 +0200 Subject: [PATCH 24/33] improve currency u.t. --- .../modules/smartadserverBidAdapter_spec.js | 48 ++++++++++--------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/test/spec/modules/smartadserverBidAdapter_spec.js b/test/spec/modules/smartadserverBidAdapter_spec.js index 0a62d5207db..3ee00a99bd9 100644 --- a/test/spec/modules/smartadserverBidAdapter_spec.js +++ b/test/spec/modules/smartadserverBidAdapter_spec.js @@ -1428,49 +1428,53 @@ describe('Smart bid adapter tests', function () { } }, getFloor: (data) => { - if (data.mediaType === BANNER) { - if (data.size[0] === 300 && data.size[1] === 250) { - return { floor: 1.2 }; - } else if (data.size[0] === 300 && data.size[1] === 600) { - return { floor: 1.4 }; - } else if (data.size[0] === 30 && data.size[1] === 60) { - return 'string'; + if (data.currency === 'USD') { + if (data.mediaType === BANNER) { + if (data.size[0] === 300 && data.size[1] === 250) { + return { floor: 1.2 }; + } else if (data.size[0] === 300 && data.size[1] === 600) { + return { floor: 1.4 }; + } else if (data.size[0] === 30 && data.size[1] === 60) { + return 'string'; + } else { + return { floor: 1.0 }; + } + } else if (data.mediaType === VIDEO) { + if (data.size[0] === 640 && data.size[1] === 480) { + return { floor: 2.3 }; + } else { + return { floor: 2.1 }; + } } else { - return { floor: 1.0 }; - } - } else if (data.mediaType === VIDEO) { - if (data.size[0] === 640 && data.size[1] === 480) { - return { floor: 2.3 }; - } else { - return { floor: 2.1 }; + return {}; } } else { - return {}; + return undefined; } } }; }); it('should return lowest floor from specified ones', () => { - expect(spec.getBidFloor(bid, 'DKK', BANNER)).to.deep.eq(1.2); + expect(spec.getBidFloor(bid, 'USD', BANNER)).to.deep.eq(1.2); }); it('should return default floor for media type whatever size', () => { bid.mediaTypes.banner.sizes.push([300, 400]); - expect(spec.getBidFloor(bid, 'DKK', BANNER)).to.deep.eq(1.0); + expect(spec.getBidFloor(bid, 'USD', BANNER)).to.deep.eq(1.0); }); it('should return default floor', () => { - expect(spec.getBidFloor(bid, 'DKK', VIDEO)).to.deep.eq(0); + expect(spec.getBidFloor(bid, 'USD', VIDEO)).to.deep.eq(0); }); - it('should return default floor when currency not passed', () => { + it('should return floor when currency not passed', () => { expect(spec.getBidFloor(bid, undefined, BANNER)).to.deep.eq(1.2); }); it('should return DEFAULT_FLOOR in case of not a number value from floor module', () => { bid.mediaTypes.banner.sizes.push([30, 60]); - expect(spec.getBidFloor(bid, 'DKK', BANNER)).to.deep.eq(0); + expect(spec.getBidFloor(bid, 'USD', BANNER)).to.deep.eq(0); }); it('should return proper video floor', () => { @@ -1481,7 +1485,7 @@ describe('Smart bid adapter tests', function () { ] } }; - expect(spec.getBidFloor(bid, 'DKK', VIDEO)).to.deep.eq(2.3); + expect(spec.getBidFloor(bid, 'USD', VIDEO)).to.deep.eq(2.3); }); it('should return default video floor', () => { @@ -1492,7 +1496,7 @@ describe('Smart bid adapter tests', function () { ] } }; - expect(spec.getBidFloor(bid, 'DKK', VIDEO)).to.deep.eq(2.1); + expect(spec.getBidFloor(bid, 'USD', VIDEO)).to.deep.eq(2.1); }); it('should return DEFAULT_FLOOR for not supported media type', () => { From c0990ebef6ea76b0f0ada34791664e615ae2c147 Mon Sep 17 00:00:00 2001 From: Jeff Mahoney Date: Fri, 25 Oct 2024 08:52:38 -0400 Subject: [PATCH 25/33] SADR-6484: initial video setup for new PBJS adapter --- modules/equativBidAdapter.js | 7 ++- src/ajax.js | 8 ++- test/spec/modules/equativBidAdapter_spec.js | 67 ++++++++++++++++++++- 3 files changed, 76 insertions(+), 6 deletions(-) diff --git a/modules/equativBidAdapter.js b/modules/equativBidAdapter.js index c5c96039f67..b6f072684d1 100644 --- a/modules/equativBidAdapter.js +++ b/modules/equativBidAdapter.js @@ -1,6 +1,6 @@ -import { BANNER } from '../src/mediaTypes.js'; import { ortbConverter } from '../libraries/ortbConverter/converter.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER, VIDEO } from '../src/mediaTypes.js'; import { deepAccess, deepSetValue, isFn, mergeDeep } from '../src/utils.js'; /** @@ -11,7 +11,7 @@ import { deepAccess, deepSetValue, isFn, mergeDeep } from '../src/utils.js'; export const spec = { code: 'equativ', gvlid: 45, - supportedMediaTypes: [BANNER], + supportedMediaTypes: [BANNER, VIDEO], /** * @param bidRequests @@ -22,7 +22,8 @@ export const spec = { return { data: converter.toORTB({ bidderRequest, bidRequests }), method: 'POST', - url: 'https://ssb-global.smartadserver.com/api/bid?callerId=169' + url: 'https://ssb-engine-argocd-dev.internal.smartadserver.com/api/bid?callerId=169' // TODO: SADR-6484: temporary URL for testing + // url: 'https://ssb-global.smartadserver.com/api/bid?callerId=169' // TODO: SADR-6484: original URL to be used after testing }; }, diff --git a/src/ajax.js b/src/ajax.js index 7f9857ad18d..c018f9d5ce9 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -1,5 +1,5 @@ -import {config} from './config.js'; -import {buildUrl, logError, parseUrl} from './utils.js'; +import { config } from './config.js'; +import { buildUrl, logError, parseUrl } from './utils.js'; export const dep = { fetch: window.fetch.bind(window), @@ -37,6 +37,10 @@ export function toFetchRequest(url, data, options = {}) { } const headers = new Headers(options.customHeaders); headers.set(CTYPE, options.contentType || 'text/plain'); + // TODO: SADR-6484: remove this (if statement below) after testing + if (url === 'https://ssb-engine-argocd-dev.internal.smartadserver.com/api/bid?callerId=169') { + headers.set('X-Eqtv-Debug', '671a49bebd18e71ead36f0a1'); + } const rqOpts = { method, headers diff --git a/test/spec/modules/equativBidAdapter_spec.js b/test/spec/modules/equativBidAdapter_spec.js index c2465176ac1..8f07cafd9a2 100644 --- a/test/spec/modules/equativBidAdapter_spec.js +++ b/test/spec/modules/equativBidAdapter_spec.js @@ -1,4 +1,4 @@ -import { spec, converter } from 'modules/equativBidAdapter.js'; +import { converter, spec } from 'modules/equativBidAdapter.js'; describe('Equativ bid adapter tests', () => { const DEFAULT_BID_REQUESTS = [ @@ -24,6 +24,40 @@ describe('Equativ bid adapter tests', () => { }, }, }, + { + adUnitCode: 'eqtv_43', + bidId: 'efgh5678', + mediaTypes: { + video: { + pos: 3, + skip: 1, + linearity: 1, + minduration: 10, + maxduration: 30, + minbitrate: 300, + maxbitrate: 600, + w: 640, + h: 480, + playbackmethod: [1], + api: [3], + mimes: ['video/x-flv'], + // protocols: [2, 3], // used in older adapter ... including as comment for reference + startdelay: 42, + battr: [13, 14], + placement: 1, + }, + }, + bidder: 'equativ', + params: { + networkId: 111, + }, + requestId: 'abcd1234', + ortb2Imp: { + ext: { + tid: 'zsgzgzz', + }, + }, + } ]; const DEFAULT_BIDDER_REQUEST = { @@ -84,6 +118,37 @@ describe('Equativ bid adapter tests', () => { }); }); + it('should build a video request properly', () => { + // ASSEMBLE + const videoRequest = DEFAULT_BID_REQUESTS[1]; + const bidRequests = [ + { ...videoRequest, params: { siteId: 123 } }, + ]; + const bidderRequest = { ...DEFAULT_BIDDER_REQUEST, bids: bidRequests }; + + // ACT + const request = spec.buildRequests(bidRequests, bidderRequest); + + // ASSERT + const videoObj = request.data.imp[0].video; + expect(videoObj).to.have.property('pos').and.to.equal(3); + expect(videoObj).to.have.property('skip').and.to.equal(1); + expect(videoObj).to.have.property('linearity').and.to.equal(1); + expect(videoObj).to.have.property('minduration').and.to.equal(10); + expect(videoObj).to.have.property('maxduration').and.to.equal(30); + expect(videoObj).to.have.property('minbitrate').and.to.equal(300); + expect(videoObj).to.have.property('maxbitrate').and.to.equal(600); + expect(videoObj).to.have.property('w').and.to.equal(640); + expect(videoObj).to.have.property('h').and.to.equal(480); + expect(videoObj).to.have.property('playbackmethod').and.to.deep.equal([1]); + expect(videoObj).to.have.property('api').and.to.deep.equal([3]); + expect(videoObj).to.have.property('mimes').and.to.deep.equal(['video/x-flv']); + // expect(videoObj).to.have.property('protocols').and.to.deep.equal([2, 3]); // used in older adapter ... including as comment for reference + expect(videoObj).to.have.property('startdelay').and.to.equal(42); + expect(videoObj).to.have.property('battr').and.to.deep.equal([13, 14]); + expect(videoObj).to.have.property('placement').and.to.equal(1); + }); + it('should add ext.bidder to imp object when siteId is defined', () => { const bidRequests = [ { ...DEFAULT_BID_REQUESTS[0], params: { siteId: 123 } }, From 19b147c77b3097f6976006b5689da7d2439486ea Mon Sep 17 00:00:00 2001 From: Jeff Mahoney Date: Mon, 28 Oct 2024 18:35:21 -0400 Subject: [PATCH 26/33] SADR-6484: Adding logging requirement missed earlier --- modules/equativBidAdapter.js | 11 ++++++- test/spec/modules/equativBidAdapter_spec.js | 36 ++++++++++++++++++++- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/modules/equativBidAdapter.js b/modules/equativBidAdapter.js index b6f072684d1..a55c47149c4 100644 --- a/modules/equativBidAdapter.js +++ b/modules/equativBidAdapter.js @@ -1,7 +1,9 @@ import { ortbConverter } from '../libraries/ortbConverter/converter.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { BANNER, VIDEO } from '../src/mediaTypes.js'; -import { deepAccess, deepSetValue, isFn, mergeDeep } from '../src/utils.js'; +import { deepAccess, deepSetValue, isFn, logWarn, mergeDeep } from '../src/utils.js'; + +const LOG_PREFIX = 'Equativ:'; /** * @typedef {import('../src/adapters/bidderFactory.js').Bid} Bid @@ -147,6 +149,13 @@ export const converter = ortbConverter({ deepSetValue(req, 'site.publisher.id', bid.params.networkId); } + if (bid.mediaTypes.video && !bid.mediaTypes.video.mimes) { + logWarn(`${LOG_PREFIX} Property "mimes" is missing from request`, bid); + } + if (bid.mediaTypes.video && !bid.mediaTypes.video.placement) { + logWarn(`${LOG_PREFIX} Property "placement" is missing from request`, bid); + } + return req; }, }); diff --git a/test/spec/modules/equativBidAdapter_spec.js b/test/spec/modules/equativBidAdapter_spec.js index 8f07cafd9a2..2f3143ea9ff 100644 --- a/test/spec/modules/equativBidAdapter_spec.js +++ b/test/spec/modules/equativBidAdapter_spec.js @@ -1,6 +1,16 @@ import { converter, spec } from 'modules/equativBidAdapter.js'; +import * as utils from '../../../src/utils.js'; describe('Equativ bid adapter tests', () => { + let sandBox; + beforeEach(() => { + sandBox = sinon.createSandbox(); + sandBox.stub(utils, 'logWarn'); + }); + afterEach(() => { + sandBox.restore(); + }); + const DEFAULT_BID_REQUESTS = [ { adUnitCode: 'eqtv_42', @@ -102,6 +112,9 @@ describe('Equativ bid adapter tests', () => { // }; describe('buildRequests', () => { + // const ENDPOINT = 'https://ssb-global.smartadserver.com/api/bid?callerId=169'; + const ENDPOINT = 'https://ssb-engine-argocd-dev.internal.smartadserver.com/api/bid?callerId=169'; + it('should build correct request using ORTB converter', () => { const request = spec.buildRequests( DEFAULT_BID_REQUESTS, @@ -114,7 +127,7 @@ describe('Equativ bid adapter tests', () => { expect(request).to.deep.equal({ data: { ...dataFromConverter, id: request.data.id }, method: 'POST', - url: 'https://ssb-global.smartadserver.com/api/bid?callerId=169', + url: ENDPOINT, // TODO: SADR-6484: temporary URL for testing - change back to real one when done testing }); }); @@ -149,6 +162,27 @@ describe('Equativ bid adapter tests', () => { expect(videoObj).to.have.property('placement').and.to.equal(1); }); + it('should warn about missing required properties', () => { + // ASSEMBLE + const vidReqWithMissingProps = DEFAULT_BID_REQUESTS.map((req) => { + if (req.mediaTypes.video) { + delete req.mediaTypes.video.mimes; + delete req.placement; + } + return req; + })[1] + const bidRequests = [ + { ...vidReqWithMissingProps, params: { siteId: 123 } }, + ]; + const bidderRequest = { ...DEFAULT_BIDDER_REQUEST, bids: bidRequests }; + + // ACT + spec.buildRequests(bidRequests, bidderRequest); + + // ASSERT + expect(utils.logWarn.called).to.equal(true) + }) + it('should add ext.bidder to imp object when siteId is defined', () => { const bidRequests = [ { ...DEFAULT_BID_REQUESTS[0], params: { siteId: 123 } }, From 3a6c723344a186c48eb1945f8230ae265b72d4df Mon Sep 17 00:00:00 2001 From: Jeff Mahoney Date: Tue, 29 Oct 2024 00:38:40 -0400 Subject: [PATCH 27/33] SADR-6484: handle ext.rewarded prop for video with new oRTBConverter --- modules/equativBidAdapter.js | 6 ++++++ test/spec/modules/equativBidAdapter_spec.js | 2 ++ 2 files changed, 8 insertions(+) diff --git a/modules/equativBidAdapter.js b/modules/equativBidAdapter.js index a55c47149c4..869d3c6296b 100644 --- a/modules/equativBidAdapter.js +++ b/modules/equativBidAdapter.js @@ -112,6 +112,12 @@ export const converter = ortbConverter({ imp.secure = Number(window.location.protocol === 'https:'); imp.tagid = bidRequest.adUnitCode; + if (bidRequest.mediaTypes.video && !!bidRequest.mediaTypes.video.ext.rewarded) { + mergeDeep(imp.video, { + ext: { rewarded: bidRequest.mediaTypes.video.ext.rewarded }, + }) + } + if (siteId || pageId || formatId) { const bidder = {}; diff --git a/test/spec/modules/equativBidAdapter_spec.js b/test/spec/modules/equativBidAdapter_spec.js index 2f3143ea9ff..af377f53eac 100644 --- a/test/spec/modules/equativBidAdapter_spec.js +++ b/test/spec/modules/equativBidAdapter_spec.js @@ -55,6 +55,7 @@ describe('Equativ bid adapter tests', () => { startdelay: 42, battr: [13, 14], placement: 1, + ext: { rewarded: 1 }, }, }, bidder: 'equativ', @@ -160,6 +161,7 @@ describe('Equativ bid adapter tests', () => { expect(videoObj).to.have.property('startdelay').and.to.equal(42); expect(videoObj).to.have.property('battr').and.to.deep.equal([13, 14]); expect(videoObj).to.have.property('placement').and.to.equal(1); + expect(videoObj).to.have.property('ext').and.to.deep.equal({ rewarded: 1 }); }); it('should warn about missing required properties', () => { From c1a2e63a8d7d236b6afdcd04d5bc6229e162a61e Mon Sep 17 00:00:00 2001 From: Jeff Mahoney Date: Tue, 29 Oct 2024 22:02:32 -0400 Subject: [PATCH 28/33] SADR-6484: test revision + not sending bid requests where video obj is empty --- modules/equativBidAdapter.js | 25 ++++++++++-- test/spec/modules/equativBidAdapter_spec.js | 44 ++++++++++++++++++--- 2 files changed, 61 insertions(+), 8 deletions(-) diff --git a/modules/equativBidAdapter.js b/modules/equativBidAdapter.js index 869d3c6296b..f26a8d78852 100644 --- a/modules/equativBidAdapter.js +++ b/modules/equativBidAdapter.js @@ -1,10 +1,25 @@ import { ortbConverter } from '../libraries/ortbConverter/converter.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { BANNER, VIDEO } from '../src/mediaTypes.js'; -import { deepAccess, deepSetValue, isFn, logWarn, mergeDeep } from '../src/utils.js'; +import { deepAccess, deepSetValue, isFn, logError, logWarn, mergeDeep } from '../src/utils.js'; const LOG_PREFIX = 'Equativ:'; +/** + * Evaluates a bid request for validity. Returns false if the + * request contains a video media type with no properties, true + * otherwise. + * @param {*} bidReq - A bid request object to evaluate + * @returns boolean + */ +function isValid(bidReq){ + if (bidReq.mediaTypes.video && JSON.stringify(bidReq.mediaTypes.video) === '{}') { + return false; + } else { + return true; + } +} + /** * @typedef {import('../src/adapters/bidderFactory.js').Bid} Bid * @typedef {import('../src/adapters/bidderFactory.js').ServerRequest} ServerRequest @@ -21,6 +36,10 @@ export const spec = { * @returns {ServerRequest[]} */ buildRequests: (bidRequests, bidderRequest) => { + if (bidRequests.filter(isValid).length === 0) { + logError(`${LOG_PREFIX} No useful bid requests to process. No request will be sent.`, bidRequests); + return undefined + } return { data: converter.toORTB({ bidderRequest, bidRequests }), method: 'POST', @@ -156,10 +175,10 @@ export const converter = ortbConverter({ } if (bid.mediaTypes.video && !bid.mediaTypes.video.mimes) { - logWarn(`${LOG_PREFIX} Property "mimes" is missing from request`, bid); + logWarn(`${LOG_PREFIX} Property "mimes" is missing from request`, bid); // TODO: SADR-6484: message OK? Should it say something else? } if (bid.mediaTypes.video && !bid.mediaTypes.video.placement) { - logWarn(`${LOG_PREFIX} Property "placement" is missing from request`, bid); + logWarn(`${LOG_PREFIX} Property "placement" is missing from request`, bid); // TODO: SADR-6484: message OK? Should it say something else? } return req; diff --git a/test/spec/modules/equativBidAdapter_spec.js b/test/spec/modules/equativBidAdapter_spec.js index af377f53eac..84bac6e02d9 100644 --- a/test/spec/modules/equativBidAdapter_spec.js +++ b/test/spec/modules/equativBidAdapter_spec.js @@ -5,6 +5,7 @@ describe('Equativ bid adapter tests', () => { let sandBox; beforeEach(() => { sandBox = sinon.createSandbox(); + sandBox.stub(utils, 'logError'); sandBox.stub(utils, 'logWarn'); }); afterEach(() => { @@ -132,7 +133,7 @@ describe('Equativ bid adapter tests', () => { }); }); - it('should build a video request properly', () => { + it('should build a video request properly under normal circumstances', () => { // ASSEMBLE const videoRequest = DEFAULT_BID_REQUESTS[1]; const bidRequests = [ @@ -164,17 +165,18 @@ describe('Equativ bid adapter tests', () => { expect(videoObj).to.have.property('ext').and.to.deep.equal({ rewarded: 1 }); }); - it('should warn about missing required properties', () => { + it('should warn about missing required properties for video requests', () => { // ASSEMBLE - const vidReqWithMissingProps = DEFAULT_BID_REQUESTS.map((req) => { + const missingRequiredVideoRequest = DEFAULT_BID_REQUESTS.map((req) => { if (req.mediaTypes.video) { + // removing required properties delete req.mediaTypes.video.mimes; - delete req.placement; + delete req.mediaTypes.video.placement; } return req; })[1] const bidRequests = [ - { ...vidReqWithMissingProps, params: { siteId: 123 } }, + { ...missingRequiredVideoRequest, params: { siteId: 123 } }, ]; const bidderRequest = { ...DEFAULT_BIDDER_REQUEST, bids: bidRequests }; @@ -185,6 +187,38 @@ describe('Equativ bid adapter tests', () => { expect(utils.logWarn.called).to.equal(true) }) + it('should not send a video request when it has an empty body and no other impressions with any media types are defined', () => { + // ASSEMBLE + const emptyVideoRequest = DEFAULT_BID_REQUESTS.map((req) => { + if (req.mediaTypes.video) { + // simulating + /* + pbjs.addAdUnits([{ + mediaTypes: { + video: { + } + }, + ... + }]); + */ + req.mediaTypes.video = {} + } + return req; + })[1] // just grab the video request - that's all we need for this test + + const bidRequests = [ + { ...emptyVideoRequest, params: { siteId: 123 } }, + ]; + const bidderRequest = { ...DEFAULT_BIDDER_REQUEST, bids: bidRequests }; + + // ACT + const request = spec.buildRequests([], bidderRequest); + + // ASSERT + expect(utils.logError.called).to.equal(true) + expect(request).to.be.undefined; + }); + it('should add ext.bidder to imp object when siteId is defined', () => { const bidRequests = [ { ...DEFAULT_BID_REQUESTS[0], params: { siteId: 123 } }, From 4be5f71d766f3b1fb18d56b477e6afe6c9a2738c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Sok=C3=B3=C5=82?= Date: Fri, 15 Nov 2024 11:06:18 +0100 Subject: [PATCH 29/33] refactoring and u.t. --- modules/equativBidAdapter.js | 88 +-- src/ajax.js | 4 - test/spec/modules/equativBidAdapter_spec.js | 751 +++++++------------- 3 files changed, 274 insertions(+), 569 deletions(-) diff --git a/modules/equativBidAdapter.js b/modules/equativBidAdapter.js index e9ed7e6fc70..2a176582d42 100644 --- a/modules/equativBidAdapter.js +++ b/modules/equativBidAdapter.js @@ -1,27 +1,10 @@ -import { getBidFloor } from '../libraries/equativUtils/equativUtils.js' -import { ortbConverter } from '../libraries/ortbConverter/converter.js'; import { BANNER, VIDEO } from '../src/mediaTypes.js'; +import { getBidFloor } from '../libraries/equativUtils/equativUtils.js' import { getStorageManager } from '../src/storageManager.js'; +import { ortbConverter } from '../libraries/ortbConverter/converter.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { deepAccess, deepSetValue, logError, logWarn, mergeDeep } from '../src/utils.js'; -const LOG_PREFIX = 'Equativ:'; - -/** - * Evaluates a bid request for validity. Returns false if the - * request contains a video media type with no properties, true - * otherwise. - * @param {*} bidReq - A bid request object to evaluate - * @returns boolean - */ -function isValid(bidReq) { - if (bidReq.mediaTypes.video && JSON.stringify(bidReq.mediaTypes.video) === '{}') { - return false; - } else { - return true; - } -} - /** * @typedef {import('../src/adapters/bidderFactory.js').Bid} Bid * @typedef {import('../src/adapters/bidderFactory.js').ServerRequest} ServerRequest @@ -30,8 +13,20 @@ function isValid(bidReq) { const BIDDER_CODE = 'equativ'; const COOKIE_SYNC_ORIGIN = 'https://apps.smartadserver.com'; const COOKIE_SYNC_URL = `${COOKIE_SYNC_ORIGIN}/diff/templates/asset/csync.html`; +const LOG_PREFIX = 'Equativ:'; const PID_COOKIE_NAME = 'eqt_pid'; +/** + * Evaluates a bid request for validity. Returns false if the + * request contains a video media type with no properties, true + * otherwise. + * @param {*} bidReq A bid request object to evaluate + * @returns boolean + */ +function isValid(bidReq) { + return !(bidReq.mediaTypes.video && JSON.stringify(bidReq.mediaTypes.video) === '{}'); +} + export const storage = getStorageManager({ bidderCode: BIDDER_CODE }); export const spec = { @@ -47,13 +42,14 @@ export const spec = { buildRequests: (bidRequests, bidderRequest) => { if (bidRequests.filter(isValid).length === 0) { logError(`${LOG_PREFIX} No useful bid requests to process. No request will be sent.`, bidRequests); - return undefined + return undefined; } + return { data: converter.toORTB({ bidderRequest, bidRequests }), method: 'POST', // url: 'https://ssb-engine-argocd-dev.internal.smartadserver.com/api/bid?callerId=169' - url: 'https://ssb-global.smartadserver.com/api/bid?callerId=169' + url: 'https://ssb-global.smartadserver.com/api/bid?callerId=169', }; }, @@ -119,30 +115,13 @@ export const converter = ortbConverter({ imp.secure = 1; imp.tagid = bidRequest.adUnitCode; - if (bidRequest.mediaTypes.video && !!bidRequest.mediaTypes.video.ext.rewarded) { - mergeDeep(imp.video, { - ext: { rewarded: bidRequest.mediaTypes.video.ext.rewarded }, - }) + if (!deepAccess(bidRequest, 'ortb2Imp.rwdd') && deepAccess(bidRequest, 'mediaTypes.video.ext.rewarded')) { + mergeDeep(imp, { rwdd: bidRequest.mediaTypes.video.ext.rewarded }); } - if (siteId || pageId || formatId) { - const bidder = {}; - - if (siteId) { - bidder.siteId = siteId; - } - - if (pageId) { - bidder.pageId = pageId; - } - - if (formatId) { - bidder.formatId = formatId; - } - - mergeDeep(imp, { - ext: { bidder }, - }); + const bidder = { ...(siteId && { siteId }), ...(pageId && { pageId }), ...(formatId && { formatId }) }; + if (Object.keys(bidder).length) { + mergeDeep(imp.ext, { bidder }); } return imp; @@ -152,22 +131,17 @@ export const converter = ortbConverter({ const bid = context.bidRequests[0]; const req = buildRequest(imps, bidderRequest, context); - if (deepAccess(bid, 'ortb2.site.publisher')) { - deepSetValue(req, 'site.publisher.id', bid.ortb2.site.publisher.id || bid.params.networkId); - } else if (deepAccess(bid, 'ortb2.app.publisher')) { - deepSetValue(req, 'app.publisher.id', bid.ortb2.app.publisher.id || bid.params.networkId); - } else if (deepAccess(bid, 'ortb2.dooh.publisher')) { - deepSetValue(req, 'dooh.publisher.id', bid.ortb2.dooh.publisher.id || bid.params.networkId); - } else { - deepSetValue(req, 'site.publisher.id', bid.params.networkId); - } + let env = ['ortb2.site.publisher', 'ortb2.app.publisher', 'ortb2.dooh.publisher'].find(env => deepAccess(bid, env)) || 'ortb2.site.publisher'; + deepSetValue(req, env.replace('ortb2.', '') + '.id', deepAccess(bid, env + '.id') || bid.params.networkId); - if (bid.mediaTypes.video && !bid.mediaTypes.video.mimes) { - logWarn(`${LOG_PREFIX} Property "mimes" is missing from request`, bid); // TODO: SADR-6484: message OK? Should it say something else? - } - if (bid.mediaTypes.video && !bid.mediaTypes.video.placement) { - logWarn(`${LOG_PREFIX} Property "placement" is missing from request`, bid); // TODO: SADR-6484: message OK? Should it say something else? + if (deepAccess(bid, 'mediaTypes.video')) { + ['mimes', 'placement'].forEach(prop => { + if (!bid.mediaTypes.video[prop]) { + logWarn(`${LOG_PREFIX} Property "${prop}" is missing from request`, bid); + } + }); } + const pid = storage.getCookie(PID_COOKIE_NAME); if (pid) { deepSetValue(req, 'user.buyeruid', pid); diff --git a/src/ajax.js b/src/ajax.js index c018f9d5ce9..8792da48fed 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -37,10 +37,6 @@ export function toFetchRequest(url, data, options = {}) { } const headers = new Headers(options.customHeaders); headers.set(CTYPE, options.contentType || 'text/plain'); - // TODO: SADR-6484: remove this (if statement below) after testing - if (url === 'https://ssb-engine-argocd-dev.internal.smartadserver.com/api/bid?callerId=169') { - headers.set('X-Eqtv-Debug', '671a49bebd18e71ead36f0a1'); - } const rqOpts = { method, headers diff --git a/test/spec/modules/equativBidAdapter_spec.js b/test/spec/modules/equativBidAdapter_spec.js index ff4dd556ea1..f113bb0605c 100644 --- a/test/spec/modules/equativBidAdapter_spec.js +++ b/test/spec/modules/equativBidAdapter_spec.js @@ -4,7 +4,17 @@ import { converter, spec, storage } from 'modules/equativBidAdapter.js'; import * as utils from '../../../src/utils.js'; describe('Equativ bid adapter tests', () => { - const DEFAULT_BID_REQUESTS = [ + let sandBox; + + beforeEach(() => { + sandBox = sinon.createSandbox(); + sandBox.stub(utils, 'logError'); + sandBox.stub(utils, 'logWarn'); + }); + + afterEach(() => sandBox.restore()); + + const DEFAULT_BANNER_BID_REQUESTS = [ { adUnitCode: 'eqtv_42', bidId: 'abcd1234', @@ -26,12 +36,56 @@ describe('Equativ bid adapter tests', () => { tid: 'zsfgzzg', }, }, - }, + } + ]; + + const DEFAULT_VIDEO_BID_REQUESTS = [ + { + adUnitCode: 'eqtv_43', + bidId: 'efgh5678', + mediaTypes: { + video: { + context: 'instream', + playerSize: [[640, 480]], + pos: 3, + skip: 1, + linearity: 1, + minduration: 10, + maxduration: 30, + minbitrate: 300, + maxbitrate: 600, + w: 640, + h: 480, + playbackmethod: [1], + api: [3], + mimes: ['video/x-flv', 'video/mp4'], + // protocols: [2, 3], // used in older adapter ... including as comment for reference + startdelay: 42, + battr: [13, 14], + placement: 1, + }, + }, + bidder: 'equativ', + params: { + networkId: 111, + }, + requestId: 'abcd1234', + ortb2Imp: { + ext: { + tid: 'zsgzgzz', + }, + }, + } ]; - const DEFAULT_BIDDER_REQUEST = { + const DEFAULT_BANNER_BIDDER_REQUEST = { + bidderCode: 'equativ', + bids: DEFAULT_BANNER_BID_REQUESTS, + }; + + const DEFAULT_VIDEO_BIDDER_REQUEST = { bidderCode: 'equativ', - bids: DEFAULT_BID_REQUESTS, + bids: DEFAULT_VIDEO_BID_REQUESTS, }; const SAMPLE_RESPONSE = { @@ -66,12 +120,12 @@ describe('Equativ bid adapter tests', () => { describe('buildRequests', () => { it('should build correct request using ORTB converter', () => { const request = spec.buildRequests( - DEFAULT_BID_REQUESTS, - DEFAULT_BIDDER_REQUEST + DEFAULT_BANNER_BID_REQUESTS, + DEFAULT_BANNER_BIDDER_REQUEST ); const dataFromConverter = converter.toORTB({ - bidderRequest: DEFAULT_BIDDER_REQUEST, - bidRequests: DEFAULT_BID_REQUESTS, + bidderRequest: DEFAULT_BANNER_BIDDER_REQUEST, + bidRequests: DEFAULT_BANNER_BID_REQUESTS, }); expect(request).to.deep.equal({ data: { ...dataFromConverter, id: request.data.id }, @@ -82,9 +136,9 @@ describe('Equativ bid adapter tests', () => { it('should add ext.bidder to imp object when siteId is defined', () => { const bidRequests = [ - { ...DEFAULT_BID_REQUESTS[0], params: { siteId: 123 } }, + { ...DEFAULT_BANNER_BID_REQUESTS[0], params: { siteId: 123 } }, ]; - const bidderRequest = { ...DEFAULT_BIDDER_REQUEST, bids: bidRequests }; + const bidderRequest = { ...DEFAULT_BANNER_BIDDER_REQUEST, bids: bidRequests }; const request = spec.buildRequests(bidRequests, bidderRequest); expect(request.data.imp[0].ext.bidder).to.deep.equal({ siteId: 123, @@ -93,9 +147,9 @@ describe('Equativ bid adapter tests', () => { it('should add ext.bidder to imp object when pageId is defined', () => { const bidRequests = [ - { ...DEFAULT_BID_REQUESTS[0], params: { pageId: 123 } }, + { ...DEFAULT_BANNER_BID_REQUESTS[0], params: { pageId: 123 } }, ]; - const bidderRequest = { ...DEFAULT_BIDDER_REQUEST, bids: bidRequests }; + const bidderRequest = { ...DEFAULT_BANNER_BIDDER_REQUEST, bids: bidRequests }; const request = spec.buildRequests(bidRequests, bidderRequest); expect(request.data.imp[0].ext.bidder).to.deep.equal({ pageId: 123, @@ -104,9 +158,9 @@ describe('Equativ bid adapter tests', () => { it('should add ext.bidder to imp object when formatId is defined', () => { const bidRequests = [ - { ...DEFAULT_BID_REQUESTS[0], params: { formatId: 123 } }, + { ...DEFAULT_BANNER_BID_REQUESTS[0], params: { formatId: 123 } }, ]; - const bidderRequest = { ...DEFAULT_BIDDER_REQUEST, bids: bidRequests }; + const bidderRequest = { ...DEFAULT_BANNER_BIDDER_REQUEST, bids: bidRequests }; const request = spec.buildRequests(bidRequests, bidderRequest); expect(request.data.imp[0].ext.bidder).to.deep.equal({ formatId: 123, @@ -114,23 +168,23 @@ describe('Equativ bid adapter tests', () => { }); it('should not add ext.bidder to imp object when siteId, pageId, formatId are not defined', () => { - const bidRequests = [{ ...DEFAULT_BID_REQUESTS[0], params: {} }]; - const bidderRequest = { ...DEFAULT_BIDDER_REQUEST, bids: bidRequests }; + const bidRequests = [{ ...DEFAULT_BANNER_BID_REQUESTS[0], params: {} }]; + const bidderRequest = { ...DEFAULT_BANNER_BIDDER_REQUEST, bids: bidRequests }; const request = spec.buildRequests(bidRequests, bidderRequest); expect(request.data.imp[0].ext.bidder).to.be.undefined; }); it('should add site.publisher.id param', () => { const request = spec.buildRequests( - DEFAULT_BID_REQUESTS, - DEFAULT_BIDDER_REQUEST + DEFAULT_BANNER_BID_REQUESTS, + DEFAULT_BANNER_BIDDER_REQUEST ); expect(request.data.site.publisher.id).to.equal(111); }); it('should pass ortb2.site.publisher.id', () => { const bidRequests = [{ - ...DEFAULT_BID_REQUESTS[0], + ...DEFAULT_BANNER_BID_REQUESTS[0], ortb2: { site: { publisher: { @@ -140,28 +194,28 @@ describe('Equativ bid adapter tests', () => { } }]; delete bidRequests[0].params; - const bidderRequest = { ...DEFAULT_BIDDER_REQUEST, bids: bidRequests }; + const bidderRequest = { ...DEFAULT_BANNER_BIDDER_REQUEST, bids: bidRequests }; const request = spec.buildRequests(bidRequests, bidderRequest); expect(request.data.site.publisher.id).to.equal(98); }); it('should pass networkId as site.publisher.id', () => { const bidRequests = [{ - ...DEFAULT_BID_REQUESTS[0], + ...DEFAULT_BANNER_BID_REQUESTS[0], ortb2: { site: { publisher: {} } } }]; - const bidderRequest = { ...DEFAULT_BIDDER_REQUEST, bids: bidRequests }; + const bidderRequest = { ...DEFAULT_BANNER_BIDDER_REQUEST, bids: bidRequests }; const request = spec.buildRequests(bidRequests, bidderRequest); expect(request.data.site.publisher.id).to.equal(111); }); it('should pass ortb2.app.publisher.id', () => { const bidRequests = [{ - ...DEFAULT_BID_REQUESTS[0], + ...DEFAULT_BANNER_BID_REQUESTS[0], ortb2: { app: { publisher: { @@ -171,28 +225,28 @@ describe('Equativ bid adapter tests', () => { } }]; delete bidRequests[0].params; - const bidderRequest = { ...DEFAULT_BIDDER_REQUEST, bids: bidRequests }; + const bidderRequest = { ...DEFAULT_BANNER_BIDDER_REQUEST, bids: bidRequests }; const request = spec.buildRequests(bidRequests, bidderRequest); expect(request.data.app.publisher.id).to.equal(27); }); it('should pass networkId as app.publisher.id', () => { const bidRequests = [{ - ...DEFAULT_BID_REQUESTS[0], + ...DEFAULT_BANNER_BID_REQUESTS[0], ortb2: { app: { publisher: {} } } }]; - const bidderRequest = { ...DEFAULT_BIDDER_REQUEST, bids: bidRequests }; + const bidderRequest = { ...DEFAULT_BANNER_BIDDER_REQUEST, bids: bidRequests }; const request = spec.buildRequests(bidRequests, bidderRequest); expect(request.data.app.publisher.id).to.equal(111); }); it('should pass ortb2.dooh.publisher.id', () => { const bidRequests = [{ - ...DEFAULT_BID_REQUESTS[0], + ...DEFAULT_BANNER_BID_REQUESTS[0], ortb2: { dooh: { publisher: { @@ -202,54 +256,54 @@ describe('Equativ bid adapter tests', () => { } }]; delete bidRequests[0].params; - const bidderRequest = { ...DEFAULT_BIDDER_REQUEST, bids: bidRequests }; + const bidderRequest = { ...DEFAULT_BANNER_BIDDER_REQUEST, bids: bidRequests }; const request = spec.buildRequests(bidRequests, bidderRequest); expect(request.data.dooh.publisher.id).to.equal(35); }); it('should pass networkId as dooh.publisher.id', () => { const bidRequests = [{ - ...DEFAULT_BID_REQUESTS[0], + ...DEFAULT_BANNER_BID_REQUESTS[0], ortb2: { dooh: { publisher: {} } } }]; - const bidderRequest = { ...DEFAULT_BIDDER_REQUEST, bids: bidRequests }; + const bidderRequest = { ...DEFAULT_BANNER_BIDDER_REQUEST, bids: bidRequests }; const request = spec.buildRequests(bidRequests, bidderRequest); expect(request.data.dooh.publisher.id).to.equal(111); }); it('should send default floor of 0.0', () => { const request = spec.buildRequests( - DEFAULT_BID_REQUESTS, - DEFAULT_BIDDER_REQUEST + DEFAULT_BANNER_BID_REQUESTS, + DEFAULT_BANNER_BIDDER_REQUEST ); expect(request.data.imp[0]).to.have.property('bidfloor').that.eq(0.0); }); it('should send secure connection', () => { const request = spec.buildRequests( - DEFAULT_BID_REQUESTS, - DEFAULT_BIDDER_REQUEST + DEFAULT_BANNER_BID_REQUESTS, + DEFAULT_BANNER_BIDDER_REQUEST ); expect(request.data.imp[0]).to.have.property('secure').that.eq(1); }); it('should have tagid', () => { const request = spec.buildRequests( - DEFAULT_BID_REQUESTS, - DEFAULT_BIDDER_REQUEST + DEFAULT_BANNER_BID_REQUESTS, + DEFAULT_BANNER_BIDDER_REQUEST ); - expect(request.data.imp[0]).to.have.property('tagid').that.eq(DEFAULT_BID_REQUESTS[0].adUnitCode); + expect(request.data.imp[0]).to.have.property('tagid').that.eq(DEFAULT_BANNER_BID_REQUESTS[0].adUnitCode); }); it('should remove dt', () => { const bidRequests = [ - { ...DEFAULT_BID_REQUESTS[0], ortb2Imp: { dt: 1728377558235 } } + { ...DEFAULT_BANNER_BID_REQUESTS[0], ortb2Imp: { dt: 1728377558235 } } ]; - const bidderRequest = { ...DEFAULT_BIDDER_REQUEST, bids: bidRequests }; + const bidderRequest = { ...DEFAULT_BANNER_BIDDER_REQUEST, bids: bidRequests }; const request = spec.buildRequests(bidRequests, bidderRequest); expect(request.data.imp[0]).to.not.have.property('dt'); }); @@ -262,8 +316,8 @@ describe('Equativ bid adapter tests', () => { getCookieStub.callsFake(cookieName => cookieData[cookieName]); const request = spec.buildRequests( - DEFAULT_BID_REQUESTS, - DEFAULT_BIDDER_REQUEST + DEFAULT_BANNER_BID_REQUESTS, + DEFAULT_BANNER_BIDDER_REQUEST ); expect(request.data.user).to.have.property('buyeruid').that.eq(cookieData['eqt_pid']); @@ -276,8 +330,8 @@ describe('Equativ bid adapter tests', () => { getCookieStub.callsFake(() => null); const request = spec.buildRequests( - DEFAULT_BID_REQUESTS, - DEFAULT_BIDDER_REQUEST + DEFAULT_BANNER_BID_REQUESTS, + DEFAULT_BANNER_BIDDER_REQUEST ); expect(request.data).to.not.have.property('user'); @@ -290,25 +344,163 @@ describe('Equativ bid adapter tests', () => { getCookieStub.callsFake(() => undefined); const bidRequest = { - ...DEFAULT_BIDDER_REQUEST, + ...DEFAULT_BANNER_BIDDER_REQUEST, ortb2: { user: { buyeruid: 'buyeruid-provided-by-publisher' } } }; - const request = spec.buildRequests([ DEFAULT_BID_REQUESTS[0] ], bidRequest); + const request = spec.buildRequests([ DEFAULT_BANNER_BID_REQUESTS[0] ], bidRequest); expect(request.data.user.buyeruid).to.deep.eq(bidRequest.ortb2.user.buyeruid); getCookieStub.restore(); }); + + it('should build a video request properly under normal circumstances', () => { + // ASSEMBLE + if (FEATURES.VIDEO) { + // ACT + const request = spec.buildRequests(DEFAULT_VIDEO_BID_REQUESTS, {}).data; + + // ASSERT + expect(request.imp[0]).to.have.property('video'); + + const videoObj = request.imp[0].video; + + expect(videoObj).to.have.property('api').and.to.deep.equal([3]); + expect(videoObj).to.have.property('battr').and.to.deep.equal([13, 14]); + expect(videoObj).to.have.property('linearity').and.to.equal(1); + expect(videoObj).to.have.property('mimes').and.to.deep.equal(['video/x-flv', 'video/mp4']); + expect(videoObj).to.have.property('minbitrate').and.to.equal(300); + expect(videoObj).to.have.property('maxbitrate').and.to.equal(600); + expect(videoObj).to.have.property('minduration').and.to.equal(10); + expect(videoObj).to.have.property('maxduration').and.to.equal(30); + expect(videoObj).to.have.property('placement').and.to.equal(1); + expect(videoObj).to.have.property('playbackmethod').and.to.deep.equal([1]); + expect(videoObj).to.have.property('pos').and.to.equal(3); + expect(videoObj).to.have.property('skip').and.to.equal(1); + expect(videoObj).to.have.property('startdelay').and.to.equal(42); + expect(videoObj).to.have.property('w').and.to.equal(640); + expect(videoObj).to.have.property('h').and.to.equal(480); + expect(videoObj).not.to.have.property('ext'); + } + }); + + it('should read and pass ortb2Imp.rwdd', () => { + // ASSEMBLE + if (FEATURES.VIDEO) { + const bidRequestsWithOrtb2ImpRwdd = [ + { + ...DEFAULT_VIDEO_BID_REQUESTS[0], + ortb2Imp: { + rwdd: 1 + } + } + ]; + // ACT + const request = spec.buildRequests(bidRequestsWithOrtb2ImpRwdd, {}).data; + + // ASSERT + expect(request.imp[0]).to.have.property('rwdd').and.to.equal(1); + } + }); + + it('should read mediaTypes.video.ext.rewarded and pass as rwdd', () => { + // ASSEMBLE + if (FEATURES.VIDEO) { + const bidRequestsWithExtReworded = [ + { + ...DEFAULT_VIDEO_BID_REQUESTS[0], + mediaTypes: { + video: { + ext: { + rewarded: 1 + } + } + } + } + ]; + // ACT + const request = spec.buildRequests(bidRequestsWithExtReworded, {}).data; + + // ASSERT + expect(request.imp[0]).to.have.property('rwdd').and.to.equal(1); + } + }); + + it('should prioritize ortb2Imp.rwdd over mediaTypes.video.ext.rewarded', () => { + // ASSEMBLE + if (FEATURES.VIDEO) { + const bidRequestsWithBothRewordedParams = [ + { + ...DEFAULT_VIDEO_BID_REQUESTS[0], + mediaTypes: { + video: { + ext: { + rewarded: 1 + } + } + }, + ortb2Imp: { + rwdd: 2 + } + } + ]; + // ACT + const request = spec.buildRequests(bidRequestsWithBothRewordedParams, {}).data; + + // ASSERT + expect(request.imp[0]).to.have.property('rwdd').and.to.equal(2); + } + }); + + it('should warn about missing required properties for video requests', () => { + // ASSEMBLE + const missingRequiredVideoRequest = DEFAULT_VIDEO_BID_REQUESTS[0]; + + // removing required properties + delete missingRequiredVideoRequest.mediaTypes.video.mimes; + delete missingRequiredVideoRequest.mediaTypes.video.placement; + + const bidRequests = [ missingRequiredVideoRequest ]; + const bidderRequest = { ...DEFAULT_VIDEO_BIDDER_REQUEST, bids: bidRequests }; + + // ACT + spec.buildRequests(bidRequests, bidderRequest); + + // ASSERT + expect(utils.logWarn.callCount).to.equal(2); + expect(utils.logWarn.getCall(0).args[0]).to.satisfy(arg => arg.includes('"mimes" is missing')); + expect(utils.logWarn.getCall(1).args[0]).to.satisfy(arg => arg.includes('"placement" is missing')); + }); + + it('should not send a video request when it has an empty body and no other impressions with any media types are defined', () => { + // ASSEMBLE + const emptyVideoRequest = { + ...DEFAULT_VIDEO_BID_REQUESTS[0], + mediaTypes: { + video: {} + } + }; + const bidRequests = [ emptyVideoRequest ]; + const bidderRequest = { ...DEFAULT_VIDEO_BIDDER_REQUEST, bids: bidRequests }; + + // ACT + const request = spec.buildRequests(bidRequests, bidderRequest); + + // ASSERT + expect(utils.logError.calledOnce).to.equal(true); + expect(utils.logError.args[0][0]).to.satisfy(arg => arg.includes('No request')); + expect(request).to.be.undefined; + }); }); describe('getBidFloor', () => { it('should return floor of 0.0 if floor module not available', () => { const bid = { - ...DEFAULT_BID_REQUESTS[0], + ...DEFAULT_BANNER_BID_REQUESTS[0], getFloor: false, }; expect(getBidFloor(bid)).to.deep.eq(0.0); @@ -324,7 +516,7 @@ describe('Equativ bid adapter tests', () => { it('should return proper min floor', () => { const bid = { - ...DEFAULT_BID_REQUESTS[0], + ...DEFAULT_BANNER_BID_REQUESTS[0], getFloor: data => { if (data.size[0] === 300 && data.size[1] === 250) { return { floor: 1.13 }; @@ -340,7 +532,7 @@ describe('Equativ bid adapter tests', () => { it('should return global media type floor if no rule for size', () => { const bid = { - ...DEFAULT_BID_REQUESTS[0], + ...DEFAULT_BANNER_BID_REQUESTS[0], getFloor: data => { if (data.size[0] === 728 && data.size[1] === 90) { return { floor: 1.13 }; @@ -356,7 +548,7 @@ describe('Equativ bid adapter tests', () => { it('should return floor of 0 if no rule for size', () => { const bid = { - ...DEFAULT_BID_REQUESTS[0], + ...DEFAULT_BANNER_BID_REQUESTS[0], getFloor: data => { if (data.size[0] === 728 && data.size[1] === 90) { return { floor: 1.13 }; @@ -460,465 +652,8 @@ describe('Equativ bid adapter tests', () => { describe('interpretResponse', () => { it('should return data returned by ORTB converter', () => { const request = spec.buildRequests( - DEFAULT_BID_REQUESTS, - DEFAULT_BIDDER_REQUEST - ); - const bids = spec.interpretResponse(SAMPLE_RESPONSE, request); - expect(bids).to.deep.equal( - converter.fromORTB({ - request: request.data, - response: SAMPLE_RESPONSE.body, - }) - ); - }); - }); - - describe('isBidRequestValid', () => { - it('should return true if params.networkId is set', () => { - const bidRequest = { - params: { - networkId: 123, - }, - }; - expect(spec.isBidRequestValid(bidRequest)).to.equal(true); - }); - - it('should return true if ortb2.site.publisher.id is set', () => { - const bidRequest = { - ortb2: { - site: { - publisher: { - id: 123, - }, - }, - }, - }; - expect(spec.isBidRequestValid(bidRequest)).to.equal(true); - }); - - it('should return true if ortb2.app.publisher.id is set', () => { - const bidRequest = { - ortb2: { - app: { - publisher: { - id: 123, - }, - }, - }, - }; - expect(spec.isBidRequestValid(bidRequest)).to.equal(true); - }); - - it('should return true if ortb2.dooh.publisher.id is set', () => { - const bidRequest = { - ortb2: { - dooh: { - publisher: { - id: 123, - }, - }, - }, - }; - expect(spec.isBidRequestValid(bidRequest)).to.equal(true); - }); - - it('should return false if networkId is not set', () => { - const bidRequest = {}; - expect(spec.isBidRequestValid(bidRequest)).to.equal(false); - }); - }); -}); - -describe('Equativ bid adapter tests', () => { - let sandBox; - beforeEach(() => { - sandBox = sinon.createSandbox(); - sandBox.stub(utils, 'logError'); - sandBox.stub(utils, 'logWarn'); - }); - afterEach(() => { - sandBox.restore(); - }); - - const DEFAULT_BID_REQUESTS = [ - { - adUnitCode: 'eqtv_42', - bidId: 'abcd1234', - mediaTypes: { - banner: { - sizes: [ - [300, 250], - [300, 600], - ], - }, - }, - bidder: 'equativ', - params: { - networkId: 111, - }, - requestId: 'efgh5678', - ortb2Imp: { - ext: { - tid: 'zsfgzzg', - }, - }, - }, - { - adUnitCode: 'eqtv_43', - bidId: 'efgh5678', - mediaTypes: { - video: { - pos: 3, - skip: 1, - linearity: 1, - minduration: 10, - maxduration: 30, - minbitrate: 300, - maxbitrate: 600, - w: 640, - h: 480, - playbackmethod: [1], - api: [3], - mimes: ['video/x-flv'], - // protocols: [2, 3], // used in older adapter ... including as comment for reference - startdelay: 42, - battr: [13, 14], - placement: 1, - ext: { rewarded: 1 }, - }, - }, - bidder: 'equativ', - params: { - networkId: 111, - }, - requestId: 'abcd1234', - ortb2Imp: { - ext: { - tid: 'zsgzgzz', - }, - }, - } - ]; - - const DEFAULT_BIDDER_REQUEST = { - bidderCode: 'equativ', - bids: DEFAULT_BID_REQUESTS, - }; - - const SAMPLE_RESPONSE = { - body: { - id: '12h712u7-k22g-8124-ab7a-h268s22dy271', - seatbid: [ - { - bid: [ - { - id: '1bh7jku7-ko2g-8654-ab72-h268shvwy271', - impid: 'r12gwgf231', - price: 0.6565, - adm: '

AD

', - adomain: ['abc.com'], - cid: '1242512', - crid: '535231', - w: 300, - h: 600, - mtype: 1, - cat: ['IAB19', 'IAB19-1'], - cattax: 1, - }, - ], - seat: '4212', - }, - ], - cur: 'USD', - statuscode: 0, - }, - }; - - describe('buildRequests', () => { - const ENDPOINT = 'https://ssb-global.smartadserver.com/api/bid?callerId=169'; - - it('should build correct request using ORTB converter', () => { - const request = spec.buildRequests( - DEFAULT_BID_REQUESTS, - DEFAULT_BIDDER_REQUEST - ); - const dataFromConverter = converter.toORTB({ - bidderRequest: DEFAULT_BIDDER_REQUEST, - bidRequests: DEFAULT_BID_REQUESTS, - }); - expect(request).to.deep.equal({ - data: { ...dataFromConverter, id: request.data.id }, - method: 'POST', - url: ENDPOINT, - }); - }); - - // it('should build a video request properly under normal circumstances', () => { - // // ASSEMBLE - // const videoRequest = DEFAULT_BID_REQUESTS[1]; - // const bidRequests = [ - // { ...videoRequest, params: { siteId: 123 } }, - // ]; - // const bidderRequest = { ...DEFAULT_BIDDER_REQUEST, bids: bidRequests }; - - // // ACT - // const request = spec.buildRequests(bidRequests, bidderRequest); - - // // ASSERT - // const videoObj = request.data.imp[0].video; - // expect(videoObj).to.have.property('pos').and.to.equal(3); - // expect(videoObj).to.have.property('skip').and.to.equal(1); - // expect(videoObj).to.have.property('linearity').and.to.equal(1); - // expect(videoObj).to.have.property('minduration').and.to.equal(10); - // expect(videoObj).to.have.property('maxduration').and.to.equal(30); - // expect(videoObj).to.have.property('minbitrate').and.to.equal(300); - // expect(videoObj).to.have.property('maxbitrate').and.to.equal(600); - // expect(videoObj).to.have.property('w').and.to.equal(640); - // expect(videoObj).to.have.property('h').and.to.equal(480); - // expect(videoObj).to.have.property('playbackmethod').and.to.deep.equal([1]); - // expect(videoObj).to.have.property('api').and.to.deep.equal([3]); - // expect(videoObj).to.have.property('mimes').and.to.deep.equal(['video/x-flv']); - // // expect(videoObj).to.have.property('protocols').and.to.deep.equal([2, 3]); // used in older adapter ... including as comment for reference - // expect(videoObj).to.have.property('startdelay').and.to.equal(42); - // expect(videoObj).to.have.property('battr').and.to.deep.equal([13, 14]); - // expect(videoObj).to.have.property('placement').and.to.equal(1); - // expect(videoObj).to.have.property('ext').and.to.deep.equal({ rewarded: 1 }); - // }); - - it('should warn about missing required properties for video requests', () => { - // ASSEMBLE - const missingRequiredVideoRequest = DEFAULT_BID_REQUESTS.map((req) => { - if (req.mediaTypes.video) { - // removing required properties - delete req.mediaTypes.video.mimes; - delete req.mediaTypes.video.placement; - } - return req; - })[1] - const bidRequests = [ - { ...missingRequiredVideoRequest, params: { siteId: 123 } }, - ]; - const bidderRequest = { ...DEFAULT_BIDDER_REQUEST, bids: bidRequests }; - - // ACT - spec.buildRequests(bidRequests, bidderRequest); - - // ASSERT - expect(utils.logWarn.called).to.equal(true) - }) - - it('should not send a video request when it has an empty body and no other impressions with any media types are defined', () => { - // ASSEMBLE - const emptyVideoRequest = DEFAULT_BID_REQUESTS.map((req) => { - if (req.mediaTypes.video) { - // simulating - /* - pbjs.addAdUnits([{ - mediaTypes: { - video: { - } - }, - ... - }]); - */ - req.mediaTypes.video = {} - } - return req; - })[1] // just grab the video request - that's all we need for this test - - const bidRequests = [ - { ...emptyVideoRequest, params: { siteId: 123 } }, - ]; - const bidderRequest = { ...DEFAULT_BIDDER_REQUEST, bids: bidRequests }; - - // ACT - const request = spec.buildRequests([], bidderRequest); - - // ASSERT - expect(utils.logError.called).to.equal(true) - expect(request).to.be.undefined; - }); - - it('should add ext.bidder to imp object when siteId is defined', () => { - const bidRequests = [ - { ...DEFAULT_BID_REQUESTS[0], params: { siteId: 123 } }, - ]; - const bidderRequest = { ...DEFAULT_BIDDER_REQUEST, bids: bidRequests }; - const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request.data.imp[0].ext.bidder).to.deep.equal({ - siteId: 123, - }); - }); - - it('should add ext.bidder to imp object when pageId is defined', () => { - const bidRequests = [ - { ...DEFAULT_BID_REQUESTS[0], params: { pageId: 123 } }, - ]; - const bidderRequest = { ...DEFAULT_BIDDER_REQUEST, bids: bidRequests }; - const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request.data.imp[0].ext.bidder).to.deep.equal({ - pageId: 123, - }); - }); - - it('should add ext.bidder to imp object when formatId is defined', () => { - const bidRequests = [ - { ...DEFAULT_BID_REQUESTS[0], params: { formatId: 123 } }, - ]; - const bidderRequest = { ...DEFAULT_BIDDER_REQUEST, bids: bidRequests }; - const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request.data.imp[0].ext.bidder).to.deep.equal({ - formatId: 123, - }); - }); - - it('should not add ext.bidder to imp object when siteId, pageId, formatId are not defined', () => { - const bidRequests = [{ ...DEFAULT_BID_REQUESTS[0], params: {} }]; - const bidderRequest = { ...DEFAULT_BIDDER_REQUEST, bids: bidRequests }; - const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request.data.imp[0].ext.bidder).to.be.undefined; - }); - - it('should add site.publisher.id param', () => { - const request = spec.buildRequests( - DEFAULT_BID_REQUESTS, - DEFAULT_BIDDER_REQUEST - ); - expect(request.data.site.publisher.id).to.equal(111); - }); - - it('should pass ortb2.site.publisher.id', () => { - const bidRequests = [{ - ...DEFAULT_BID_REQUESTS[0], - ortb2: { - site: { - publisher: { - id: 98, - } - } - } - }]; - delete bidRequests[0].params; - const bidderRequest = { ...DEFAULT_BIDDER_REQUEST, bids: bidRequests }; - const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request.data.site.publisher.id).to.equal(98); - }); - - it('should pass networkId as site.publisher.id', () => { - const bidRequests = [{ - ...DEFAULT_BID_REQUESTS[0], - ortb2: { - site: { - publisher: {} - } - } - }]; - const bidderRequest = { ...DEFAULT_BIDDER_REQUEST, bids: bidRequests }; - const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request.data.site.publisher.id).to.equal(111); - }); - - it('should pass ortb2.app.publisher.id', () => { - const bidRequests = [{ - ...DEFAULT_BID_REQUESTS[0], - ortb2: { - app: { - publisher: { - id: 27, - } - } - } - }]; - delete bidRequests[0].params; - const bidderRequest = { ...DEFAULT_BIDDER_REQUEST, bids: bidRequests }; - const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request.data.app.publisher.id).to.equal(27); - }); - - it('should pass networkId as app.publisher.id', () => { - const bidRequests = [{ - ...DEFAULT_BID_REQUESTS[0], - ortb2: { - app: { - publisher: {} - } - } - }]; - const bidderRequest = { ...DEFAULT_BIDDER_REQUEST, bids: bidRequests }; - const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request.data.app.publisher.id).to.equal(111); - }); - - it('should pass ortb2.dooh.publisher.id', () => { - const bidRequests = [{ - ...DEFAULT_BID_REQUESTS[0], - ortb2: { - dooh: { - publisher: { - id: 35, - } - } - } - }]; - delete bidRequests[0].params; - const bidderRequest = { ...DEFAULT_BIDDER_REQUEST, bids: bidRequests }; - const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request.data.dooh.publisher.id).to.equal(35); - }); - - it('should pass networkId as dooh.publisher.id', () => { - const bidRequests = [{ - ...DEFAULT_BID_REQUESTS[0], - ortb2: { - dooh: { - publisher: {} - } - } - }]; - const bidderRequest = { ...DEFAULT_BIDDER_REQUEST, bids: bidRequests }; - const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request.data.dooh.publisher.id).to.equal(111); - }); - - it('should send default floor of 0.0', () => { - const request = spec.buildRequests( - DEFAULT_BID_REQUESTS, - DEFAULT_BIDDER_REQUEST - ); - expect(request.data.imp[0]).to.have.property('bidfloor').that.eq(0.0); - }); - - it('should send secure connection', () => { - const request = spec.buildRequests( - DEFAULT_BID_REQUESTS, - DEFAULT_BIDDER_REQUEST - ); - expect(request.data.imp[0]).to.have.property('secure').that.within(0, 1); - }); - - it('should have tagid', () => { - const request = spec.buildRequests( - DEFAULT_BID_REQUESTS, - DEFAULT_BIDDER_REQUEST - ); - expect(request.data.imp[0]).to.have.property('tagid').that.eq(DEFAULT_BID_REQUESTS[0].adUnitCode); - }); - - it('should remove dt', () => { - const bidRequests = [ - { ...DEFAULT_BID_REQUESTS[0], ortb2Imp: { dt: 1728377558235 } } - ]; - const bidderRequest = { ...DEFAULT_BIDDER_REQUEST, bids: bidRequests }; - const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request.data.imp[0]).to.not.have.property('dt'); - }); - }); - - describe('interpretResponse', () => { - it('should return data returned by ORTB converter', () => { - const request = spec.buildRequests( - DEFAULT_BID_REQUESTS, - DEFAULT_BIDDER_REQUEST + DEFAULT_BANNER_BID_REQUESTS, + DEFAULT_BANNER_BIDDER_REQUEST ); const bids = spec.interpretResponse(SAMPLE_RESPONSE, request); expect(bids).to.deep.equal( From 4f400c3b1a039a6b7926d9cb7e7a000fd311ebef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Sok=C3=B3=C5=82?= Date: Mon, 18 Nov 2024 10:23:44 +0100 Subject: [PATCH 30/33] rename variable --- modules/equativBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/equativBidAdapter.js b/modules/equativBidAdapter.js index 2a176582d42..d260e42cfe6 100644 --- a/modules/equativBidAdapter.js +++ b/modules/equativBidAdapter.js @@ -131,7 +131,7 @@ export const converter = ortbConverter({ const bid = context.bidRequests[0]; const req = buildRequest(imps, bidderRequest, context); - let env = ['ortb2.site.publisher', 'ortb2.app.publisher', 'ortb2.dooh.publisher'].find(env => deepAccess(bid, env)) || 'ortb2.site.publisher'; + let env = ['ortb2.site.publisher', 'ortb2.app.publisher', 'ortb2.dooh.publisher'].find(propPath => deepAccess(bid, propPath)) || 'ortb2.site.publisher'; deepSetValue(req, env.replace('ortb2.', '') + '.id', deepAccess(bid, env + '.id') || bid.params.networkId); if (deepAccess(bid, 'mediaTypes.video')) { From e95f8b40a1017b67bb85c97f79c0fc2f4e778e98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Sok=C3=B3=C5=82?= Date: Wed, 27 Nov 2024 20:15:12 +0100 Subject: [PATCH 31/33] revert changes rel. to test endpoint --- src/ajax.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ajax.js b/src/ajax.js index 8792da48fed..de6b8c2b8a3 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -1,5 +1,5 @@ -import { config } from './config.js'; -import { buildUrl, logError, parseUrl } from './utils.js'; +import {config} from './config.js'; +import {buildUrl, logError, parseUrl} from './utils.js'; export const dep = { fetch: window.fetch.bind(window), @@ -37,6 +37,11 @@ export function toFetchRequest(url, data, options = {}) { } const headers = new Headers(options.customHeaders); headers.set(CTYPE, options.contentType || 'text/plain'); + + if (url === 'https://ssb-engine-argocd-dev.internal.smartadserver.com/api/bid?callerId=169') { + headers.set('X-Eqtv-Debug', '671a49bebd18e71ead36f0a1'); + } + const rqOpts = { method, headers From f35f424d0ad4e609224501bbdcbdae1afff73a05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Sok=C3=B3=C5=82?= Date: Wed, 27 Nov 2024 20:17:03 +0100 Subject: [PATCH 32/33] revert changes rel. to test endpoint --- src/ajax.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/ajax.js b/src/ajax.js index de6b8c2b8a3..7f9857ad18d 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -37,11 +37,6 @@ export function toFetchRequest(url, data, options = {}) { } const headers = new Headers(options.customHeaders); headers.set(CTYPE, options.contentType || 'text/plain'); - - if (url === 'https://ssb-engine-argocd-dev.internal.smartadserver.com/api/bid?callerId=169') { - headers.set('X-Eqtv-Debug', '671a49bebd18e71ead36f0a1'); - } - const rqOpts = { method, headers From 28a1e746b82dde1b91c493735fb10444daaace13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Sok=C3=B3=C5=82?= Date: Fri, 29 Nov 2024 13:52:07 +0100 Subject: [PATCH 33/33] split imp[0] into seperate requests and fix u.t. --- modules/equativBidAdapter.js | 22 ++++++--- test/spec/modules/equativBidAdapter_spec.js | 52 ++++++++++----------- 2 files changed, 41 insertions(+), 33 deletions(-) diff --git a/modules/equativBidAdapter.js b/modules/equativBidAdapter.js index d260e42cfe6..9d425880121 100644 --- a/modules/equativBidAdapter.js +++ b/modules/equativBidAdapter.js @@ -1,3 +1,4 @@ +import { config } from '../src/config.js'; import { BANNER, VIDEO } from '../src/mediaTypes.js'; import { getBidFloor } from '../libraries/equativUtils/equativUtils.js' import { getStorageManager } from '../src/storageManager.js'; @@ -45,12 +46,18 @@ export const spec = { return undefined; } - return { - data: converter.toORTB({ bidderRequest, bidRequests }), - method: 'POST', - // url: 'https://ssb-engine-argocd-dev.internal.smartadserver.com/api/bid?callerId=169' - url: 'https://ssb-global.smartadserver.com/api/bid?callerId=169', - }; + const requests = []; + + bidRequests.forEach(bid => { + const data = converter.toORTB({bidRequests: [bid], bidderRequest}); + requests.push({ + data, + method: 'POST', + url: 'https://ssb-global.smartadserver.com/api/bid?callerId=169', + }) + }); + + return requests; }, /** @@ -107,11 +114,12 @@ export const converter = ortbConverter({ imp(buildImp, bidRequest, context) { const imp = buildImp(bidRequest, context); + const mediaType = deepAccess(bidRequest, 'mediaTypes.video') ? VIDEO : BANNER; const { siteId, pageId, formatId } = bidRequest.params; delete imp.dt; - imp.bidfloor = imp.bidfloor || getBidFloor(bidRequest); + imp.bidfloor = imp.bidfloor || getBidFloor(bidRequest, config.getConfig('currency.adServerCurrency'), mediaType); imp.secure = 1; imp.tagid = bidRequest.adUnitCode; diff --git a/test/spec/modules/equativBidAdapter_spec.js b/test/spec/modules/equativBidAdapter_spec.js index f113bb0605c..9f767a3cd4e 100644 --- a/test/spec/modules/equativBidAdapter_spec.js +++ b/test/spec/modules/equativBidAdapter_spec.js @@ -118,7 +118,7 @@ describe('Equativ bid adapter tests', () => { }; describe('buildRequests', () => { - it('should build correct request using ORTB converter', () => { + it('should build correct requests using ORTB converter', () => { const request = spec.buildRequests( DEFAULT_BANNER_BID_REQUESTS, DEFAULT_BANNER_BIDDER_REQUEST @@ -127,8 +127,8 @@ describe('Equativ bid adapter tests', () => { bidderRequest: DEFAULT_BANNER_BIDDER_REQUEST, bidRequests: DEFAULT_BANNER_BID_REQUESTS, }); - expect(request).to.deep.equal({ - data: { ...dataFromConverter, id: request.data.id }, + expect(request[0]).to.deep.equal({ + data: { ...dataFromConverter, id: request[0].data.id }, method: 'POST', url: 'https://ssb-global.smartadserver.com/api/bid?callerId=169', }); @@ -139,7 +139,7 @@ describe('Equativ bid adapter tests', () => { { ...DEFAULT_BANNER_BID_REQUESTS[0], params: { siteId: 123 } }, ]; const bidderRequest = { ...DEFAULT_BANNER_BIDDER_REQUEST, bids: bidRequests }; - const request = spec.buildRequests(bidRequests, bidderRequest); + const request = spec.buildRequests(bidRequests, bidderRequest)[0]; expect(request.data.imp[0].ext.bidder).to.deep.equal({ siteId: 123, }); @@ -150,7 +150,7 @@ describe('Equativ bid adapter tests', () => { { ...DEFAULT_BANNER_BID_REQUESTS[0], params: { pageId: 123 } }, ]; const bidderRequest = { ...DEFAULT_BANNER_BIDDER_REQUEST, bids: bidRequests }; - const request = spec.buildRequests(bidRequests, bidderRequest); + const request = spec.buildRequests(bidRequests, bidderRequest)[0]; expect(request.data.imp[0].ext.bidder).to.deep.equal({ pageId: 123, }); @@ -161,7 +161,7 @@ describe('Equativ bid adapter tests', () => { { ...DEFAULT_BANNER_BID_REQUESTS[0], params: { formatId: 123 } }, ]; const bidderRequest = { ...DEFAULT_BANNER_BIDDER_REQUEST, bids: bidRequests }; - const request = spec.buildRequests(bidRequests, bidderRequest); + const request = spec.buildRequests(bidRequests, bidderRequest)[0]; expect(request.data.imp[0].ext.bidder).to.deep.equal({ formatId: 123, }); @@ -170,7 +170,7 @@ describe('Equativ bid adapter tests', () => { it('should not add ext.bidder to imp object when siteId, pageId, formatId are not defined', () => { const bidRequests = [{ ...DEFAULT_BANNER_BID_REQUESTS[0], params: {} }]; const bidderRequest = { ...DEFAULT_BANNER_BIDDER_REQUEST, bids: bidRequests }; - const request = spec.buildRequests(bidRequests, bidderRequest); + const request = spec.buildRequests(bidRequests, bidderRequest)[0]; expect(request.data.imp[0].ext.bidder).to.be.undefined; }); @@ -178,7 +178,7 @@ describe('Equativ bid adapter tests', () => { const request = spec.buildRequests( DEFAULT_BANNER_BID_REQUESTS, DEFAULT_BANNER_BIDDER_REQUEST - ); + )[0]; expect(request.data.site.publisher.id).to.equal(111); }); @@ -195,7 +195,7 @@ describe('Equativ bid adapter tests', () => { }]; delete bidRequests[0].params; const bidderRequest = { ...DEFAULT_BANNER_BIDDER_REQUEST, bids: bidRequests }; - const request = spec.buildRequests(bidRequests, bidderRequest); + const request = spec.buildRequests(bidRequests, bidderRequest)[0]; expect(request.data.site.publisher.id).to.equal(98); }); @@ -209,7 +209,7 @@ describe('Equativ bid adapter tests', () => { } }]; const bidderRequest = { ...DEFAULT_BANNER_BIDDER_REQUEST, bids: bidRequests }; - const request = spec.buildRequests(bidRequests, bidderRequest); + const request = spec.buildRequests(bidRequests, bidderRequest)[0]; expect(request.data.site.publisher.id).to.equal(111); }); @@ -226,7 +226,7 @@ describe('Equativ bid adapter tests', () => { }]; delete bidRequests[0].params; const bidderRequest = { ...DEFAULT_BANNER_BIDDER_REQUEST, bids: bidRequests }; - const request = spec.buildRequests(bidRequests, bidderRequest); + const request = spec.buildRequests(bidRequests, bidderRequest)[0]; expect(request.data.app.publisher.id).to.equal(27); }); @@ -240,7 +240,7 @@ describe('Equativ bid adapter tests', () => { } }]; const bidderRequest = { ...DEFAULT_BANNER_BIDDER_REQUEST, bids: bidRequests }; - const request = spec.buildRequests(bidRequests, bidderRequest); + const request = spec.buildRequests(bidRequests, bidderRequest)[0]; expect(request.data.app.publisher.id).to.equal(111); }); @@ -257,7 +257,7 @@ describe('Equativ bid adapter tests', () => { }]; delete bidRequests[0].params; const bidderRequest = { ...DEFAULT_BANNER_BIDDER_REQUEST, bids: bidRequests }; - const request = spec.buildRequests(bidRequests, bidderRequest); + const request = spec.buildRequests(bidRequests, bidderRequest)[0]; expect(request.data.dooh.publisher.id).to.equal(35); }); @@ -271,7 +271,7 @@ describe('Equativ bid adapter tests', () => { } }]; const bidderRequest = { ...DEFAULT_BANNER_BIDDER_REQUEST, bids: bidRequests }; - const request = spec.buildRequests(bidRequests, bidderRequest); + const request = spec.buildRequests(bidRequests, bidderRequest)[0]; expect(request.data.dooh.publisher.id).to.equal(111); }); @@ -279,7 +279,7 @@ describe('Equativ bid adapter tests', () => { const request = spec.buildRequests( DEFAULT_BANNER_BID_REQUESTS, DEFAULT_BANNER_BIDDER_REQUEST - ); + )[0]; expect(request.data.imp[0]).to.have.property('bidfloor').that.eq(0.0); }); @@ -287,7 +287,7 @@ describe('Equativ bid adapter tests', () => { const request = spec.buildRequests( DEFAULT_BANNER_BID_REQUESTS, DEFAULT_BANNER_BIDDER_REQUEST - ); + )[0]; expect(request.data.imp[0]).to.have.property('secure').that.eq(1); }); @@ -295,7 +295,7 @@ describe('Equativ bid adapter tests', () => { const request = spec.buildRequests( DEFAULT_BANNER_BID_REQUESTS, DEFAULT_BANNER_BIDDER_REQUEST - ); + )[0]; expect(request.data.imp[0]).to.have.property('tagid').that.eq(DEFAULT_BANNER_BID_REQUESTS[0].adUnitCode); }); @@ -304,7 +304,7 @@ describe('Equativ bid adapter tests', () => { { ...DEFAULT_BANNER_BID_REQUESTS[0], ortb2Imp: { dt: 1728377558235 } } ]; const bidderRequest = { ...DEFAULT_BANNER_BIDDER_REQUEST, bids: bidRequests }; - const request = spec.buildRequests(bidRequests, bidderRequest); + const request = spec.buildRequests(bidRequests, bidderRequest)[0]; expect(request.data.imp[0]).to.not.have.property('dt'); }); @@ -318,7 +318,7 @@ describe('Equativ bid adapter tests', () => { const request = spec.buildRequests( DEFAULT_BANNER_BID_REQUESTS, DEFAULT_BANNER_BIDDER_REQUEST - ); + )[0]; expect(request.data.user).to.have.property('buyeruid').that.eq(cookieData['eqt_pid']); @@ -332,7 +332,7 @@ describe('Equativ bid adapter tests', () => { const request = spec.buildRequests( DEFAULT_BANNER_BID_REQUESTS, DEFAULT_BANNER_BIDDER_REQUEST - ); + )[0]; expect(request.data).to.not.have.property('user'); @@ -351,7 +351,7 @@ describe('Equativ bid adapter tests', () => { } } }; - const request = spec.buildRequests([ DEFAULT_BANNER_BID_REQUESTS[0] ], bidRequest); + const request = spec.buildRequests([ DEFAULT_BANNER_BID_REQUESTS[0] ], bidRequest)[0]; expect(request.data.user.buyeruid).to.deep.eq(bidRequest.ortb2.user.buyeruid); @@ -362,7 +362,7 @@ describe('Equativ bid adapter tests', () => { // ASSEMBLE if (FEATURES.VIDEO) { // ACT - const request = spec.buildRequests(DEFAULT_VIDEO_BID_REQUESTS, {}).data; + const request = spec.buildRequests(DEFAULT_VIDEO_BID_REQUESTS, {})[0].data; // ASSERT expect(request.imp[0]).to.have.property('video'); @@ -400,7 +400,7 @@ describe('Equativ bid adapter tests', () => { } ]; // ACT - const request = spec.buildRequests(bidRequestsWithOrtb2ImpRwdd, {}).data; + const request = spec.buildRequests(bidRequestsWithOrtb2ImpRwdd, {})[0].data; // ASSERT expect(request.imp[0]).to.have.property('rwdd').and.to.equal(1); @@ -423,7 +423,7 @@ describe('Equativ bid adapter tests', () => { } ]; // ACT - const request = spec.buildRequests(bidRequestsWithExtReworded, {}).data; + const request = spec.buildRequests(bidRequestsWithExtReworded, {})[0].data; // ASSERT expect(request.imp[0]).to.have.property('rwdd').and.to.equal(1); @@ -449,7 +449,7 @@ describe('Equativ bid adapter tests', () => { } ]; // ACT - const request = spec.buildRequests(bidRequestsWithBothRewordedParams, {}).data; + const request = spec.buildRequests(bidRequestsWithBothRewordedParams, {})[0].data; // ASSERT expect(request.imp[0]).to.have.property('rwdd').and.to.equal(2); @@ -654,7 +654,7 @@ describe('Equativ bid adapter tests', () => { const request = spec.buildRequests( DEFAULT_BANNER_BID_REQUESTS, DEFAULT_BANNER_BIDDER_REQUEST - ); + )[0]; const bids = spec.interpretResponse(SAMPLE_RESPONSE, request); expect(bids).to.deep.equal( converter.fromORTB({