From d3b79002225856ef330014be71a754ce7100795c Mon Sep 17 00:00:00 2001 From: Tiago Peczenyj Date: Thu, 8 Jun 2023 19:12:27 +0200 Subject: [PATCH] Weborama RTD Module : start Bidder specific handling removal (#10005) * remove specific code to pubmatic * remove specific code to smartadserver bidder * update unit tests * remove rubicon specific code * refactor method * refactor this.#setBidderOrtb2 * fix lint issue * add ortb2 user.keywords on appnexs * try fix appnexus case * small refactor inspired on #9952 * try fix appnexus * Revert "try fix appnexus" This reverts commit db1fc089081660753a0a15348508c6be7aba42ff. * Revert "small refactor inspired on #9952" This reverts commit 395926025925e06ef2547f59ac659118473bc138. * Revert "try fix appnexus case" This reverts commit 919540aaa6402b004c2b22bddfa4ed81128528bc. * Revert "add ortb2 user.keywords on appnexs" This reverts commit e2c5747f359b0265cb439f9cdb3928053d2be646. --- modules/weboramaRtdProvider.js | 120 +--- modules/weboramaRtdProvider.md | 8 +- test/spec/modules/weboramaRtdProvider_spec.js | 536 +++++++++++------- 3 files changed, 360 insertions(+), 304 deletions(-) diff --git a/modules/weboramaRtdProvider.js b/modules/weboramaRtdProvider.js index 7e5b21de5a6..6ba502d2c8b 100644 --- a/modules/weboramaRtdProvider.js +++ b/modules/weboramaRtdProvider.js @@ -689,19 +689,8 @@ class WeboramaRtdProvider { /** @type {string} */ const bidder = bidderAliasRegistry[bid.bidder] || bid.bidder; - switch (bidder) { - case 'appnexus': - this.#handleAppnexusBid(bid, profile); - break; - case 'pubmatic': - this.#handlePubmaticBid(bid, profile); - break; - case 'smartadserver': - this.#handleSmartadserverBid(bid, profile); - break; - case 'rubicon': - this.#handleRubiconBid(bid, profile, metadata); - break; + if (bidder == 'appnexus') { + this.#handleAppnexusBid(reqBidsConfigObj, bid, profile); } } @@ -719,92 +708,19 @@ class WeboramaRtdProvider { /** handle appnexus/xandr bid * @method * @private + * @param {Object} reqBidsConfigObj + * @param {Object} reqBidsConfigObj.ortb2Fragments + * @param {Object} reqBidsConfigObj.ortb2Fragments.bidder * @param {Object} bid - * @param {Object} bid.params - * @param {Object} bid.params.keyword + * @param {Object} bid.parameters * @param {Profile} profile * @returns {void} */ // eslint-disable-next-line no-dupe-class-members - #handleAppnexusBid(bid, profile) { + #handleAppnexusBid(reqBidsConfigObj, bid, profile) { const base = 'params.keywords'; this.#assignProfileToObject(bid, base, profile); - } - - /** handle pubmatic bid - * @method - * @private - * @param {Object} bid - * @param {Object} bid.params - * @param {string} bid.params.dctr - * @param {Profile} profile - * @returns {void} - */ - // eslint-disable-next-line no-dupe-class-members - #handlePubmaticBid(bid, profile) { - const sep = '|'; - const subsep = ','; - - bid.params ||= {}; - - const data = bid.params.dctr || ''; - const target = new Set(data.split(sep).filter((x) => x.length > 0)); - - Object.entries(profile).forEach(([key, values]) => { - const value = values.join(subsep); - const keyword = `${key}=${value}`; - target.add(keyword); - }); - - bid.params.dctr = Array.from(target).join(sep); - } - - /** handle smartadserver bid - * @method - * @private - * @param {Object} bid - * @param {Object} bid.params - * @param {string} bid.params.target - * @param {Profile} profile - * @returns {void} - */ - // eslint-disable-next-line no-dupe-class-members - #handleSmartadserverBid(bid, profile) { - const sep = ';'; - - bid.params ||= {}; - - const data = bid.params.target || ''; - const target = new Set(data.split(sep).filter((x) => x.length > 0)); - - Object.entries(profile).forEach(([key, values]) => { - values.forEach(value => { - const keyword = `${key}=${value}`; - target.add(keyword); - }) - }); - - bid.params.target = Array.from(target).join(sep); - } - - /** handle rubicon bid - * @method - * @private - * @param {Object} bid - * @param {string} bid.bidder - * @param {Profile} profile - * @param {dataCallbackMetadata} metadata - * @returns {void} - */ - // eslint-disable-next-line no-dupe-class-members - #handleRubiconBid(bid, profile, metadata) { - if (isBoolean(metadata.user)) { - const section = metadata.user ? 'visitor' : 'inventory'; - const base = `params.${section}`; - this.#assignProfileToObject(bid, base, profile); - } else { - logMessage(`SKIP bidder '${bid.bidder}', data from '${metadata.source}' is not defined as user or site-centric`); - } + // this.#setBidderOrtb2(reqBidsConfigObj.ortb2Fragments?.bidder, bid.bidder, base, profile); } /** handle generic bid via ortb2 arbitrary data @@ -823,14 +739,28 @@ class WeboramaRtdProvider { if (isBoolean(metadata.user)) { logMessage(`bidder '${bidder}' is not directly supported, trying set data via bidder ortb2 fpd`); const section = metadata.user ? 'user' : 'site'; - const base = `${bidder}.${section}.ext.data`; + const path = `${section}.ext.data`; - this.#assignProfileToObject(reqBidsConfigObj.ortb2Fragments?.bidder, base, profile); + this.#setBidderOrtb2(reqBidsConfigObj.ortb2Fragments?.bidder, bidder, path, profile) } else { logMessage(`SKIP unsupported bidder '${bidder}', data from '${metadata.source}' is not defined as user or site-centric`); } } - + /** + * set bidder ortb2 data + * @method + * @private + * @param {Object} bidderOrtb2Fragments + * @param {string} bidder + * @param {string} path + * @param {Profile} profile + * @returns {void} + */ + // eslint-disable-next-line no-dupe-class-members + #setBidderOrtb2(bidderOrtb2Fragments, bidder, path, profile) { + const base = `${bidder}.${path}`; + this.#assignProfileToObject(bidderOrtb2Fragments, base, profile) + } /** * assign profile to object * @method diff --git a/modules/weboramaRtdProvider.md b/modules/weboramaRtdProvider.md index f86351fe214..0c6e3339787 100644 --- a/modules/weboramaRtdProvider.md +++ b/modules/weboramaRtdProvider.md @@ -575,12 +575,9 @@ pbjs.que.push(function () { ### Supported Bidders -We currently support the following bidder adapters: +We currently support the following bidder adapters with dedicated code: -* SmartADServer SSP -* PubMatic SSP * AppNexus SSP -* Rubicon SSP We also set the bidder (and global, if no specific bidders are set on `sendToBidders`) ortb2 `site.ext.data` and `user.ext.data` sections (as arbitrary data). The following bidders may support it, to be sure, check the `First Party Data Support` on the feature list for the particular bidder from [here](https://docs.prebid.org/dev-docs/bidders). @@ -605,8 +602,11 @@ We also set the bidder (and global, if no specific bidders are set on `sendToBid * Opt Out Advertising * Ozone Project * Proxistore +* PubMatic SSP * Rise +* Rubicon SSP * Smaato +* Smart ADServer SSP * Sonobi * TheMediaGrid * TripleLift diff --git a/test/spec/modules/weboramaRtdProvider_spec.js b/test/spec/modules/weboramaRtdProvider_spec.js index bbc1c6d6f02..7de8474d7c9 100644 --- a/test/spec/modules/weboramaRtdProvider_spec.js +++ b/test/spec/modules/weboramaRtdProvider_spec.js @@ -130,19 +130,19 @@ describe('weboramaRtdProvider', function() { }); expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5); - expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('webo_ctx=foo;webo_ctx=bar;webo_ds=baz'); - expect(reqBidsConfigObj.adUnits[0].bids[1].params.dctr).to.equal('webo_ctx=foo,bar|webo_ds=baz'); + expect(reqBidsConfigObj.adUnits[0].bids[0].params).to.be.undefined; + expect(reqBidsConfigObj.adUnits[0].bids[1].params).to.be.undefined; expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal(data); - expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.deep.equal({ - inventory: data - }); - expect(reqBidsConfigObj.ortb2Fragments.bidder.other).to.deep.equal({ - site: { - ext: { - data: data - }, - } - }); + expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.be.undefined; + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + site: { + ext: { + data: data + }, + } + }); + }) expect(onDataResponse).to.deep.equal({ data: data, meta: { @@ -217,19 +217,19 @@ describe('weboramaRtdProvider', function() { }); expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5); - expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('webo_vctx=foo;webo_vctx=bar'); - expect(reqBidsConfigObj.adUnits[0].bids[1].params.dctr).to.equal('webo_vctx=foo,bar'); + expect(reqBidsConfigObj.adUnits[0].bids[0].params).to.be.undefined; + expect(reqBidsConfigObj.adUnits[0].bids[1].params).to.be.undefined; expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal(data); - expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.deep.equal({ - inventory: data - }); - expect(reqBidsConfigObj.ortb2Fragments.bidder.other).to.deep.equal({ - site: { - ext: { - data: data - }, - } - }); + expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.be.undefined; + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + site: { + ext: { + data: data + }, + } + }); + }) expect(onDataResponse).to.deep.equal({ data: data, meta: { @@ -304,19 +304,19 @@ describe('weboramaRtdProvider', function() { }); expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5); - expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('webo_vctx=foo;webo_vctx=bar'); - expect(reqBidsConfigObj.adUnits[0].bids[1].params.dctr).to.equal('webo_vctx=foo,bar'); + expect(reqBidsConfigObj.adUnits[0].bids[0].params).to.be.undefined; + expect(reqBidsConfigObj.adUnits[0].bids[1].params).to.be.undefined; expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal(data); - expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.deep.equal({ - inventory: data - }); - expect(reqBidsConfigObj.ortb2Fragments.bidder.other).to.deep.equal({ - site: { - ext: { - data: data - }, - } - }); + expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.be.undefined; + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + site: { + ext: { + data: data + }, + } + }); + }) expect(onDataResponse).to.deep.equal({ data: data, meta: { @@ -543,9 +543,22 @@ describe('weboramaRtdProvider', function() { expect(adUnit.bids[1].params).to.be.undefined; expect(adUnit.bids[2].params.keywords).to.deep.equal(data); expect(adUnit.bids[3].params).to.be.undefined; - expect(reqBidsConfigObj.ortb2Fragments.bidder.other).to.be.undefined; }); + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + if (v == 'appnexus') { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + site: { + ext: { + data: data + }, + } + }); + + return; + } + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.be.undefined; + }) expect(onDataResponse).to.deep.equal({ data: data, meta: { @@ -809,9 +822,10 @@ describe('weboramaRtdProvider', function() { baz: 'bam', } }); - - expect(reqBidsConfigObj.ortb2Fragments.bidder.other).to.be.undefined; }); + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.be.undefined; + }) }); }); }); @@ -951,9 +965,10 @@ describe('weboramaRtdProvider', function() { baz: 'bam', } }); - - expect(reqBidsConfigObj.ortb2Fragments.bidder.other).to.be.undefined; }); + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.be.undefined; + }) }); }); }); @@ -1105,8 +1120,8 @@ describe('weboramaRtdProvider', function() { }); expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5); - expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('foo=bar;webo_ctx=foo;webo_ctx=bar;webo_ds=baz'); - expect(reqBidsConfigObj.adUnits[0].bids[1].params.dctr).to.equal('foo=bar|webo_ctx=foo,bar|webo_ds=baz'); + expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('foo=bar'); + expect(reqBidsConfigObj.adUnits[0].bids[1].params.dctr).to.equal('foo=bar'); expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal({ foo: ['bar'], webo_ctx: ['foo', 'bar'], @@ -1115,20 +1130,20 @@ describe('weboramaRtdProvider', function() { expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.deep.equal({ inventory: { foo: 'bar', - webo_ctx: ['foo', 'bar'], - webo_ds: ['baz'], }, visitor: { baz: 'bam', } }); - expect(reqBidsConfigObj.ortb2Fragments.bidder.other).to.deep.equal({ - site: { - ext: { - data: data - }, - } - }); + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + site: { + ext: { + data: data + }, + } + }); + }) }); it('should use default profile in case of api error', function() { @@ -1196,19 +1211,19 @@ describe('weboramaRtdProvider', function() { }); expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5); - expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('webo_ctx=baz'); - expect(reqBidsConfigObj.adUnits[0].bids[1].params.dctr).to.equal('webo_ctx=baz'); + expect(reqBidsConfigObj.adUnits[0].bids[0].params).to.be.undefined; + expect(reqBidsConfigObj.adUnits[0].bids[1].params).to.be.undefined; expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal(defaultProfile); - expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.deep.equal({ - inventory: defaultProfile - }); - expect(reqBidsConfigObj.ortb2Fragments.bidder.other).to.deep.equal({ - site: { - ext: { - data: defaultProfile - }, - } - }); + expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.be.undefined; + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + site: { + ext: { + data: defaultProfile + }, + } + }); + }) expect(onDataResponse).to.deep.equal({ data: defaultProfile, meta: { @@ -1316,20 +1331,35 @@ describe('weboramaRtdProvider', function() { reqBidsConfigObj.adUnits.forEach(adUnit => { expect(adUnit.bids.length).to.equal(5); - expect(adUnit.bids[0].params.target).to.equal('webo_ctx=foo;webo_ctx=bar;webo_ds=baz'); - expect(adUnit.bids[1].params.dctr).to.equal('webo_ctx=foo,bar|webo_ds=baz'); - expect(adUnit.bids[3].params).to.deep.equal({ - inventory: data - }); - expect(reqBidsConfigObj.ortb2Fragments.bidder.other).to.deep.equal({ + expect(adUnit.bids[0].params).to.be.undefined; + expect(adUnit.bids[1].params).to.be.undefined; + expect(adUnit.bids[3].params).to.be.undefined; + }); + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + if (v == 'appnexus') { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + site: { + ext: { + data: { + webo_ctx: ['foo', 'bar'], + webo_ds: ['baz'], + webo_bar: ['baz'], + } + }, + } + }); + + return + } + + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ site: { ext: { data: data }, } }); - }); - + }) expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal({ webo_ctx: ['foo', 'bar'], webo_ds: ['baz'], @@ -1414,19 +1444,19 @@ describe('weboramaRtdProvider', function() { }); expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5); - expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('webo_cs=foo;webo_cs=bar;webo_audiences=baz'); - expect(reqBidsConfigObj.adUnits[0].bids[1].params.dctr).to.equal('webo_cs=foo,bar|webo_audiences=baz'); + expect(reqBidsConfigObj.adUnits[0].bids[0].params).to.be.undefined; + expect(reqBidsConfigObj.adUnits[0].bids[1].params).to.be.undefined; expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal(data); - expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.deep.equal({ - visitor: data - }); - expect(reqBidsConfigObj.ortb2Fragments.bidder.other).to.deep.equal({ - user: { - ext: { - data: data - }, - } - }); + expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.be.undefined; + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + user: { + ext: { + data: data + }, + } + }); + }) expect(onDataResponse).to.deep.equal({ data: data, meta: { @@ -1545,8 +1575,21 @@ describe('weboramaRtdProvider', function() { expect(adUnit.bids[2].params.keywords).to.deep.equal(data); expect(adUnit.bids[3].params).to.be.undefined; }); - expect(reqBidsConfigObj.ortb2Fragments.bidder.other).to.be.undefined; + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + if (v == 'appnexus') { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + user: { + ext: { + data: data + }, + } + }); + + return + } + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.be.undefined; + }) expect(onDataResponse).to.deep.equal({ data: data, meta: { @@ -1657,7 +1700,21 @@ describe('weboramaRtdProvider', function() { expect(adUnit.bids[1].params).to.be.undefined; expect(adUnit.bids[3].params).to.be.undefined; }); - expect(reqBidsConfigObj.ortb2Fragments.bidder.other).to.be.undefined; + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + if (v == 'appnexus') { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + user: { + ext: { + data: data + }, + } + }); + + return + } + + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.be.undefined; + }) expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal(data); expect(reqBidsConfigObj.adUnits[1].bids[2].params).to.be.undefined; @@ -1813,7 +1870,9 @@ describe('weboramaRtdProvider', function() { } }); }); - expect(reqBidsConfigObj.ortb2Fragments.bidder.other).to.be.undefined; + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.be.undefined; + }) }); }); }); @@ -1956,7 +2015,9 @@ describe('weboramaRtdProvider', function() { } }); }); - expect(reqBidsConfigObj.ortb2Fragments.bidder.other).to.be.undefined; + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.be.undefined; + }) }); }); }); @@ -2109,8 +2170,8 @@ describe('weboramaRtdProvider', function() { }); expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5); - expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('foo=bar;webo_cs=foo;webo_cs=bar;webo_audiences=baz'); - expect(reqBidsConfigObj.adUnits[0].bids[1].params.dctr).to.equal('foo=bar|webo_cs=foo,bar|webo_audiences=baz'); + expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('foo=bar'); + expect(reqBidsConfigObj.adUnits[0].bids[1].params.dctr).to.equal('foo=bar'); expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal({ foo: ['bar'], webo_cs: ['foo', 'bar'], @@ -2122,17 +2183,17 @@ describe('weboramaRtdProvider', function() { }, visitor: { baz: 'bam', - webo_cs: ['foo', 'bar'], - webo_audiences: ['baz'], - } - }); - expect(reqBidsConfigObj.ortb2Fragments.bidder.other).to.deep.equal({ - user: { - ext: { - data: data - }, } }); + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + user: { + ext: { + data: data + }, + } + }); + }) }); it('should use default profile in case of nothing on local storage', function() { @@ -2187,19 +2248,19 @@ describe('weboramaRtdProvider', function() { }); expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5); - expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('webo_audiences=baz'); - expect(reqBidsConfigObj.adUnits[0].bids[1].params.dctr).to.equal('webo_audiences=baz'); + expect(reqBidsConfigObj.adUnits[0].bids[0].params).to.be.undefined; + expect(reqBidsConfigObj.adUnits[0].bids[1].params).to.be.undefined; expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal(defaultProfile); - expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.deep.equal({ - visitor: defaultProfile - }); - expect(reqBidsConfigObj.ortb2Fragments.bidder.other).to.deep.equal({ - user: { - ext: { - data: defaultProfile - }, - } - }); + expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.be.undefined; + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + user: { + ext: { + data: defaultProfile + }, + } + }); + }) }); it('should use default profile if cant read from local storage', function() { @@ -2261,19 +2322,19 @@ describe('weboramaRtdProvider', function() { }); expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5); - expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('webo_audiences=baz'); - expect(reqBidsConfigObj.adUnits[0].bids[1].params.dctr).to.equal('webo_audiences=baz'); + expect(reqBidsConfigObj.adUnits[0].bids[0].params).to.be.undefined; + expect(reqBidsConfigObj.adUnits[0].bids[1].params).to.be.undefined; expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal(defaultProfile); - expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.deep.equal({ - visitor: defaultProfile - }); - expect(reqBidsConfigObj.ortb2Fragments.bidder.other).to.deep.equal({ - user: { - ext: { - data: defaultProfile - }, - } - }); + expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.be.undefined; + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + user: { + ext: { + data: defaultProfile + }, + } + }); + }) expect(onDataResponse).to.deep.equal({ data: defaultProfile, meta: { @@ -2383,26 +2444,35 @@ describe('weboramaRtdProvider', function() { reqBidsConfigObj.adUnits.forEach(adUnit => { expect(adUnit.bids.length).to.equal(5); - expect(adUnit.bids[0].params.target).to.equal('webo_cs=foo;webo_cs=bar;webo_audiences=baz'); - expect(adUnit.bids[1].params.dctr).to.equal('webo_cs=foo,bar|webo_audiences=baz'); - expect(adUnit.bids[3].params).to.deep.equal({ - visitor: data - }); - expect(reqBidsConfigObj.ortb2Fragments.bidder.other).to.deep.equal({ + expect(adUnit.bids[0].params).to.be.undefined; + expect(adUnit.bids[1].params).to.be.undefined; + expect(adUnit.bids[3].params).to.be.undefined; + }); + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + if (v == 'appnexus') { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + user: { + ext: { + data: { + webo_cs: ['foo', 'bar'], + webo_audiences: ['baz'], + webo_bar: ['baz'], + } + }, + } + }); + + return + } + + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ user: { ext: { data: data }, } }); - }); - - expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal({ - webo_cs: ['foo', 'bar'], - webo_audiences: ['baz'], - webo_bar: ['baz'], - }); - expect(reqBidsConfigObj.adUnits[1].bids[2].params.keywords).to.deep.equal(data); + }) expect(onDataResponse).to.deep.equal({ data: data, @@ -2480,19 +2550,19 @@ describe('weboramaRtdProvider', function() { }); expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5); - expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('lite_occupation=gérant;lite_occupation=bénévole;lite_hobbies=sport;lite_hobbies=cinéma'); - expect(reqBidsConfigObj.adUnits[0].bids[1].params.dctr).to.equal('lite_occupation=gérant,bénévole|lite_hobbies=sport,cinéma'); + expect(reqBidsConfigObj.adUnits[0].bids[0].params).to.be.undefined; + expect(reqBidsConfigObj.adUnits[0].bids[1].params).to.be.undefined; expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal(data); - expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.deep.equal({ - inventory: data, - }); - expect(reqBidsConfigObj.ortb2Fragments.bidder.other).to.deep.equal({ - site: { - ext: { - data: data, - }, - }, - }); + expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.be.undefined; + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + site: { + ext: { + data: data + }, + } + }); + }) expect(onDataResponse).to.deep.equal({ data: data, meta: { @@ -2610,7 +2680,21 @@ describe('weboramaRtdProvider', function() { expect(adUnit.bids[2].params.keywords).to.deep.equal(data); expect(adUnit.bids[3].params).to.be.undefined; }); - expect(reqBidsConfigObj.ortb2Fragments.bidder.other).to.be.undefined; + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + if (v == 'appnexus') { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + site: { + ext: { + data: data + }, + } + }); + + return + } + + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.be.undefined; + }) expect(onDataResponse).to.deep.equal({ data: data, @@ -2721,11 +2805,26 @@ describe('weboramaRtdProvider', function() { expect(adUnit.bids[1].params).to.be.undefined; expect(adUnit.bids[3].params).to.be.undefined; }); - expect(reqBidsConfigObj.ortb2Fragments.bidder.other).to.be.undefined; expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal(data); expect(reqBidsConfigObj.adUnits[1].bids[2].params).to.be.undefined; + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + if (v == 'appnexus') { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + site: { + ext: { + data: data + }, + } + }); + + return + } + + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.be.undefined; + }) + expect(onDataResponse).to.deep.equal({ data: data, meta: { @@ -2876,7 +2975,9 @@ describe('weboramaRtdProvider', function() { } }); }); - expect(reqBidsConfigObj.ortb2Fragments.bidder.other).to.be.undefined; + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.be.undefined; + }) }); }); }); @@ -3018,7 +3119,9 @@ describe('weboramaRtdProvider', function() { } }); }); - expect(reqBidsConfigObj.ortb2Fragments.bidder.other).to.be.undefined; + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.be.undefined; + }) }); }); }); @@ -3173,8 +3276,8 @@ describe('weboramaRtdProvider', function() { }); expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5); - expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('foo=bar;lite_occupation=gérant;lite_occupation=bénévole;lite_hobbies=sport;lite_hobbies=cinéma'); - expect(reqBidsConfigObj.adUnits[0].bids[1].params.dctr).to.equal('foo=bar|lite_occupation=gérant,bénévole|lite_hobbies=sport,cinéma'); + expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('foo=bar'); + expect(reqBidsConfigObj.adUnits[0].bids[1].params.dctr).to.equal('foo=bar'); expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal({ foo: ['bar'], lite_occupation: ['gérant', 'bénévole'], @@ -3183,20 +3286,20 @@ describe('weboramaRtdProvider', function() { expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.deep.equal({ inventory: { foo: 'bar', - lite_occupation: ['gérant', 'bénévole'], - lite_hobbies: ['sport', 'cinéma'], }, visitor: { baz: 'bam', } }); - expect(reqBidsConfigObj.ortb2Fragments.bidder.other).to.deep.equal({ - site: { - ext: { - data: data, - }, - }, - }); + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + site: { + ext: { + data: data + }, + } + }); + }) }); it('should use default profile in case of nothing on local storage', function() { @@ -3250,19 +3353,19 @@ describe('weboramaRtdProvider', function() { }); expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5); - expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('lite_hobbies=sport;lite_hobbies=cinéma'); - expect(reqBidsConfigObj.adUnits[0].bids[1].params.dctr).to.equal('lite_hobbies=sport,cinéma'); + expect(reqBidsConfigObj.adUnits[0].bids[0].params).to.be.undefined; + expect(reqBidsConfigObj.adUnits[0].bids[1].params).to.be.undefined; expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal(defaultProfile); - expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.deep.equal({ - inventory: defaultProfile, - }); - expect(reqBidsConfigObj.ortb2Fragments.bidder.other).to.deep.equal({ - site: { - ext: { - data: defaultProfile, - }, - }, - }); + expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.be.undefined; + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + site: { + ext: { + data: defaultProfile + }, + } + }); + }) }); it('should use default profile if cant read from local storage', function() { @@ -3323,12 +3426,10 @@ describe('weboramaRtdProvider', function() { }); expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5); - expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('lite_hobbies=sport;lite_hobbies=cinéma'); - expect(reqBidsConfigObj.adUnits[0].bids[1].params.dctr).to.equal('lite_hobbies=sport,cinéma'); + expect(reqBidsConfigObj.adUnits[0].bids[0].params).to.be.undefined; + expect(reqBidsConfigObj.adUnits[0].bids[1].params).to.be.undefined; expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal(defaultProfile); - expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.deep.equal({ - inventory: defaultProfile, - }); + expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.be.undefined; expect(reqBidsConfigObj.ortb2Fragments.bidder.other).to.deep.equal({ site: { ext: { @@ -3336,6 +3437,15 @@ describe('weboramaRtdProvider', function() { }, }, }); + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + site: { + ext: { + data: defaultProfile, + }, + } + }); + }) expect(onDataResponse).to.deep.equal({ data: defaultProfile, meta: { @@ -3403,19 +3513,19 @@ describe('weboramaRtdProvider', function() { }); expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5); - expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('lite_hobbies=sport;lite_hobbies=cinéma'); - expect(reqBidsConfigObj.adUnits[0].bids[1].params.dctr).to.equal('lite_hobbies=sport,cinéma'); + expect(reqBidsConfigObj.adUnits[0].bids[0].params).to.be.undefined; + expect(reqBidsConfigObj.adUnits[0].bids[1].params).to.be.undefined; expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal(defaultProfile); - expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.deep.equal({ - inventory: defaultProfile, - }); - expect(reqBidsConfigObj.ortb2Fragments.bidder.other).to.deep.equal({ - site: { - ext: { - data: defaultProfile, - }, - }, - }); + expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.be.undefined; + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + site: { + ext: { + data: defaultProfile + }, + } + }); + }) expect(onDataResponse).to.deep.equal({ data: defaultProfile, meta: { @@ -3523,19 +3633,35 @@ describe('weboramaRtdProvider', function() { reqBidsConfigObj.adUnits.forEach(adUnit => { expect(adUnit.bids.length).to.equal(5); - expect(adUnit.bids[0].params.target).to.equal('lite_occupation=gérant;lite_occupation=bénévole;lite_hobbies=sport;lite_hobbies=cinéma'); - expect(adUnit.bids[1].params.dctr).to.equal('lite_occupation=gérant,bénévole|lite_hobbies=sport,cinéma'); - expect(adUnit.bids[3].params).to.deep.equal({ - inventory: data, + expect(adUnit.bids[0].params).to.be.undefined; + expect(adUnit.bids[1].params).to.be.undefined; + expect(adUnit.bids[3].params).to.be.undefined; + }); + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + if (v == 'appnexus') { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + site: { + ext: { + data: { + lite_occupation: ['gérant', 'bénévole'], + lite_hobbies: ['sport', 'cinéma'], + lito_bar: ['baz'], + }, + }, + } + }); + + return + } + + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + site: { + ext: { + data: data, + }, + } }); - }); - expect(reqBidsConfigObj.ortb2Fragments.bidder.other).to.deep.equal({ - site: { - ext: { - data: data, - }, - }, - }); + }) expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal({ lite_occupation: ['gérant', 'bénévole'],