From b8a7ee4b979c0aee2a254a43c7f6ee22bc5f284f Mon Sep 17 00:00:00 2001 From: Adam Browning <19834421+adam-browning@users.noreply.github.com> Date: Wed, 13 Oct 2021 18:07:28 +0300 Subject: [PATCH] Yahoo SSP Bid Adapter: fix for adId (#7571) * Added ysspBidAdapter * Renaming to Yahoo SSP * changing all internal references from yssp to yahoossp * added alias for aol, onemobile, onedisplay * Removing aliases from adapter * Pass EU consent string in the correct location in the payload. * WIP * WIP * pubId support 1st draft * WIP * WIP * WIP pubId unit tests * WIP * WIP * pubid tests stable * pubId support * md update * site id inventory mapping fix * update to md file * update to md file * order userId list * added user id yahoo.com * placementId support * inventoryId & placementId stable unit tests * maintainer group update * maintainer group update * Redirecting to PubGW urls without .ads. * url switch fix * fetch specific utils * lint * change inventoryId to siteId * WIP * custom key-value pair support * WIP * WIP * WIP * WIP * WIP * WIP * updated FPD support * unit tests stable * unit tests stable * check includes * md file update * code review updates * WIP * WIP * code review comments * WIP * review comments implemented * update to md file * update to md file * update to md file * type fix * type fix * typo fix * readme structure * typo * yarn.lock removed * revert yarn.lock * SRA Mode adId fix * SRA adId patch v1.0.1 * SRA adId patch v1.0.1 Co-authored-by: slimkrazy Co-authored-by: Samuel Adu --- modules/yahoosspBidAdapter.js | 4 +-- test/spec/modules/yahoosspBidAdapter_spec.js | 29 +++++++++++++++++++- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/modules/yahoosspBidAdapter.js b/modules/yahoosspBidAdapter.js index 35fc2ba7b59..ac91596f8d0 100644 --- a/modules/yahoosspBidAdapter.js +++ b/modules/yahoosspBidAdapter.js @@ -6,7 +6,7 @@ import { Renderer } from '../src/Renderer.js'; const INTEGRATION_METHOD = 'prebid.js'; const BIDDER_CODE = 'yahoossp'; -const ADAPTER_VERSION = '1.0.0'; +const ADAPTER_VERSION = '1.0.1'; const PREBID_VERSION = '$prebid.version$'; const DEFAULT_BID_TTL = 300; const TEST_MODE_DCN = '8a969516017a7a396ec539d97f540011'; @@ -581,7 +581,7 @@ export const spec = { let cpm = (bid.ext && bid.ext.encp) ? bid.ext.encp : bid.price; let bidResponse = { - adId: bid.id, + adId: deepAccess(bid, 'adId') ? bid.adId : bid.impid || bid.crid, adUnitCode: bidderRequest.adUnitCode, requestId: bid.impid, bidderCode: spec.code, diff --git a/test/spec/modules/yahoosspBidAdapter_spec.js b/test/spec/modules/yahoosspBidAdapter_spec.js index 9c24ecedda1..5eb82b399cc 100644 --- a/test/spec/modules/yahoosspBidAdapter_spec.js +++ b/test/spec/modules/yahoosspBidAdapter_spec.js @@ -11,7 +11,7 @@ const DEFAULT_AD_UNIT_CODE = '/19968336/header-bid-tag-1'; const DEFAULT_AD_UNIT_TYPE = 'banner'; const DEFAULT_PARAMS_BID_OVERRIDE = {}; const DEFAULT_VIDEO_CONTEXT = 'instream'; -const ADAPTER_VERSION = '1.0.0'; +const ADAPTER_VERSION = '1.0.1'; const PREBID_VERSION = '$prebid.version$'; const INTEGRATION_METHOD = 'prebid.js'; @@ -1252,6 +1252,33 @@ describe('YahooSSP Bid Adapter:', () => { }) }); + describe('bid response Ad ID / Creative ID', () => { + it('should use adId if it exists in the bid-response', () => { + const { serverResponse, bidderRequest } = generateResponseMock('banner'); + const adId = 'bid-response-adId'; + serverResponse.body.seatbid[0].bid[0].adId = adId; + const response = spec.interpretResponse(serverResponse, {bidderRequest}); + expect(response[0].adId).to.equal(adId); + }); + + it('should use impid if adId does not exist in the bid-response', () => { + const { serverResponse, bidderRequest } = generateResponseMock('banner'); + const impid = '25b6c429c1f52f'; + serverResponse.body.seatbid[0].bid[0].impid = impid; + const response = spec.interpretResponse(serverResponse, {bidderRequest}); + expect(response[0].adId).to.equal(impid); + }); + + it('should use crid if adId & impid do not exist in the bid-response', () => { + const { serverResponse, bidderRequest } = generateResponseMock('banner'); + const crid = 'passback-12579'; + serverResponse.body.seatbid[0].bid[0].impid = undefined; + serverResponse.body.seatbid[0].bid[0].crid = crid; + const response = spec.interpretResponse(serverResponse, {bidderRequest}); + expect(response[0].adId).to.equal(crid); + }); + }); + describe('Time To Live (ttl)', () => { const UNSUPPORTED_TTL_FORMATS = ['string', [1, 2, 3], true, false, null, undefined]; UNSUPPORTED_TTL_FORMATS.forEach(param => {