Skip to content

Commit

Permalink
Yahoo Ads Bid Adapter: Fix to only set bid response renderer for vide…
Browse files Browse the repository at this point in the history
…o. (#12139)
  • Loading branch information
zach-bowman authored Sep 6, 2024
1 parent 1d094e9 commit 48916ae
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modules/yahooAdsBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ export const spec = {
};
}

if (deepAccess(bidderRequest, 'mediaTypes.video.context') === 'outstream' && !bidderRequest.renderer) {
if (deepAccess(bidderRequest, 'mediaTypes.video.context') === 'outstream' && !bidderRequest.renderer && bidResponse.mediaType === VIDEO) {
bidResponse.renderer = createRenderer(bidderRequest, bidResponse) || undefined;
}

Expand Down
70 changes: 70 additions & 0 deletions test/spec/modules/yahooAdsBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { config } from 'src/config.js';
import { BANNER, VIDEO } from 'src/mediaTypes.js';
import { spec } from 'modules/yahooAdsBidAdapter.js';
import {createEidsArray} from '../../../modules/userId/eids';
import {deepAccess} from '../../../src/utils';

const DEFAULT_BID_ID = '84ab500420319d';
const DEFAULT_BID_DCN = '2093845709823475';
Expand Down Expand Up @@ -1628,5 +1629,74 @@ describe('Yahoo Advertising Bid Adapter:', () => {
expect(response[0].bidderCode).to.be.undefined;
});
});

describe('Renderer:', () => {
it('should create and set renderer when bidder request context is outstream, bidder request renderer is falsy, and bid response mediaType is VIDEO', () => {
config.setConfig({
yahooAds: {
mode: VIDEO
}
});
const { serverResponse, bidderRequest } = generateResponseMock('video', 'vast');
bidderRequest.mediaTypes = {
video: {
context: 'outstream'
}
};
const response = spec.interpretResponse(serverResponse, {bidderRequest});
expect(deepAccess(bidderRequest, 'mediaTypes.video.context')).to.equal('outstream');
expect(bidderRequest.renderer).to.be.undefined;
expect(response[0].mediaType).to.equal('video');
expect(response[0].renderer).to.not.be.undefined;
});

it('should not create and set renderer when bidder request renderer is falsy and bid response mediaType is VIDEO, but bidder request context is not outstream,', () => {
config.setConfig({
yahooAds: {
mode: VIDEO
}
});
const { serverResponse, bidderRequest } = generateResponseMock('video', 'vast');
const response = spec.interpretResponse(serverResponse, {bidderRequest});
expect(deepAccess(bidderRequest, 'mediaTypes.video.context')).to.not.equal('outstream');
expect(bidderRequest.renderer).to.be.undefined;
expect(response[0].mediaType).to.equal('video');
expect(response[0].renderer).to.be.undefined;
});

it('should not create and set renderer when bidder request context is outstream and bid response mediaType is VIDEO, but bidder request renderer is not falsy', () => {
config.setConfig({
yahooAds: {
mode: VIDEO
}
});
const { serverResponse, bidderRequest } = generateResponseMock('video', 'vast');
bidderRequest.mediaTypes = {
video: {
context: 'outstream'
}
};
bidderRequest.renderer = 'not falsy';
const response = spec.interpretResponse(serverResponse, {bidderRequest});
expect(deepAccess(bidderRequest, 'mediaTypes.video.context')).to.equal('outstream');
expect(bidderRequest.renderer).to.not.be.undefined;
expect(response[0].mediaType).to.equal('video');
expect(response[0].renderer).to.be.undefined;
});

it('should not create and set renderer when bidder request context is outstream and bidder request renderer is falsy, but bid response mediaType is not VIDEO', () => {
const { serverResponse, bidderRequest } = generateResponseMock('banner');
bidderRequest.mediaTypes = {
video: {
context: 'outstream'
}
};
const response = spec.interpretResponse(serverResponse, {bidderRequest});
expect(deepAccess(bidderRequest, 'mediaTypes.video.context')).to.equal('outstream');
expect(bidderRequest.renderer).to.be.undefined;
expect(response[0].mediaType).to.not.equal('video');
expect(response[0].renderer).to.be.undefined;
});
});
});
});

0 comments on commit 48916ae

Please sign in to comment.