Skip to content

Commit

Permalink
VIS.X Bid Adapter: fix handling of bid response (#7233)
Browse files Browse the repository at this point in the history
* VIS.X: add failing test

* VIS.X: additional check for instream video

* VIS.X: missing semicolon
  • Loading branch information
mk0x9 authored Jul 29, 2021
1 parent 9d7fdc8 commit 0f7d5fb
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 2 deletions.
8 changes: 6 additions & 2 deletions modules/visxBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ function _addBidResponse(serverBid, bidsMap, currency, bidResponses, bidsWithout
bidResponse.ext = serverBid.ext.prebid;
}

if (!_isVideoBid(bid)) {
if (!_isVideoInstreamBid(bid)) {
bidResponse.ad = serverBid.adm;
} else {
bidResponse.vastXml = serverBid.adm;
Expand Down Expand Up @@ -298,14 +298,18 @@ function _isVideoBid(bid) {
return bid.mediaType === VIDEO || deepAccess(bid, 'mediaTypes.video');
}

function _isVideoInstreamBid(bid) {
return _isVideoBid(bid) && deepAccess(bid, 'mediaTypes.video', {}).context === VIDEO_INSTREAM;
}

function _isBannerBid(bid) {
return bid.mediaType === BANNER || deepAccess(bid, 'mediaTypes.banner');
}

function _isValidVideoBid(bid, logErrors = false) {
let result = true;
const videoMediaType = deepAccess(bid, 'mediaTypes.video');
if (videoMediaType.context !== VIDEO_INSTREAM) {
if (!_isVideoInstreamBid(bid)) {
if (logErrors) {
logError(LOG_ERROR_MESS.onlyVideoInstream);
}
Expand Down
51 changes: 51 additions & 0 deletions test/spec/modules/visxBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,57 @@ describe('VisxAdapter', function () {
expect(result).to.deep.equal(expectedResponse);
});

it('handles multiformat bid response with outstream+banner as banner', function () {
const fullResponse = [
{'bid': [{'price': 0.5, 'adm': '<VAST/>', 'auid': 903537, 'w': 400, 'h': 300, 'cur': 'EUR', 'mediaType': 'video'}], 'seat': '1'},
];
const bidRequests = [
{
'bidder': 'visx',
'params': {
'uid': '903537'
},
'adUnitCode': 'adunit-code-1',
'mediaTypes': {
'video': {
'context': 'outstream',
'playerSize': [400, 300],
'mimes': ['video/mp4'],
'protocols': [3, 6]
}
},
'banner': {
'sizes': []
},
'sizes': [[400, 300]],
'bidId': '2164be6358b9',
'bidderRequestId': '106efe3247',
'auctionId': '32a1f276cb87cb8',
}
];
const request = spec.buildRequests(bidRequests);
const expectedResponse = [
{
'ad': '<VAST/>',
'requestId': '2164be6358b9',
'cpm': 0.5,
'creativeId': 903537,
'dealId': undefined,
'width': 400,
'height': 300,
'currency': 'EUR',
'netRevenue': true,
'ttl': 360,
'meta': {
'advertiserDomains': [],
'mediaType': 'video',
},
}
];
const result = spec.interpretResponse({'body': {'seatbid': fullResponse}}, request);
expect(result).to.deep.equal(expectedResponse);
});

it('should get right ext data in bid response', function () {
const bidRequests = [
{
Expand Down

0 comments on commit 0f7d5fb

Please sign in to comment.