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

add default sizes value for appnexus native requests #3602

Merged
merged 1 commit into from
Mar 5, 2019
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: 3 additions & 0 deletions modules/appnexusBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,9 @@ function bidToTag(bid) {

if (bid.mediaType === NATIVE || utils.deepAccess(bid, `mediaTypes.${NATIVE}`)) {
tag.ad_types.push(NATIVE);
if (tag.sizes.length === 0) {
tag.sizes = transformSizes([1, 1]);
}

if (bid.nativeParams) {
const nativeRequest = buildNativeRequest(bid.nativeParams);
Expand Down
24 changes: 24 additions & 0 deletions test/spec/modules/appnexusBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,30 @@ describe('AppNexusAdapter', function () {
});
});

it('should always populated tags[].sizes with 1,1 for native if otherwise not defined', function () {
let bidRequest = Object.assign({},
bidRequests[0],
{
mediaType: 'native',
nativeParams: {
image: { required: true }
}
}
);
bidRequest.sizes = [[150, 100], [300, 250]];

let request = spec.buildRequests([bidRequest]);
let payload = JSON.parse(request.data);
expect(payload.tags[0].sizes).to.deep.equal([{width: 150, height: 100}, {width: 300, height: 250}]);

delete bidRequest.sizes;

request = spec.buildRequests([bidRequest]);
payload = JSON.parse(request.data);

expect(payload.tags[0].sizes).to.deep.equal([{width: 1, height: 1}]);
});

it('should convert keyword params to proper form and attaches to request', function () {
let bidRequest = Object.assign({},
bidRequests[0],
Expand Down
81 changes: 80 additions & 1 deletion test/spec/unit/core/adapterManager_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,7 @@ describe('adapterManager tests', function () {
setSizeConfig([]);
});

it('should not filter bids w/ no labels', function () {
it('should not filter banner bids w/ no labels', function () {
let bidRequests = adapterManager.makeBidRequests(
adUnits,
Date.now(),
Expand All @@ -933,6 +933,85 @@ describe('adapterManager tests', function () {
expect(appnexusBidRequests.bids[1].sizes).to.deep.equal(find(adUnits, adUnit => adUnit.code === appnexusBidRequests.bids[1].adUnitCode).sizes);
});

it('should not filter video bids', function () {
setSizeConfig([{
'mediaQuery': '(min-width: 768px) and (max-width: 1199px)',
'sizesSupported': [
[728, 90],
[300, 250]
],
'labels': ['tablet', 'phone']
}]);

let videoAdUnits = [{
code: 'test_video',
mediaTypes: {
video: {
playerSize: [300, 300],
context: 'outstream'
}
},
bids: [{
bidder: 'appnexus',
params: {
placementId: 13232385,
video: {
skippable: true,
playback_method: ['auto_play_sound_off']
}
}
}]
}];
let bidRequests = adapterManager.makeBidRequests(
videoAdUnits,
Date.now(),
utils.getUniqueIdentifierStr(),
function callback() {},
[]
);
expect(bidRequests[0].bids[0].sizes).to.deep.equal([300, 300]);
});

it('should not filter native bids', function () {
setSizeConfig([{
'mediaQuery': '(min-width: 768px) and (max-width: 1199px)',
'sizesSupported': [
[728, 90],
[300, 250]
],
'labels': ['tablet', 'phone']
}]);

let nativeAdUnits = [{
code: 'test_native',
sizes: [[1, 1]],
mediaTypes: {
native: {
title: { required: true },
body: { required: false },
image: { required: true },
icon: { required: false },
sponsoredBy: { required: true },
clickUrl: { required: true },
},
},
bids: [
{
bidder: 'appnexus',
params: { placementId: 13232354 }
},
]
}];
let bidRequests = adapterManager.makeBidRequests(
nativeAdUnits,
Date.now(),
utils.getUniqueIdentifierStr(),
function callback() {},
[]
);
expect(bidRequests[0].bids[0].sizes).to.deep.equal([]);
});

it('should filter sizes using size config', function () {
let validSizes = [
[728, 90],
Expand Down