diff --git a/modules/seedtagBidAdapter.js b/modules/seedtagBidAdapter.js index d649999c438..4cde02c690e 100644 --- a/modules/seedtagBidAdapter.js +++ b/modules/seedtagBidAdapter.js @@ -18,12 +18,6 @@ const BIDDER_CODE = 'seedtag'; const SEEDTAG_ALIAS = 'st'; const SEEDTAG_SSP_ENDPOINT = 'https://s.seedtag.com/c/hb/bid'; const SEEDTAG_SSP_ONTIMEOUT_ENDPOINT = 'https://s.seedtag.com/se/hb/timeout'; -const ALLOWED_DISPLAY_PLACEMENTS = [ - 'inScreen', - 'inImage', - 'inArticle', - 'inBanner', -]; // Global Vendor List Id // https://iabeurope.eu/vendor-list-tcf-v2-0/ @@ -95,8 +89,7 @@ function hasMandatoryDisplayParams(bid) { const p = bid.params; return ( !!p.publisherId && - !!p.adUnitId && - ALLOWED_DISPLAY_PLACEMENTS.indexOf(p.placement) > -1 + !!p.adUnitId ); } @@ -111,19 +104,7 @@ function hasMandatoryVideoParams(bid) { isArray(videoParams.playerSize) && videoParams.playerSize.length > 0; - switch (bid.params.placement) { - // instream accept only video format - case 'inStream': - return isValid && (videoParams.context === 'instream' || videoParams.context === 'outstream'); - // outstream accept banner/native/video format - default: - return ( - isValid && - videoParams.context === 'outstream' && - hasBannerMediaType(bid) && - hasMandatoryDisplayParams(bid) - ); - } + return isValid } function buildBidRequest(validBidRequest) { @@ -172,6 +153,10 @@ function getVideoParams(validBidRequest) { return videoParams; } +function isVideoOutstream(validBidRequest) { + return getVideoParams(validBidRequest).context === 'outstream'; +} + function buildBidResponse(seedtagBid) { const mediaType = mapMediaType(seedtagBid.mediaType); const bid = { @@ -286,9 +271,19 @@ export const spec = { * @return boolean True if this is a valid bid, and false otherwise. */ isBidRequestValid(bid) { - return hasVideoMediaType(bid) - ? hasMandatoryVideoParams(bid) - : hasMandatoryDisplayParams(bid); + const hasVideo = hasVideoMediaType(bid); + const hasBanner = hasBannerMediaType(bid); + + // when accept both mediatype but it must be outstream + if (hasVideo && hasBanner) { + return hasMandatoryVideoParams(bid) && isVideoOutstream(bid) && hasMandatoryDisplayParams(bid); + } else if (hasVideo) { + return hasMandatoryVideoParams(bid); + } else if (hasBanner) { + return hasMandatoryDisplayParams(bid); + } else { + return false; + } }, /** diff --git a/test/spec/modules/seedtagBidAdapter_spec.js b/test/spec/modules/seedtagBidAdapter_spec.js index 4032d2a280c..db19d71f23f 100644 --- a/test/spec/modules/seedtagBidAdapter_spec.js +++ b/test/spec/modules/seedtagBidAdapter_spec.js @@ -49,15 +49,13 @@ function createInStreamSlotConfig(mediaType) { return getSlotConfigs(mediaType, { publisherId: PUBLISHER_ID, adUnitId: ADUNIT_ID, - placement: 'inStream', }); } -const createBannerSlotConfig = (placement, mediatypes) => { +const createBannerSlotConfig = (mediatypes) => { return getSlotConfigs(mediatypes || { banner: {} }, { publisherId: PUBLISHER_ID, adUnitId: ADUNIT_ID, - placement, }); }; @@ -72,64 +70,69 @@ describe('Seedtag Adapter', function () { describe('isBidRequestValid method', function () { describe('returns true', function () { describe('when banner slot config has all mandatory params', () => { - const placements = ['inBanner', 'inImage', 'inScreen', 'inArticle']; - placements.forEach((placement) => { - it(placement + 'should be valid', function () { + it('should be valid', function () { + const isBidRequestValid = spec.isBidRequestValid( + createBannerSlotConfig() + ); + expect(isBidRequestValid).to.equal(true); + }); + + it('should be valid when has display and video mediatypes, and video context is outstream', + function () { const isBidRequestValid = spec.isBidRequestValid( - createBannerSlotConfig(placement) + createBannerSlotConfig({ + banner: {}, + video: { + context: 'outstream', + playerSize: [[600, 200]], + }, + }) ); expect(isBidRequestValid).to.equal(true); - }); - - it( - placement + - ' should be valid when has display and video mediatypes, and video context is outstream', - function () { - const isBidRequestValid = spec.isBidRequestValid( - createBannerSlotConfig(placement, { - banner: {}, - video: { - context: 'outstream', - playerSize: [[600, 200]], - }, - }) - ); - expect(isBidRequestValid).to.equal(true); - } - ); + } + ); - it( - placement + - ' shouldn\'t be valid when has only video mediatypes, and video context is outstream', - function () { - const isBidRequestValid = spec.isBidRequestValid( - createBannerSlotConfig(placement, { - video: { - context: 'outstream', - playerSize: [[600, 200]], - }, - }) - ); - expect(isBidRequestValid).to.equal(false); - } - ); - it( - placement + - " shouldn't be valid when has display and video mediatypes, and video context is instream", - function () { - const isBidRequestValid = spec.isBidRequestValid( - createBannerSlotConfig(placement, { - banner: {}, - video: { - context: 'instream', - playerSize: [[600, 200]], - }, - }) - ); - expect(isBidRequestValid).to.equal(false); - } - ); - }); + it('should be valid when has only video mediatypes, and video context is outstream', + function () { + const isBidRequestValid = spec.isBidRequestValid( + createBannerSlotConfig({ + video: { + context: 'outstream', + playerSize: [[600, 200]], + }, + }) + ); + expect(isBidRequestValid).to.equal(true); + } + ); + it('should be valid when has display and video mediatypes, and video context is instream', + function () { + const isBidRequestValid = spec.isBidRequestValid( + createBannerSlotConfig({ + banner: {}, + video: { + context: 'instream', + playerSize: [[600, 200]], + }, + }) + ); + expect(isBidRequestValid).to.equal(false); + } + ); + it("shouldn't be valid when has display and video mediatypes, and video context is instream", + function () { + const isBidRequestValid = spec.isBidRequestValid( + createBannerSlotConfig({ + banner: {}, + video: { + context: 'instream', + playerSize: [[600, 200]], + }, + }) + ); + expect(isBidRequestValid).to.equal(false); + } + ); }); describe('when video slot has all mandatory params', function () { it('should return true, when video context is instream', function () { @@ -142,7 +145,7 @@ describe('Seedtag Adapter', function () { const isBidRequestValid = spec.isBidRequestValid(slotConfig); expect(isBidRequestValid).to.equal(true); }); - it('should return true, when video context is instream and mediatype is video and banner', function () { + it('should return false, when video context is instream and mediatype is video and banner', function () { const slotConfig = createInStreamSlotConfig({ video: { context: 'instream', @@ -151,61 +154,8 @@ describe('Seedtag Adapter', function () { banner: {}, }); const isBidRequestValid = spec.isBidRequestValid(slotConfig); - expect(isBidRequestValid).to.equal(true); - }); - it('should return false, when video context is instream, but placement is not inStream', function () { - const slotConfig = getSlotConfigs( - { - video: { - context: 'instream', - playerSize: [[600, 200]], - }, - }, - { - publisherId: PUBLISHER_ID, - adUnitId: ADUNIT_ID, - placement: 'inBanner', - } - ); - const isBidRequestValid = spec.isBidRequestValid(slotConfig); expect(isBidRequestValid).to.equal(false); }); - - it('should return true when placement is inStream and video context is outstream', function () { - const slotConfig = getSlotConfigs( - { - video: { - context: 'instream', - playerSize: [[600, 200]], - }, - }, - { - publisherId: PUBLISHER_ID, - adUnitId: ADUNIT_ID, - placement: 'inStream', - } - ); - const isBidRequestValid = spec.isBidRequestValid(slotConfig); - expect(isBidRequestValid).to.equal(true); - }); - - it('should return true when placement is inStream and video context is instream', function () { - const slotConfig = getSlotConfigs( - { - video: { - context: 'outstream', - playerSize: [[600, 200]], - }, - }, - { - publisherId: PUBLISHER_ID, - adUnitId: ADUNIT_ID, - placement: 'inStream', - } - ); - const isBidRequestValid = spec.isBidRequestValid(slotConfig); - expect(isBidRequestValid).to.equal(true); - }); }); }); describe('returns false', function () { @@ -217,7 +167,6 @@ describe('Seedtag Adapter', function () { const isBidRequestValid = spec.isBidRequestValid( createSlotConfig({ adUnitId: ADUNIT_ID, - placement: 'inBanner', }) ); expect(isBidRequestValid).to.equal(false); @@ -226,26 +175,6 @@ describe('Seedtag Adapter', function () { const isBidRequestValid = spec.isBidRequestValid( createSlotConfig({ publisherId: PUBLISHER_ID, - placement: 'inBanner', - }) - ); - expect(isBidRequestValid).to.equal(false); - }); - it('does not have the placement.', function () { - const isBidRequestValid = spec.isBidRequestValid( - createSlotConfig({ - publisherId: PUBLISHER_ID, - adUnitId: ADUNIT_ID, - }) - ); - expect(isBidRequestValid).to.equal(false); - }); - it('does not have a the correct placement.', function () { - const isBidRequestValid = spec.isBidRequestValid( - createSlotConfig({ - publisherId: PUBLISHER_ID, - adUnitId: ADUNIT_ID, - placement: 'another_thing', }) ); expect(isBidRequestValid).to.equal(false); @@ -293,12 +222,10 @@ describe('Seedtag Adapter', function () { const mandatoryDisplayParams = { publisherId: PUBLISHER_ID, adUnitId: ADUNIT_ID, - placement: 'inBanner', }; const mandatoryVideoParams = { publisherId: PUBLISHER_ID, adUnitId: ADUNIT_ID, - placement: 'inStream', }; const validBidRequests = [ getSlotConfigs({ banner: {} }, mandatoryDisplayParams),