From 2a10388dc44f5cc792bed72a2d3e3cfae07cd769 Mon Sep 17 00:00:00 2001 From: Arne Schulz Date: Tue, 4 Jun 2019 17:16:02 +0200 Subject: [PATCH] Bugfix add bid parameters if not present (#3808) * initial orbidder version in personal github repo * use adUnits from orbidder_example.html * replace obsolete functions * forgot to commit the test * check if bidderRequest object is available * try to fix weird safari/ie issue * ebayK: add more params * update orbidderBidAdapter.md * use spec. instead of this. for consistency reasons * add bidfloor parameter to params object * fix gdpr object handling * default to consentRequired: false when not explicitly given * wip - use onSetTargeting callback * add tests for onSetTargeting callback * fix params and respective tests --- modules/orbidderBidAdapter.js | 5 ++--- test/spec/modules/orbidderBidAdapter_spec.js | 14 +++++++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/modules/orbidderBidAdapter.js b/modules/orbidderBidAdapter.js index 1123cc5d50e..e085a14c6b8 100644 --- a/modules/orbidderBidAdapter.js +++ b/modules/orbidderBidAdapter.js @@ -82,10 +82,9 @@ export const spec = { const getRefererInfo = detectReferer(window); bid.pageUrl = getRefererInfo().referer; - if (spec.bidParams[bid.adId]) { - bid.params = spec.bidParams[bid.adId]; + if (spec.bidParams[bid.requestId] && (typeof bid.params === 'undefined')) { + bid.params = [spec.bidParams[bid.requestId]]; } - spec.ajaxCall(`${spec.orbidderHost}${route}`, JSON.stringify(bid)); }, diff --git a/test/spec/modules/orbidderBidAdapter_spec.js b/test/spec/modules/orbidderBidAdapter_spec.js index 3818f502901..55f5e2cae4c 100644 --- a/test/spec/modules/orbidderBidAdapter_spec.js +++ b/test/spec/modules/orbidderBidAdapter_spec.js @@ -2,6 +2,7 @@ import {expect} from 'chai'; import {spec} from 'modules/orbidderBidAdapter'; import {newBidder} from 'src/adapters/bidderFactory'; import openxAdapter from '../../../modules/openxAnalyticsAdapter'; +import {detectReferer} from 'src/refererDetection'; describe('orbidderBidAdapter', () => { const adapter = newBidder(spec); @@ -153,9 +154,16 @@ describe('orbidderBidAdapter', () => { adId: 'testId', test: 1, pageUrl: 'www.someurl.de', - referrer: 'www.somereferrer.de' + referrer: 'www.somereferrer.de', + requestId: '123req456' }; + spec.bidParams['123req456'] = {'accountId': '123acc456'}; + + let bidObjClone = deepClone(bidObj); + bidObjClone.pageUrl = detectReferer(window)().referer; + bidObjClone.params = [{'accountId': '123acc456'}]; + beforeEach(() => { ajaxStub = sinon.stub(spec, 'ajaxCall'); }); @@ -169,13 +177,13 @@ describe('orbidderBidAdapter', () => { expect(ajaxStub.calledOnce).to.equal(true); expect(ajaxStub.firstCall.args[0].indexOf('https://')).to.equal(0); expect(ajaxStub.firstCall.args[0]).to.equal(`${spec.orbidderHost}/win`); - expect(ajaxStub.firstCall.args[1]).to.equal(JSON.stringify(bidObj)); + expect(ajaxStub.firstCall.args[1]).to.equal(JSON.stringify(bidObjClone)); spec.onSetTargeting(bidObj); expect(ajaxStub.calledTwice).to.equal(true); expect(ajaxStub.secondCall.args[0].indexOf('https://')).to.equal(0); expect(ajaxStub.secondCall.args[0]).to.equal(`${spec.orbidderHost}/targeting`); - expect(ajaxStub.secondCall.args[1]).to.equal(JSON.stringify(bidObj)); + expect(ajaxStub.secondCall.args[1]).to.equal(JSON.stringify(bidObjClone)); }); });