From 171d16d53d128d8e5b4fa71b472ef78863dc7d3e Mon Sep 17 00:00:00 2001 From: Filip Stamenkovic Date: Thu, 17 Jul 2025 20:11:24 +0200 Subject: [PATCH 1/2] add banner support to showheroes --- modules/showheroes-bsBidAdapter.js | 14 ++-- .../modules/showheroes-bsBidAdapter_spec.js | 64 +++++++++++++++++++ 2 files changed, 71 insertions(+), 7 deletions(-) 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..196f3b7c50c 100644 --- a/test/spec/modules/showheroes-bsBidAdapter_spec.js +++ b/test/spec/modules/showheroes-bsBidAdapter_spec.js @@ -78,6 +78,17 @@ const bidRequestOutstreamV2 = { } } +const bidRequestBannerV2 = { + ...bidRequestCommonParamsV2, + ...{ + mediaTypes: { + banner: { + sizes: [[300, 250]], + } + } + } +} + describe('shBidAdapter', () => { it('validates request', () => { const bid = { @@ -139,6 +150,7 @@ describe('shBidAdapter', () => { adm: vastXml, impid: '38b373e1e31c18', crid: 'c_38b373e1e31c18', + mtype: 2, // 2 = video adomain: adomain, ext: { callbacks: { @@ -249,6 +261,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: '
test banner
', + impid: '38b373e1e31c18', + crid: 'c_38b373e1e31c18', + mtype: 1, // 1 = banner + adomain: adomain, + ext: { + callbacks: { + won: [callback_won], + }, + extra: 'test', + }, + }], + seat: 'showheroes', + }] + }; + + const expectedResponse = [ + { + cpm: 1, + creativeId: 'c_38b373e1e31c18', + creative_id: 'c_38b373e1e31c18', + currency: 'EUR', + width: 300, + height: 250, + mediaType: 'banner', + netRevenue: true, + requestId: '38b373e1e31c18', + ttl: 300, + meta: { + advertiserDomains: adomain, + }, + ad: '
test banner
', + callbacks: { + won: [callback_won], + }, + extra: 'test', + } + ]; + + const result = spec.interpretResponse({ 'body': bannerResponse }, request); + expect(result).to.deep.equal(expectedResponse); + }) }); describe('getUserSyncs', function () { From f3ca6b5154d1235f0169fb5b028eb235e8d2e468 Mon Sep 17 00:00:00 2001 From: Filip Stamenkovic Date: Wed, 23 Jul 2025 13:51:04 +0200 Subject: [PATCH 2/2] fix tests --- test/spec/modules/showheroes-bsBidAdapter_spec.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/spec/modules/showheroes-bsBidAdapter_spec.js b/test/spec/modules/showheroes-bsBidAdapter_spec.js index 196f3b7c50c..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'; @@ -90,6 +91,13 @@ const bidRequestBannerV2 = { } 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: {