Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Teads bid adapter: switch GPID logic to the new imp.ext.gpid field #7903

Merged
merged 1 commit into from
Jan 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions modules/teadsBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,7 @@ function buildRequestObject(bid) {
const reqObj = {};
let placementId = getValue(bid.params, 'placementId');
let pageId = getValue(bid.params, 'pageId');
const impressionData = deepAccess(bid, 'ortb2Imp.ext.data');
const gpid = deepAccess(impressionData, 'pbadslot') || deepAccess(impressionData, 'adserver.adslot');
const gpid = deepAccess(bid, 'ortb2Imp.ext.gpid');

reqObj.sizes = getSizes(bid);
reqObj.bidId = getBidIdParameter('bidId', bid);
Expand Down
73 changes: 14 additions & 59 deletions test/spec/modules/teadsBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -614,15 +614,13 @@ describe('teadsBidAdapter', () => {
}
];

it('should add gpid if ortb2Imp.ext.data.pbadslot is present and is non empty (and ortb2Imp.ext.data.adserver.adslot is not present)', function () {
it('should add gpid if ortb2Imp.ext.gpid is present and is non empty', function () {
const updatedBidRequests = bidRequests.map(function(bidRequest, index) {
return {
...bidRequest,
ortb2Imp: {
ext: {
data: {
pbadslot: '1111/home-left-' + index
}
gpid: '1111/home-left-' + index
}
}
};
Expand All @@ -635,41 +633,12 @@ describe('teadsBidAdapter', () => {
expect(payload.data[1].gpid).to.equal('1111/home-left-1');
});

it('should add gpid if ortb2Imp.ext.data.pbadslot is present and is non empty (even if ortb2Imp.ext.data.adserver.adslot is present and is non empty too)', function () {
const updatedBidRequests = bidRequests.map(function(bidRequest, index) {
return {
...bidRequest,
ortb2Imp: {
ext: {
data: {
pbadslot: '1111/home-left-' + index,
adserver: {
adslot: '1111/home-left/div-' + index
}
}
}
}
};
}
);
const request = spec.buildRequests(updatedBidRequests, bidderResquestDefault);
const payload = JSON.parse(request.data);

expect(payload.data[0].gpid).to.equal('1111/home-left-0');
expect(payload.data[1].gpid).to.equal('1111/home-left-1');
});

it('should not add gpid if both ortb2Imp.ext.data.pbadslot and ortb2Imp.ext.data.adserver.adslot are present but empty', function () {
it('should not add gpid if ortb2Imp.ext.gpid is present but empty', function () {
const updatedBidRequests = bidRequests.map(bidRequest => ({
...bidRequest,
ortb2Imp: {
ext: {
data: {
pbadslot: '',
adserver: {
adslot: ''
}
}
gpid: ''
}
}
}));
Expand All @@ -682,36 +651,22 @@ describe('teadsBidAdapter', () => {
});
});

it('should not add gpid if both ortb2Imp.ext.data.pbadslot and ortb2Imp.ext.data.adserver.adslot are not present', function () {
const request = spec.buildRequests(bidRequests, bidderResquestDefault);
it('should not add gpid if ortb2Imp.ext.gpid is not present', function () {
const updatedBidRequests = bidRequests.map(bidRequest => ({
...bidRequest,
ortb2Imp: {
ext: {
}
}
}));

const request = spec.buildRequests(updatedBidRequests, bidderResquestDefault);
const payload = JSON.parse(request.data);

return payload.data.forEach(bid => {
expect(bid).not.to.have.property('gpid');
});
});

it('should add gpid if ortb2Imp.ext.data.pbadslot is not present but ortb2Imp.ext.data.adserver.adslot is present and is non empty', function () {
const updatedBidRequests = bidRequests.map(function(bidRequest, index) {
return {
...bidRequest,
ortb2Imp: {
ext: {
data: {
adserver: {
adslot: '1111/home-left-' + index
}
}
}
}
};
});
const request = spec.buildRequests(updatedBidRequests, bidderResquestDefault);
const payload = JSON.parse(request.data);

expect(payload.data[0].gpid).to.equal('1111/home-left-0');
expect(payload.data[1].gpid).to.equal('1111/home-left-1');
});
});

function checkMediaTypesSizes(mediaTypes, expectedSizes) {
Expand Down