From 1ae68140825ed623660a0732dab93e9d0ee0c551 Mon Sep 17 00:00:00 2001 From: Victor <103455651+victorlassomarketing@users.noreply.github.com> Date: Thu, 26 Dec 2024 08:53:58 -0800 Subject: [PATCH] Update with testing params (#12600) --- modules/lassoBidAdapter.js | 26 +++++- test/spec/modules/lassoBidAdapter_spec.js | 102 ++++++++++++++++++++++ 2 files changed, 124 insertions(+), 4 deletions(-) diff --git a/modules/lassoBidAdapter.js b/modules/lassoBidAdapter.js index dc36cb4af23..ccee9616044 100644 --- a/modules/lassoBidAdapter.js +++ b/modules/lassoBidAdapter.js @@ -32,6 +32,22 @@ export const spec = { sizes = bidRequest.mediaTypes[BANNER].sizes; } + const { params } = bidRequest; + + let npi = params.npi || ''; + let dgid = params.dgid || ''; + let test = false; + + if (params.testNPI) { + npi = params.testNPI; + test = true; + } + + if (params.testDGID) { + dgid = params.testDGID; + test = true; + } + const payload = { auctionStart: bidderRequest.auctionStart, url: encodeURIComponent(window.location.href), @@ -44,14 +60,16 @@ export const spec = { sizes, aimXR, uid: '$UID', - npi: bidRequest.params.npi || '', - npi_hash: bidRequest.params.npiHash || '', + npi, + dgid, + npi_hash: params.npiHash || '', params: JSON.stringify(bidRequest.params), crumbs: JSON.stringify(bidRequest.crumbs), prebidVersion: '$prebid.version$', version: 4, coppa: config.getConfig('coppa') == true ? 1 : 0, - ccpa: bidderRequest.uspConsent || undefined + ccpa: bidderRequest.uspConsent || undefined, + test } if ( @@ -130,7 +148,7 @@ function getBidRequestUrl(aimXR, params) { if (params && params.dtc) { path = '/dtc-request'; } - if (aimXR || params.npi || params.npiHash) { + if (aimXR || params.npi || params.dgid || params.npiHash || params.testNPI || params.testDGID) { return ENDPOINT_URL + path; } return GET_IUD_URL + ENDPOINT_URL + path; diff --git a/test/spec/modules/lassoBidAdapter_spec.js b/test/spec/modules/lassoBidAdapter_spec.js index f33869e9366..94ec86aba69 100644 --- a/test/spec/modules/lassoBidAdapter_spec.js +++ b/test/spec/modules/lassoBidAdapter_spec.js @@ -100,11 +100,45 @@ describe('lassoBidAdapter', function () { }); it('should send request to get uid and trc via get request', () => { + expect(bidRequest.data.test).to.equal(false) expect(bidRequest.method).to.equal('GET'); expect(bidRequest.url).to.equal(GET_IUD_URL + ENDPOINT_URL + '/request'); }); }); + describe('buildRequests with dgid', function () { + let validBidRequests, bidRequest; + before(() => { + const updateBidParams = Object.assign({}, bid, { + params: { + adUnitId: 123456, + dgid: '123' + } + }); + validBidRequests = spec.buildRequests([updateBidParams], bidderRequest); + expect(validBidRequests).to.be.an('array').that.is.not.empty; + bidRequest = validBidRequests[0]; + }) + + it('Returns valid bidRequest', function () { + expect(bidRequest).to.exist; + expect(bidRequest.method).to.exist; + expect(bidRequest.url).to.exist; + expect(bidRequest.data).to.exist; + }); + + it('Returns GET method', function() { + expect(bidRequest.method).to.exist; + expect(bidRequest.method).to.equal('GET'); + }); + + it('should send request to trc via get request with dgid', () => { + expect(bidRequest.data.test).to.equal(false) + expect(bidRequest.method).to.equal('GET'); + expect(bidRequest.url).to.equal(ENDPOINT_URL + '/request'); + }); + }); + describe('buildRequests with npi', function () { let validBidRequests, bidRequest; before(() => { @@ -132,6 +166,73 @@ describe('lassoBidAdapter', function () { }); it('should send request to trc via get request with npi', () => { + expect(bidRequest.data.test).to.equal(false) + expect(bidRequest.method).to.equal('GET'); + expect(bidRequest.url).to.equal(ENDPOINT_URL + '/request'); + }); + }); + + describe('buildRequests with test npi', function () { + let validBidRequests, bidRequest; + before(() => { + const updateBidParams = Object.assign({}, bid, { + params: { + adUnitId: 123456, + testNPI: '123' + } + }); + validBidRequests = spec.buildRequests([updateBidParams], bidderRequest); + expect(validBidRequests).to.be.an('array').that.is.not.empty; + bidRequest = validBidRequests[0]; + }) + + it('Returns valid bidRequest', function () { + expect(bidRequest).to.exist; + expect(bidRequest.method).to.exist; + expect(bidRequest.url).to.exist; + expect(bidRequest.data).to.exist; + }); + + it('Returns GET method', function() { + expect(bidRequest.method).to.exist; + expect(bidRequest.method).to.equal('GET'); + }); + + it('should send request to trc via get request with npi and test param', () => { + expect(bidRequest.data.test).to.equal(true) + expect(bidRequest.method).to.equal('GET'); + expect(bidRequest.url).to.equal(ENDPOINT_URL + '/request'); + }); + }); + + describe('buildRequests with test dgid', function () { + let validBidRequests, bidRequest; + before(() => { + const updateBidParams = Object.assign({}, bid, { + params: { + adUnitId: 123456, + testDGID: '123' + } + }); + validBidRequests = spec.buildRequests([updateBidParams], bidderRequest); + expect(validBidRequests).to.be.an('array').that.is.not.empty; + bidRequest = validBidRequests[0]; + }) + + it('Returns valid bidRequest', function () { + expect(bidRequest).to.exist; + expect(bidRequest.method).to.exist; + expect(bidRequest.url).to.exist; + expect(bidRequest.data).to.exist; + }); + + it('Returns GET method', function() { + expect(bidRequest.method).to.exist; + expect(bidRequest.method).to.equal('GET'); + }); + + it('should send request to trc via get request with dgid and test param', () => { + expect(bidRequest.data.test).to.equal(true) expect(bidRequest.method).to.equal('GET'); expect(bidRequest.url).to.equal(ENDPOINT_URL + '/request'); }); @@ -164,6 +265,7 @@ describe('lassoBidAdapter', function () { }); it('should send request to trc via get request with npi', () => { + expect(bidRequest.data.test).to.equal(false) expect(bidRequest.method).to.equal('GET'); expect(bidRequest.url).to.equal(ENDPOINT_URL + '/request'); });