From 54a638374210ee232a495e3090a6f6ff69380073 Mon Sep 17 00:00:00 2001 From: Demetrio Girardi Date: Sat, 9 Nov 2024 12:32:46 -0800 Subject: [PATCH] Core: allow renderers without URLs (#12426) --- src/auction.js | 6 +++--- test/spec/auctionmanager_spec.js | 28 ++++++++++++++++++++-------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/auction.js b/src/auction.js index f122840affc..759397275d5 100644 --- a/src/auction.js +++ b/src/auction.js @@ -635,15 +635,15 @@ function getPreparedBidForAuction(bid, {index = auctionManager.index} = {}) { var renderer = null; // the renderer for the mediaType takes precendence - if (mediaTypeRenderer && mediaTypeRenderer.url && mediaTypeRenderer.render && !(mediaTypeRenderer.backupOnly === true && bid.renderer)) { + if (mediaTypeRenderer && mediaTypeRenderer.render && !(mediaTypeRenderer.backupOnly === true && bid.renderer)) { renderer = mediaTypeRenderer; - } else if (bidRenderer && bidRenderer.url && bidRenderer.render && !(bidRenderer.backupOnly === true && bid.renderer)) { + } else if (bidRenderer && bidRenderer.render && !(bidRenderer.backupOnly === true && bid.renderer)) { renderer = bidRenderer; } if (renderer) { // be aware, an adapter could already have installed the bidder, in which case this overwrite's the existing adapter - bid.renderer = Renderer.install({ url: renderer.url, config: renderer.options });// rename options to config, to make it consistent? + bid.renderer = Renderer.install({ url: renderer.url, config: renderer.options, renderNow: renderer.url == null });// rename options to config, to make it consistent? bid.renderer.setRender(renderer.render); } diff --git a/test/spec/auctionmanager_spec.js b/test/spec/auctionmanager_spec.js index 6a8a826bec5..afc90fae342 100644 --- a/test/spec/auctionmanager_spec.js +++ b/test/spec/auctionmanager_spec.js @@ -1044,26 +1044,38 @@ describe('auctionmanager.js', function () { Object.entries({ 'on adUnit': () => adUnits[0], 'on bid': () => bidderRequests[0].bids[0], + 'on mediatype': () => bidderRequests[0].bids[0].mediaTypes.banner, }).forEach(([t, getObj]) => { - it(t, () => { - let renderer = { + let renderer, bid; + beforeEach(() => { + renderer = { url: 'renderer.js', render: (bid) => bid }; + }) - let bids1 = Object.assign({}, + function getBid() { + let bid = Object.assign({}, bids[0], { bidderCode: BIDDER_CODE, - mediaType: 'video-outstream', + mediaType: 'banner', } ); Object.assign(getObj(), {renderer}); - spec.interpretResponse.returns(bids1); + spec.interpretResponse.returns(bid); auction.callBids(); - const addedBid = auction.getBidsReceived().pop(); - assert.equal(addedBid.renderer.url, 'renderer.js'); - }) + return auction.getBidsReceived().pop(); + } + + it(t, () => { + expect(getBid().renderer.url).to.eql('renderer.js'); + }); + + it('allows renderers without URL', () => { + delete renderer.url; + expect(getBid().renderer.renderNow).to.be.true; + }); }) })