diff --git a/modules/showheroes-bsBidAdapter.js b/modules/showheroes-bsBidAdapter.js index d6ebcc5ceab..71a017120f0 100644 --- a/modules/showheroes-bsBidAdapter.js +++ b/modules/showheroes-bsBidAdapter.js @@ -8,7 +8,7 @@ import { import { Renderer } from '../src/Renderer.js'; import { ortbConverter } from '../libraries/ortbConverter/converter.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { VIDEO } from '../src/mediaTypes.js'; +import { BANNER, VIDEO } from '../src/mediaTypes.js'; const ENDPOINT = 'https://ads.viralize.tv/openrtb2/auction/'; const BIDDER_CODE = 'showheroes-bs'; @@ -19,12 +19,13 @@ const converter = ortbConverter({ netRevenue: true, ttl: TTL, currency: 'EUR', - mediaType: VIDEO, }, imp(buildImp, bidRequest, context) { const imp = buildImp(bidRequest, context); const videoContext = deepAccess(bidRequest, 'mediaTypes.video.context'); - deepSetValue(imp, 'video.ext.context', videoContext); + if (videoContext) { + deepSetValue(imp, 'video.ext.context', videoContext); + } imp.ext = imp.ext || {}; imp.ext.params = bidRequest.params; imp.ext.adUnitCode = bidRequest.adUnitCode; @@ -75,14 +76,14 @@ export const spec = { code: BIDDER_CODE, gvlid: GVLID, aliases: ['showheroesBs'], - supportedMediaTypes: [VIDEO], + supportedMediaTypes: [VIDEO, BANNER], isBidRequestValid: (bid) => { return !!bid.params.unitId; }, buildRequests: (bidRequests, bidderRequest) => { const QA = bidRequests[0].params.qa; - const ortbData = converter.toORTB({ bidRequests, bidderRequest }) + const ortbData = converter.toORTB({ bidRequests, bidderRequest }); return { url: QA?.endpoint || ENDPOINT, @@ -95,8 +96,7 @@ export const spec = { return []; } - const bids = converter.fromORTB({response: response.body, request: request.data}).bids; - return bids; + return converter.fromORTB({response: response.body, request: request.data}).bids; }, getUserSyncs: (syncOptions, serverResponses) => { const syncs = []; diff --git a/test/spec/modules/showheroes-bsBidAdapter_spec.js b/test/spec/modules/showheroes-bsBidAdapter_spec.js index 564df497628..290447c3792 100644 --- a/test/spec/modules/showheroes-bsBidAdapter_spec.js +++ b/test/spec/modules/showheroes-bsBidAdapter_spec.js @@ -1,6 +1,7 @@ import { expect } from 'chai' import { spec } from 'modules/showheroes-bsBidAdapter.js' import { addFPDToBidderRequest } from '../../helpers/fpd.js'; +import { getGlobal } from '../../../src/prebidGlobal.js'; import 'modules/priceFloors.js'; import 'modules/consentManagementTcf.js'; import 'modules/consentManagementUsp.js'; @@ -78,7 +79,25 @@ const bidRequestOutstreamV2 = { } } +const bidRequestBannerV2 = { + ...bidRequestCommonParamsV2, + ...{ + mediaTypes: { + banner: { + sizes: [[300, 250]], + } + } + } +} + describe('shBidAdapter', () => { + before(() => { + // without this change in the Renderer.js file exception is thrown + // because 'adUnits' is undefined, and there is a call that does + // 'pbjs.adUnits.find' in the Renderer.js file + getGlobal().adUnits = []; + }); + it('validates request', () => { const bid = { params: { @@ -139,6 +158,7 @@ describe('shBidAdapter', () => { adm: vastXml, impid: '38b373e1e31c18', crid: 'c_38b373e1e31c18', + mtype: 2, // 2 = video adomain: adomain, ext: { callbacks: { @@ -249,6 +269,58 @@ describe('shBidAdapter', () => { expect(bid.vastUrl).to.eql(vastUrl); }) } + + it('should get correct bid response when type is banner', function () { + const request = spec.buildRequests([bidRequestBannerV2], bidderRequest); + const bannerResponse = { + cur: 'EUR', + seatbid: [{ + bid: [{ + price: 1, + w: 300, + h: 250, + adm: '