From 75df072223a16987461a1d55c31227efbbd47e7c Mon Sep 17 00:00:00 2001 From: Lisa Benmore Date: Tue, 28 Sep 2021 17:13:56 -0700 Subject: [PATCH 1/2] Gumgum: ADTS-157 use nearest matching h/w dimensions from bid request --- modules/gumgumBidAdapter.js | 10 ++++++++-- test/spec/modules/gumgumBidAdapter_spec.js | 23 +++++++++++++++++----- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/modules/gumgumBidAdapter.js b/modules/gumgumBidAdapter.js index 756d204e00d..eef98100a29 100644 --- a/modules/gumgumBidAdapter.js +++ b/modules/gumgumBidAdapter.js @@ -1,5 +1,6 @@ -import { logError, logWarn, parseSizesInput, _each, deepAccess } from '../src/utils.js'; import { BANNER, VIDEO } from '../src/mediaTypes.js'; +import { _each, deepAccess, logError, logWarn, parseSizesInput } from '../src/utils.js'; + import { config } from '../src/config.js' import { getStorageManager } from '../src/storageManager.js'; import includes from 'core-js-pure/features/array/includes'; @@ -488,7 +489,12 @@ function interpretResponse(serverResponse, bidRequest) { } else if (product === 5 && includes(sizes, '1x1')) { sizes = ['1x1']; } else if (product === 2 && includes(sizes, '1x1')) { - sizes = responseWidth && responseHeight ? [`${responseWidth}x${responseHeight}`] : parseSizesInput(bidRequest.sizes) + const requestSizesThatMatchResponse = (bidRequest.sizes && bidRequest.sizes.reduce((result, current) => { + const [ width, height ] = current; + if (responseWidth === width || responseHeight === height) result.push(current.join('x')); + return result + }, [])) || []; + sizes = requestSizesThatMatchResponse.length ? requestSizesThatMatchResponse : utils.parseSizesInput(bidRequest.sizes) } let [width, height] = sizes[0].split('x'); diff --git a/test/spec/modules/gumgumBidAdapter_spec.js b/test/spec/modules/gumgumBidAdapter_spec.js index e11123729e0..713bd514c0c 100644 --- a/test/spec/modules/gumgumBidAdapter_spec.js +++ b/test/spec/modules/gumgumBidAdapter_spec.js @@ -683,11 +683,24 @@ describe('gumgumAdapter', function () { expect(result[0].height).to.equal('1'); }); - it('uses response width and height for inscreen product', function () { - const result = spec.interpretResponse({ body: serverResponse }, bidRequest)[0]; - expect(result.width).to.equal(serverResponse.ad.width.toString()); - expect(result.height).to.equal(serverResponse.ad.height.toString()); - }); + it('uses request size that nearest matches response size for in-screen', function () { + const request = { ...bidRequest }; + const body = { ...serverResponse }; + const expectedSize = [ 300, 50 ]; + let result; + + request.pi = 2; + request.sizes.unshift(expectedSize); + + // typical ad server response values for in-screen + body.ad.width = 300; + body.ad.height = 100; + + result = spec.interpretResponse({ body }, request)[0]; + + expect(result.width = expectedSize[0]); + expect(result.height = expectedSize[1]); + }) it('defaults to use bidRequest sizes', function () { const { ad, jcsi, pag, thms, meta } = serverResponse From f79c477684c3cedca7604034e2ba1c0bc379069d Mon Sep 17 00:00:00 2001 From: Lisa Benmore Date: Wed, 29 Sep 2021 08:48:51 -0700 Subject: [PATCH 2/2] updated method calls from utils --- modules/gumgumBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/gumgumBidAdapter.js b/modules/gumgumBidAdapter.js index eef98100a29..76fb7023bb1 100644 --- a/modules/gumgumBidAdapter.js +++ b/modules/gumgumBidAdapter.js @@ -494,7 +494,7 @@ function interpretResponse(serverResponse, bidRequest) { if (responseWidth === width || responseHeight === height) result.push(current.join('x')); return result }, [])) || []; - sizes = requestSizesThatMatchResponse.length ? requestSizesThatMatchResponse : utils.parseSizesInput(bidRequest.sizes) + sizes = requestSizesThatMatchResponse.length ? requestSizesThatMatchResponse : parseSizesInput(bidRequest.sizes) } let [width, height] = sizes[0].split('x');