Skip to content

Commit

Permalink
Update with testing params (#12600)
Browse files Browse the repository at this point in the history
  • Loading branch information
victorlassomarketing authored Dec 26, 2024
1 parent 7651cb3 commit 1ae6814
Show file tree
Hide file tree
Showing 2 changed files with 124 additions and 4 deletions.
26 changes: 22 additions & 4 deletions modules/lassoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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 (
Expand Down Expand Up @@ -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;
Expand Down
102 changes: 102 additions & 0 deletions test/spec/modules/lassoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down Expand Up @@ -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');
});
Expand Down Expand Up @@ -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');
});
Expand Down

0 comments on commit 1ae6814

Please sign in to comment.