From eaae05916d31947245e5ca09aa0acf0b1b97fecd Mon Sep 17 00:00:00 2001 From: Yohan Boutin Date: Tue, 8 Nov 2022 12:04:08 +0100 Subject: [PATCH 1/9] use inBanner and inStream for video --- modules/seedtagBidAdapter.js | 59 ++-- modules/seedtagBidAdapter.md | 63 ++++ test/spec/modules/seedtagBidAdapter_spec.js | 305 ++++++++++---------- 3 files changed, 250 insertions(+), 177 deletions(-) diff --git a/modules/seedtagBidAdapter.js b/modules/seedtagBidAdapter.js index 850ac5610f5..8d74b9b288d 100644 --- a/modules/seedtagBidAdapter.js +++ b/modules/seedtagBidAdapter.js @@ -11,48 +11,57 @@ const ALLOWED_PLACEMENTS = { inImage: true, inScreen: true, inArticle: true, - banner: true, - video: true -} + inBanner: true, + inVideo: true, +}; // Global Vendor List Id // https://iabeurope.eu/vendor-list-tcf-v2-0/ const GVLID = 157; const mediaTypesMap = { - [BANNER]: 'display', - [VIDEO]: 'video' + [BANNER]: "display", + [VIDEO]: "video", }; const deviceConnection = { - FIXED: 'fixed', - MOBILE: 'mobile', - UNKNOWN: 'unknown' + FIXED: "fixed", + MOBILE: "mobile", + UNKNOWN: "unknown", }; const getConnectionType = () => { - const connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection || {} + const connection = + navigator.connection || + navigator.mozConnection || + navigator.webkitConnection || + {}; switch (connection.type || connection.effectiveType) { - case 'wifi': - case 'ethernet': - return deviceConnection.FIXED - case 'cellular': - case 'wimax': - return deviceConnection.MOBILE + case "wifi": + case "ethernet": + return deviceConnection.FIXED; + case "cellular": + case "wimax": + return deviceConnection.MOBILE; default: - const isMobile = /iPad|iPhone|iPod/.test(navigator.userAgent) || /android/i.test(navigator.userAgent) - return isMobile ? deviceConnection.UNKNOWN : deviceConnection.FIXED + const isMobile = + /iPad|iPhone|iPod/.test(navigator.userAgent) || + /android/i.test(navigator.userAgent); + return isMobile ? deviceConnection.UNKNOWN : deviceConnection.FIXED; } }; function mapMediaType(seedtagMediaType) { - if (seedtagMediaType === 'display') return BANNER; - if (seedtagMediaType === 'video') return VIDEO; + if (seedtagMediaType === "display") return BANNER; + if (seedtagMediaType === "video") return VIDEO; else return seedtagMediaType; } function hasVideoMediaType(bid) { - return (!!bid.mediaTypes && !!bid.mediaTypes.video) || (!!bid.params && !!bid.params.video) + return ( + (!!bid.mediaTypes && !!bid.mediaTypes.video) || + (!!bid.params && !!bid.params.video) + ); } function hasMandatoryParams(params) { @@ -65,11 +74,15 @@ function hasMandatoryParams(params) { } function hasMandatoryVideoParams(bid) { - const videoParams = getVideoParams(bid) + const videoParams = getVideoParams(bid); - return hasVideoMediaType(bid) && !!videoParams.playerSize && + return ( + hasVideoMediaType(bid) && + !!videoParams.playerSize && isArray(videoParams.playerSize) && - videoParams.playerSize.length > 0; + videoParams.playerSize.length > 0 && + bid.params.placement === "inStream" // only inStream is supported for video + ); } function buildBidRequest(validBidRequest) { diff --git a/modules/seedtagBidAdapter.md b/modules/seedtagBidAdapter.md index 061a254c5fa..61e7f75d373 100644 --- a/modules/seedtagBidAdapter.md +++ b/modules/seedtagBidAdapter.md @@ -59,3 +59,66 @@ const adUnits = [ } ] ``` + +## InBanner +```js +const adUnits = [ + { + code: '/21804003197/prebid_test_300x250', + mediaTypes: { + banner: { + sizes: [[300, 250]] + } + }, + bids: [ + { + bidder: 'seedtag', + params: { + publisherId: '0000-0000-01', // required + adUnitId: '0000', // required + placement: 'inBanner', // required + } + } + ] + } +] +``` + +## inStream Video Ad Unit +```js +var adUnits = [{ + code: 'video', + mediaTypes: { + video: { + context: 'instream', // required + playerSize: [600, 300] // required + } + }, + bids: [ + { + bidder: 'seedtag', + params: { + publisherId: '0000-0000-01', // required + adUnitId: '0000', // required + placement: 'inStream', // required + adPosition: 0, // optional + // Video object as specified in OpenRTB 2.5 + video: { + mimes: ['video/mp4'], // recommended + minduration: 5, // optional + maxduration: 60, // optional + boxingallowed: 1, // optional + skip: 1, // optional + startdelay: 1, // optional + linearity: 1, // optional + battr: [1, 2], // optional + maxbitrate: 10, // optional + playbackmethod: [1], // optional + delivery: [1], // optional + placement: 1, // optional + } + } + } + ] +}]; +``` diff --git a/test/spec/modules/seedtagBidAdapter_spec.js b/test/spec/modules/seedtagBidAdapter_spec.js index bd726bfe971..8e77c49b23d 100644 --- a/test/spec/modules/seedtagBidAdapter_spec.js +++ b/test/spec/modules/seedtagBidAdapter_spec.js @@ -25,19 +25,19 @@ function getSlotConfigs(mediaTypes, params) { }; } -function createVideoSlotConfig(mediaType) { +function createInStreamSlotConfig(mediaType) { return getSlotConfigs(mediaType, { publisherId: PUBLISHER_ID, adUnitId: ADUNIT_ID, - placement: 'video', + placement: "inStream", }); } -describe('Seedtag Adapter', function () { - describe('isBidRequestValid method', function () { - describe('returns true', function () { - describe('when banner slot config has all mandatory params', () => { - describe('and placement has the correct value', function () { +describe("Seedtag Adapter", function () { + describe("isBidRequestValid method", function () { + describe("returns true", function () { + describe("when banner slot config has all mandatory params", () => { + describe("and placement has the correct value", function () { const createBannerSlotConfig = (placement) => { return getSlotConfigs( { banner: {} }, @@ -49,14 +49,14 @@ describe('Seedtag Adapter', function () { ); }; const placements = [ - 'banner', - 'video', - 'inImage', - 'inScreen', - 'inArticle', + "inBanner", + "inStream", + "inImage", + "inScreen", + "inArticle", ]; placements.forEach((placement) => { - it('should be ' + placement, function () { + it("should be " + placement, function () { const isBidRequestValid = spec.isBidRequestValid( createBannerSlotConfig(placement) ); @@ -65,68 +65,68 @@ describe('Seedtag Adapter', function () { }); }); }); - describe('when video slot has all mandatory params', function () { - it('should return true, when video context is instream', function () { + describe("when video slot has all mandatory params", function () { + it("should return true, when video context is instream", function () { const slotConfig = getSlotConfigs( { video: { - context: 'instream', + context: "instream", playerSize: [[600, 200]], }, }, { publisherId: PUBLISHER_ID, adUnitId: ADUNIT_ID, - placement: 'video', + placement: "inStream", } ); const isBidRequestValid = spec.isBidRequestValid(slotConfig); expect(isBidRequestValid).to.equal(true); }); - it('should return true, when video context is outstream', function () { + it("should return false, when video context is outstream", function () { const slotConfig = getSlotConfigs( { video: { - context: 'outstream', + context: "outstream", playerSize: [[600, 200]], }, }, { publisherId: PUBLISHER_ID, adUnitId: ADUNIT_ID, - placement: 'video', + placement: "inStream", } ); const isBidRequestValid = spec.isBidRequestValid(slotConfig); - expect(isBidRequestValid).to.equal(true); + expect(isBidRequestValid).to.equal(false); }); }); }); - describe('returns false', function () { - describe('when params are not correct', function () { + describe("returns false", function () { + describe("when params are not correct", function () { function createSlotConfig(params) { return getSlotConfigs({ banner: {} }, params); } - it('does not have the PublisherToken.', function () { + it("does not have the PublisherToken.", function () { const isBidRequestValid = spec.isBidRequestValid( createSlotConfig({ adUnitId: ADUNIT_ID, - placement: 'banner', + placement: "inBanner", }) ); expect(isBidRequestValid).to.equal(false); }); - it('does not have the AdUnitId.', function () { + it("does not have the AdUnitId.", function () { const isBidRequestValid = spec.isBidRequestValid( createSlotConfig({ publisherId: PUBLISHER_ID, - placement: 'banner', + placement: "inBanner", }) ); expect(isBidRequestValid).to.equal(false); }); - it('does not have the placement.', function () { + it("does not have the placement.", function () { const isBidRequestValid = spec.isBidRequestValid( createSlotConfig({ publisherId: PUBLISHER_ID, @@ -135,58 +135,58 @@ describe('Seedtag Adapter', function () { ); expect(isBidRequestValid).to.equal(false); }); - it('does not have a the correct placement.', function () { + it("does not have a the correct placement.", function () { const isBidRequestValid = spec.isBidRequestValid( createSlotConfig({ publisherId: PUBLISHER_ID, adUnitId: ADUNIT_ID, - placement: 'another_thing', + placement: "another_thing", }) ); expect(isBidRequestValid).to.equal(false); }); }); - describe('when video mediaType object is not correct', function () { + describe("when video mediaType object is not correct", function () { function createVideoSlotconfig(mediaType) { return getSlotConfigs(mediaType, { publisherId: PUBLISHER_ID, adUnitId: ADUNIT_ID, - placement: 'video', + placement: "inStream", }); } - it('is a void object', function () { + it("is a void object", function () { const isBidRequestValid = spec.isBidRequestValid( - createVideoSlotConfig({ video: {} }) + createInStreamSlotConfig({ video: {} }) ); expect(isBidRequestValid).to.equal(false); }); - it('does not have playerSize.', function () { + it("does not have playerSize.", function () { const isBidRequestValid = spec.isBidRequestValid( - createVideoSlotConfig({ video: { context: 'instream' } }) + createInStreamSlotConfig({ video: { context: "instream" } }) ); expect(isBidRequestValid).to.equal(false); }); - it('is outstream ', function () { + it("is outstream ", function () { const isBidRequestValid = spec.isBidRequestValid( - createVideoSlotConfig({ + createInStreamSlotConfig({ video: { - context: 'outstream', + context: "outstream", playerSize: [[600, 200]], }, }) ); - expect(isBidRequestValid).to.equal(true); + expect(isBidRequestValid).to.equal(false); }); - describe('order does not matter', function () { - it('when video is not the first slot', function () { + describe("order does not matter", function () { + it("when video is not the first slot", function () { const isBidRequestValid = spec.isBidRequestValid( - createVideoSlotConfig({ banner: {}, video: {} }) + createInStreamSlotConfig({ banner: {}, video: {} }) ); expect(isBidRequestValid).to.equal(false); }); - it('when video is the first slot', function () { + it("when video is the first slot", function () { const isBidRequestValid = spec.isBidRequestValid( - createVideoSlotConfig({ video: {}, banner: {} }) + createInStreamSlotConfig({ video: {}, banner: {} }) ); expect(isBidRequestValid).to.equal(false); }); @@ -195,52 +195,52 @@ describe('Seedtag Adapter', function () { }); }); - describe('buildRequests method', function () { + describe("buildRequests method", function () { const bidderRequest = { - refererInfo: { page: 'referer' }, + refererInfo: { page: "referer" }, timeout: 1000, }; const mandatoryParams = { publisherId: PUBLISHER_ID, adUnitId: ADUNIT_ID, - placement: 'banner', + placement: "inBanner", }; const inStreamParams = Object.assign({}, mandatoryParams, { video: { - mimes: 'mp4', + mimes: "mp4", }, }); const validBidRequests = [ getSlotConfigs({ banner: {} }, mandatoryParams), getSlotConfigs( - { video: { context: 'instream', playerSize: [[300, 200]] } }, + { video: { context: "instream", playerSize: [[300, 200]] } }, inStreamParams ), ]; - it('Url params should be correct ', function () { + it("Url params should be correct ", function () { const request = spec.buildRequests(validBidRequests, bidderRequest); - expect(request.method).to.equal('POST'); - expect(request.url).to.equal('https://s.seedtag.com/c/hb/bid'); + expect(request.method).to.equal("POST"); + expect(request.url).to.equal("https://s.seedtag.com/c/hb/bid"); }); - it('Common data request should be correct', function () { + it("Common data request should be correct", function () { const now = Date.now(); const request = spec.buildRequests(validBidRequests, bidderRequest); const data = JSON.parse(request.data); - expect(data.url).to.equal('referer'); - expect(data.publisherToken).to.equal('0000-0000-01'); - expect(typeof data.version).to.equal('string'); + expect(data.url).to.equal("referer"); + expect(data.publisherToken).to.equal("0000-0000-01"); + expect(typeof data.version).to.equal("string"); expect( - ['fixed', 'mobile', 'unknown'].indexOf(data.connectionType) + ["fixed", "mobile", "unknown"].indexOf(data.connectionType) ).to.be.above(-1); expect(data.auctionStart).to.be.greaterThanOrEqual(now); expect(data.ttfb).to.be.greaterThanOrEqual(0); - expect(data.bidRequests[0].adUnitCode).to.equal('adunit-code'); + expect(data.bidRequests[0].adUnitCode).to.equal("adunit-code"); }); - describe('adPosition param', function () { - it('should sended when publisher set adPosition param', function () { + describe("adPosition param", function () { + it("should sended when publisher set adPosition param", function () { const params = Object.assign({}, mandatoryParams, { adPosition: 1, }); @@ -249,7 +249,7 @@ describe('Seedtag Adapter', function () { const data = JSON.parse(request.data); expect(data.bidRequests[0].adPosition).to.equal(1); }); - it('should not sended when publisher has not set adPosition param', function () { + it("should not sended when publisher has not set adPosition param", function () { const validBidRequests = [ getSlotConfigs({ banner: {} }, mandatoryParams), ]; @@ -259,44 +259,44 @@ describe('Seedtag Adapter', function () { }); }); - describe('GDPR params', function () { - describe('when there arent consent management platform', function () { - it('cmp should be false', function () { + describe("GDPR params", function () { + describe("when there arent consent management platform", function () { + it("cmp should be false", function () { const request = spec.buildRequests(validBidRequests, bidderRequest); const data = JSON.parse(request.data); expect(data.cmp).to.equal(false); }); }); - describe('when there are consent management platform', function () { - it('cmps should be true and ga should not sended, when gdprApplies is undefined', function () { - bidderRequest['gdprConsent'] = { + describe("when there are consent management platform", function () { + it("cmps should be true and ga should not sended, when gdprApplies is undefined", function () { + bidderRequest["gdprConsent"] = { gdprApplies: undefined, - consentString: 'consentString', + consentString: "consentString", }; const request = spec.buildRequests(validBidRequests, bidderRequest); const data = JSON.parse(request.data); expect(data.cmp).to.equal(true); - expect(Object.keys(data).indexOf('data')).to.equal(-1); - expect(data.cd).to.equal('consentString'); + expect(Object.keys(data).indexOf("data")).to.equal(-1); + expect(data.cd).to.equal("consentString"); }); - it('cmps should be true and all gdpr parameters should be sended, when there are gdprApplies', function () { - bidderRequest['gdprConsent'] = { + it("cmps should be true and all gdpr parameters should be sended, when there are gdprApplies", function () { + bidderRequest["gdprConsent"] = { gdprApplies: true, - consentString: 'consentString', + consentString: "consentString", }; const request = spec.buildRequests(validBidRequests, bidderRequest); const data = JSON.parse(request.data); expect(data.cmp).to.equal(true); expect(data.ga).to.equal(true); - expect(data.cd).to.equal('consentString'); + expect(data.cd).to.equal("consentString"); }); - it('should expose gvlid', function () { + it("should expose gvlid", function () { expect(spec.gvlid).to.equal(157); }); - it('should handle uspConsent', function () { - const uspConsent = '1---'; + it("should handle uspConsent", function () { + const uspConsent = "1---"; - bidderRequest['uspConsent'] = uspConsent; + bidderRequest["uspConsent"] = uspConsent; const request = spec.buildRequests(validBidRequests, bidderRequest); const payload = JSON.parse(request.data); @@ -308,12 +308,9 @@ describe('Seedtag Adapter', function () { it("shouldn't send uspConsent when not available", function () { const uspConsent = undefined; - bidderRequest['uspConsent'] = uspConsent; + bidderRequest["uspConsent"] = uspConsent; - const request = spec.buildRequests( - validBidRequests, - bidderRequest - ); + const request = spec.buildRequests(validBidRequests, bidderRequest); const payload = JSON.parse(request.data); expect(payload.uspConsent).to.not.exist; @@ -321,33 +318,33 @@ describe('Seedtag Adapter', function () { }); }); - describe('BidRequests params', function () { + describe("BidRequests params", function () { const request = spec.buildRequests(validBidRequests, bidderRequest); const data = JSON.parse(request.data); const bidRequests = data.bidRequests; - it('should request a Banner', function () { + it("should request a Banner", function () { const bannerBid = bidRequests[0]; - expect(bannerBid.id).to.equal('30b31c1838de1e'); + expect(bannerBid.id).to.equal("30b31c1838de1e"); expect(bannerBid.transactionId).to.equal( - 'd704d006-0d6e-4a09-ad6c-179e7e758096' + "d704d006-0d6e-4a09-ad6c-179e7e758096" ); - expect(bannerBid.supplyTypes[0]).to.equal('display'); - expect(bannerBid.adUnitId).to.equal('000000'); + expect(bannerBid.supplyTypes[0]).to.equal("display"); + expect(bannerBid.adUnitId).to.equal("000000"); expect(bannerBid.sizes[0][0]).to.equal(300); expect(bannerBid.sizes[0][1]).to.equal(250); expect(bannerBid.sizes[1][0]).to.equal(300); expect(bannerBid.sizes[1][1]).to.equal(600); expect(bannerBid.requestCount).to.equal(1); }); - it('should request an InStream Video', function () { + it("should request an InStream Video", function () { const videoBid = bidRequests[1]; - expect(videoBid.id).to.equal('30b31c1838de1e'); + expect(videoBid.id).to.equal("30b31c1838de1e"); expect(videoBid.transactionId).to.equal( - 'd704d006-0d6e-4a09-ad6c-179e7e758096' + "d704d006-0d6e-4a09-ad6c-179e7e758096" ); - expect(videoBid.supplyTypes[0]).to.equal('video'); - expect(videoBid.adUnitId).to.equal('000000'); - expect(videoBid.videoParams.mimes).to.equal('mp4'); + expect(videoBid.supplyTypes[0]).to.equal("video"); + expect(videoBid.adUnitId).to.equal("000000"); + expect(videoBid.videoParams.mimes).to.equal("mp4"); expect(videoBid.videoParams.w).to.equal(300); expect(videoBid.videoParams.h).to.equal(200); expect(videoBid.sizes[0][0]).to.equal(300); @@ -385,18 +382,18 @@ describe('Seedtag Adapter', function () { it('should add schain to payload when exposed on validBidRequest', function () { // https://github.com/prebid/Prebid.js/blob/master/modules/schain.md#sample-code-for-passing-the-schain-object const schain = { - ver: '1.0', + ver: "1.0", complete: 1, nodes: [ { - asi: 'indirectseller.com', - sid: '00001', + asi: "indirectseller.com", + sid: "00001", hp: 1, }, { - asi: 'indirectseller-2.com', - sid: '00002', + asi: "indirectseller-2.com", + sid: "00002", hp: 1, }, ], @@ -424,137 +421,137 @@ describe('Seedtag Adapter', function () { }); }); - describe('interpret response method', function () { - it('should return a void array, when the server response are not correct.', function () { + describe("interpret response method", function () { + it("should return a void array, when the server response are not correct.", function () { const request = { data: JSON.stringify({}) }; const serverResponse = { body: {}, }; const bids = spec.interpretResponse(serverResponse, request); - expect(typeof bids).to.equal('object'); + expect(typeof bids).to.equal("object"); expect(bids.length).to.equal(0); }); - it('should return a void array, when the server response have no bids.', function () { + it("should return a void array, when the server response have no bids.", function () { const request = { data: JSON.stringify({}) }; const serverResponse = { body: { bids: [] } }; const bids = spec.interpretResponse(serverResponse, request); - expect(typeof bids).to.equal('object'); + expect(typeof bids).to.equal("object"); expect(bids.length).to.equal(0); }); - describe('when the server response return a bid', function () { - describe('the bid is a banner', function () { - it('should return a banner bid', function () { + describe("when the server response return a bid", function () { + describe("the bid is a banner", function () { + it("should return a banner bid", function () { const request = { data: JSON.stringify({}) }; const serverResponse = { body: { bids: [ { - bidId: '2159a54dc2566f', + bidId: "2159a54dc2566f", price: 0.5, - currency: 'USD', - content: 'content', + currency: "USD", + content: "content", width: 728, height: 90, - mediaType: 'display', + mediaType: "display", ttl: 360, - nurl: 'testurl.com/nurl', - adomain: ['advertiserdomain.com'], + nurl: "testurl.com/nurl", + adomain: ["advertiserdomain.com"], }, ], - cookieSync: { url: '' }, + cookieSync: { url: "" }, }, }; const bids = spec.interpretResponse(serverResponse, request); expect(bids.length).to.equal(1); - expect(bids[0].requestId).to.equal('2159a54dc2566f'); + expect(bids[0].requestId).to.equal("2159a54dc2566f"); expect(bids[0].cpm).to.equal(0.5); expect(bids[0].width).to.equal(728); expect(bids[0].height).to.equal(90); - expect(bids[0].currency).to.equal('USD'); + expect(bids[0].currency).to.equal("USD"); expect(bids[0].netRevenue).to.equal(true); - expect(bids[0].ad).to.equal('content'); - expect(bids[0].nurl).to.equal('testurl.com/nurl'); + expect(bids[0].ad).to.equal("content"); + expect(bids[0].nurl).to.equal("testurl.com/nurl"); expect(bids[0].meta.advertiserDomains).to.deep.equal([ - 'advertiserdomain.com', + "advertiserdomain.com", ]); }); }); - describe('the bid is a video', function () { - it('should return a instream bid', function () { + describe("the bid is a video", function () { + it("should return a instream bid", function () { const request = { data: JSON.stringify({}) }; const serverResponse = { body: { bids: [ { - bidId: '2159a54dc2566f', + bidId: "2159a54dc2566f", price: 0.5, - currency: 'USD', - content: 'content', + currency: "USD", + content: "content", width: 728, height: 90, - mediaType: 'video', + mediaType: "video", ttl: 360, nurl: undefined, }, ], - cookieSync: { url: '' }, + cookieSync: { url: "" }, }, }; const bids = spec.interpretResponse(serverResponse, request); expect(bids.length).to.equal(1); - expect(bids[0].requestId).to.equal('2159a54dc2566f'); + expect(bids[0].requestId).to.equal("2159a54dc2566f"); expect(bids[0].cpm).to.equal(0.5); expect(bids[0].width).to.equal(728); expect(bids[0].height).to.equal(90); - expect(bids[0].currency).to.equal('USD'); + expect(bids[0].currency).to.equal("USD"); expect(bids[0].netRevenue).to.equal(true); - expect(bids[0].vastXml).to.equal('content'); + expect(bids[0].vastXml).to.equal("content"); expect(bids[0].meta.advertiserDomains).to.deep.equal([]); }); }); }); }); - describe('user syncs method', function () { - it('should return empty array, when iframe sync option are disabled.', function () { + describe("user syncs method", function () { + it("should return empty array, when iframe sync option are disabled.", function () { const syncOption = { iframeEnabled: false }; - const serverResponses = [{ body: { cookieSync: 'someUrl' } }]; + const serverResponses = [{ body: { cookieSync: "someUrl" } }]; const cookieSyncArray = spec.getUserSyncs(syncOption, serverResponses); expect(cookieSyncArray.length).to.equal(0); }); - it('should return empty array, when the server response are wrong.', function () { + it("should return empty array, when the server response are wrong.", function () { const syncOption = { iframeEnabled: true }; const serverResponses = [{ body: {} }]; const cookieSyncArray = spec.getUserSyncs(syncOption, serverResponses); expect(cookieSyncArray.length).to.equal(0); }); - it('should return empty array, when the server response are void.', function () { + it("should return empty array, when the server response are void.", function () { const syncOption = { iframeEnabled: true }; - const serverResponses = [{ body: { cookieSync: '' } }]; + const serverResponses = [{ body: { cookieSync: "" } }]; const cookieSyncArray = spec.getUserSyncs(syncOption, serverResponses); expect(cookieSyncArray.length).to.equal(0); }); - it('should return a array with the cookie sync, when the server response with a cookie sync.', function () { + it("should return a array with the cookie sync, when the server response with a cookie sync.", function () { const syncOption = { iframeEnabled: true }; - const serverResponses = [{ body: { cookieSync: 'someUrl' } }]; + const serverResponses = [{ body: { cookieSync: "someUrl" } }]; const cookieSyncArray = spec.getUserSyncs(syncOption, serverResponses); expect(cookieSyncArray.length).to.equal(1); - expect(cookieSyncArray[0].type).to.equal('iframe'); - expect(cookieSyncArray[0].url).to.equal('someUrl'); + expect(cookieSyncArray[0].type).to.equal("iframe"); + expect(cookieSyncArray[0].url).to.equal("someUrl"); }); }); - describe('onTimeout', function () { + describe("onTimeout", function () { beforeEach(function () { - sinon.stub(utils, 'triggerPixel'); + sinon.stub(utils, "triggerPixel"); }); afterEach(function () { utils.triggerPixel.restore(); }); - it('should return the correct endpoint', function () { - const params = { publisherId: '0000', adUnitId: '11111' }; + it("should return the correct endpoint", function () { + const params = { publisherId: "0000", adUnitId: "11111" }; const timeout = 3000; const timeoutData = [{ params: [params], timeout }]; const timeoutUrl = getTimeoutUrl(timeoutData); @@ -568,8 +565,8 @@ describe('Seedtag Adapter', function () { ); }); - it('should set the timeout pixel', function () { - const params = { publisherId: '0000', adUnitId: '11111' }; + it("should set the timeout pixel", function () { + const params = { publisherId: "0000", adUnitId: "11111" }; const timeout = 3000; const timeoutData = [{ params: [params], timeout }]; spec.onTimeout(timeoutData); @@ -586,29 +583,29 @@ describe('Seedtag Adapter', function () { }); }); - describe('onBidWon', function () { + describe("onBidWon", function () { beforeEach(function () { - sinon.stub(utils, 'triggerPixel'); + sinon.stub(utils, "triggerPixel"); }); afterEach(function () { utils.triggerPixel.restore(); }); - describe('without nurl', function () { + describe("without nurl", function () { const bid = {}; - it('does not create pixel ', function () { + it("does not create pixel ", function () { spec.onBidWon(bid); expect(utils.triggerPixel.called).to.equal(false); }); }); - describe('with nurl', function () { - const nurl = 'http://seedtag_domain/won'; + describe("with nurl", function () { + const nurl = "http://seedtag_domain/won"; const bid = { nurl }; - it('creates nurl pixel if bid nurl', function () { + it("creates nurl pixel if bid nurl", function () { spec.onBidWon({ nurl }); expect(utils.triggerPixel.calledWith(nurl)).to.equal(true); }); From 911d9060b66b94a5c84bf05efaf71967b6fa3654 Mon Sep 17 00:00:00 2001 From: Yohan Boutin Date: Tue, 8 Nov 2022 15:14:23 +0100 Subject: [PATCH 2/9] remove duplicate video params, now use only params from adunit level --- modules/seedtagBidAdapter.js | 96 +++++++++++++++++------------------- modules/seedtagBidAdapter.md | 32 ++++++------ 2 files changed, 60 insertions(+), 68 deletions(-) diff --git a/modules/seedtagBidAdapter.js b/modules/seedtagBidAdapter.js index 8d74b9b288d..2bc1e21d420 100644 --- a/modules/seedtagBidAdapter.js +++ b/modules/seedtagBidAdapter.js @@ -1,12 +1,12 @@ -import { isArray, _map, triggerPixel } from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js' -import { VIDEO, BANNER } from '../src/mediaTypes.js' -import { config } from '../src/config.js'; - -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'; +import { isArray, _map, triggerPixel } from "../src/utils.js"; +import { registerBidder } from "../src/adapters/bidderFactory.js"; +import { VIDEO, BANNER } from "../src/mediaTypes.js"; +import { config } from "../src/config.js"; + +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_PLACEMENTS = { inImage: true, inScreen: true, @@ -58,10 +58,7 @@ function mapMediaType(seedtagMediaType) { } function hasVideoMediaType(bid) { - return ( - (!!bid.mediaTypes && !!bid.mediaTypes.video) || - (!!bid.params && !!bid.params.video) - ); + return !!bid.mediaTypes && !!bid.mediaTypes.video; } function hasMandatoryParams(params) { @@ -81,7 +78,8 @@ function hasMandatoryVideoParams(bid) { !!videoParams.playerSize && isArray(videoParams.playerSize) && videoParams.playerSize.length > 0 && - bid.params.placement === "inStream" // only inStream is supported for video + // only instream is supported for video + videoParams.context === "instream" ); } @@ -102,15 +100,11 @@ function buildBidRequest(validBidRequest) { adUnitId: params.adUnitId, adUnitCode: validBidRequest.adUnitCode, placement: params.placement, - requestCount: validBidRequest.bidderRequestsCount || 1 // FIXME : in unit test the parameter bidderRequestsCount is undefined + requestCount: validBidRequest.bidderRequestsCount || 1, // FIXME : in unit test the parameter bidderRequestsCount is undefined }; - if (params.adPosition) { - bidRequest.adPosition = params.adPosition; - } - if (hasVideoMediaType(validBidRequest)) { - bidRequest.videoParams = getVideoParams(validBidRequest) + bidRequest.videoParams = getVideoParams(validBidRequest); } return bidRequest; @@ -126,13 +120,7 @@ function getVideoParams(validBidRequest) { videoParams.h = videoParams.playerSize[0][1]; } - const bidderVideoParams = (validBidRequest.params && validBidRequest.params.video) || {} - // override video params from seedtag bidder params - Object.keys(bidderVideoParams).forEach(key => { - videoParams[key] = validBidRequest.params.video[key] - }) - - return videoParams + return videoParams; } function buildBidResponse(seedtagBid) { @@ -149,8 +137,11 @@ function buildBidResponse(seedtagBid) { ttl: seedtagBid.ttl, nurl: seedtagBid.nurl, meta: { - advertiserDomains: seedtagBid && seedtagBid.adomain && seedtagBid.adomain.length > 0 ? seedtagBid.adomain : [] - } + advertiserDomains: + seedtagBid && seedtagBid.adomain && seedtagBid.adomain.length > 0 + ? seedtagBid.adomain + : [], + }, }; if (mediaType === VIDEO) { @@ -171,7 +162,7 @@ function ttfb() { const ttfb = (() => { // Timing API V2 try { - const entry = performance.getEntriesByType('navigation')[0]; + const entry = performance.getEntriesByType("navigation")[0]; return Math.round(entry.responseStart - entry.startTime); } catch (e) { // Timing API V1 @@ -192,18 +183,23 @@ function ttfb() { } export function getTimeoutUrl(data) { - let queryParams = ''; + let queryParams = ""; if ( - isArray(data) && data[0] && - isArray(data[0].params) && data[0].params[0] + isArray(data) && + data[0] && + isArray(data[0].params) && + data[0].params[0] ) { const params = data[0].params[0]; - const timeout = data[0].timeout + const timeout = data[0].timeout; queryParams = - '?publisherToken=' + params.publisherId + - '&adUnitId=' + params.adUnitId + - '&timeout=' + timeout; + "?publisherToken=" + + params.publisherId + + "&adUnitId=" + + params.adUnitId + + "&timeout=" + + timeout; } return SEEDTAG_SSP_ONTIMEOUT_ENDPOINT + queryParams; } @@ -237,7 +233,7 @@ export const spec = { publisherToken: validBidRequests[0].params.publisherId, cmp: !!bidderRequest.gdprConsent, timeout: bidderRequest.timeout, - version: '$prebid.version$', + version: "$prebid.version$", connectionType: getConnectionType(), auctionStart: bidderRequest.auctionStart || Date.now(), ttfb: ttfb(), @@ -246,28 +242,28 @@ export const spec = { if (payload.cmp) { const gdprApplies = bidderRequest.gdprConsent.gdprApplies; - if (gdprApplies !== undefined) payload['ga'] = gdprApplies; - payload['cd'] = bidderRequest.gdprConsent.consentString; + if (gdprApplies !== undefined) payload["ga"] = gdprApplies; + payload["cd"] = bidderRequest.gdprConsent.consentString; } if (bidderRequest.uspConsent) { - payload['uspConsent'] = bidderRequest.uspConsent + payload["uspConsent"] = bidderRequest.uspConsent; } if (validBidRequests[0].schain) { payload.schain = validBidRequests[0].schain; } - let coppa = config.getConfig('coppa') + let coppa = config.getConfig("coppa"); if (coppa) { - payload.coppa = coppa + payload.coppa = coppa; } - const payloadString = JSON.stringify(payload) + const payloadString = JSON.stringify(payload); return { - method: 'POST', + method: "POST", url: SEEDTAG_SSP_ENDPOINT, - data: payloadString - } + data: payloadString, + }; }, /** @@ -298,7 +294,7 @@ export const spec = { const serverResponse = serverResponses[0]; if (syncOptions.iframeEnabled && serverResponse) { const cookieSyncUrl = serverResponse.body.cookieSync; - return cookieSyncUrl ? [{ type: 'iframe', url: cookieSyncUrl }] : []; + return cookieSyncUrl ? [{ type: "iframe", url: cookieSyncUrl }] : []; } else { return []; } @@ -321,6 +317,6 @@ export const spec = { if (bid && bid.nurl) { triggerPixel(bid.nurl); } - } -} + }, +}; registerBidder(spec); diff --git a/modules/seedtagBidAdapter.md b/modules/seedtagBidAdapter.md index 61e7f75d373..18b6372940b 100644 --- a/modules/seedtagBidAdapter.md +++ b/modules/seedtagBidAdapter.md @@ -91,7 +91,20 @@ var adUnits = [{ mediaTypes: { video: { context: 'instream', // required - playerSize: [600, 300] // required + playerSize: [600, 300], // required + // Video object as specified in OpenRTB 2.5 + mimes: ['video/mp4'], // recommended + minduration: 5, // optional + maxduration: 60, // optional + boxingallowed: 1, // optional + skip: 1, // optional + startdelay: 1, // optional + linearity: 1, // optional + battr: [1, 2], // optional + maxbitrate: 10, // optional + playbackmethod: [1], // optional + delivery: [1], // optional + placement: 1, // optional } }, bids: [ @@ -100,23 +113,6 @@ var adUnits = [{ params: { publisherId: '0000-0000-01', // required adUnitId: '0000', // required - placement: 'inStream', // required - adPosition: 0, // optional - // Video object as specified in OpenRTB 2.5 - video: { - mimes: ['video/mp4'], // recommended - minduration: 5, // optional - maxduration: 60, // optional - boxingallowed: 1, // optional - skip: 1, // optional - startdelay: 1, // optional - linearity: 1, // optional - battr: [1, 2], // optional - maxbitrate: 10, // optional - playbackmethod: [1], // optional - delivery: [1], // optional - placement: 1, // optional - } } } ] From 9c57b6b9cb517a2cd6eb88a964f33e3d64e3aae5 Mon Sep 17 00:00:00 2001 From: Yohan Boutin Date: Tue, 8 Nov 2022 15:23:01 +0100 Subject: [PATCH 3/9] lint --- test/spec/modules/seedtagBidAdapter_spec.js | 74 ++++++++++----------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/test/spec/modules/seedtagBidAdapter_spec.js b/test/spec/modules/seedtagBidAdapter_spec.js index 8e77c49b23d..815d379491b 100644 --- a/test/spec/modules/seedtagBidAdapter_spec.js +++ b/test/spec/modules/seedtagBidAdapter_spec.js @@ -1,10 +1,10 @@ -import { expect } from 'chai'; -import { spec, getTimeoutUrl } from 'modules/seedtagBidAdapter.js'; -import * as utils from 'src/utils.js'; -import { config } from '../../../src/config.js'; +import { expect } from "chai"; +import { spec, getTimeoutUrl } from "modules/seedtagBidAdapter.js"; +import * as utils from "src/utils.js"; +import { config } from "../../../src/config.js"; -const PUBLISHER_ID = '0000-0000-01'; -const ADUNIT_ID = '000000'; +const PUBLISHER_ID = "0000-0000-01"; +const ADUNIT_ID = "000000"; function getSlotConfigs(mediaTypes, params) { return { @@ -13,15 +13,15 @@ function getSlotConfigs(mediaTypes, params) { [300, 250], [300, 600], ], - bidId: '30b31c1838de1e', - bidderRequestId: '22edbae2733bf6', - auctionId: '1d1a030790a475', + bidId: "30b31c1838de1e", + bidderRequestId: "22edbae2733bf6", + auctionId: "1d1a030790a475", bidRequestsCount: 1, - bidder: 'seedtag', + bidder: "seedtag", mediaTypes: mediaTypes, - src: 'client', - transactionId: 'd704d006-0d6e-4a09-ad6c-179e7e758096', - adUnitCode: 'adunit-code', + src: "client", + transactionId: "d704d006-0d6e-4a09-ad6c-179e7e758096", + adUnitCode: "adunit-code", }; } @@ -355,31 +355,31 @@ describe("Seedtag Adapter", function () { }); }); - describe('COPPA param', function () { - it('should add COPPA param to payload when prebid config has parameter COPPA equal to true', function () { - config.setConfig({ coppa: true }) + describe("COPPA param", function () { + it("should add COPPA param to payload when prebid config has parameter COPPA equal to true", function () { + config.setConfig({ coppa: true }); const request = spec.buildRequests(validBidRequests, bidderRequest); const data = JSON.parse(request.data); expect(data.coppa).to.equal(true); - }) + }); - it('should not add COPPA param to payload when prebid config has parameter COPPA equal to false', function () { - config.setConfig({ coppa: false }) + it("should not add COPPA param to payload when prebid config has parameter COPPA equal to false", function () { + config.setConfig({ coppa: false }); const request = spec.buildRequests(validBidRequests, bidderRequest); const data = JSON.parse(request.data); expect(data.coppa).to.be.undefined; - }) + }); - it('should not add COPPA param to payload when prebid config has not parameter COPPA', function () { + it("should not add COPPA param to payload when prebid config has not parameter COPPA", function () { const request = spec.buildRequests(validBidRequests, bidderRequest); const data = JSON.parse(request.data); expect(data.coppa).to.be.undefined; - }) - }) - describe('schain param', function () { - it('should add schain to payload when exposed on validBidRequest', function () { + }); + }); + describe("schain param", function () { + it("should add schain to payload when exposed on validBidRequest", function () { // https://github.com/prebid/Prebid.js/blob/master/modules/schain.md#sample-code-for-passing-the-schain-object const schain = { ver: "1.0", @@ -556,12 +556,12 @@ describe("Seedtag Adapter", function () { const timeoutData = [{ params: [params], timeout }]; const timeoutUrl = getTimeoutUrl(timeoutData); expect(timeoutUrl).to.equal( - 'https://s.seedtag.com/se/hb/timeout?publisherToken=' + - params.publisherId + - '&adUnitId=' + - params.adUnitId + - '&timeout=' + - timeout + "https://s.seedtag.com/se/hb/timeout?publisherToken=" + + params.publisherId + + "&adUnitId=" + + params.adUnitId + + "&timeout=" + + timeout ); }); @@ -572,12 +572,12 @@ describe("Seedtag Adapter", function () { spec.onTimeout(timeoutData); expect( utils.triggerPixel.calledWith( - 'https://s.seedtag.com/se/hb/timeout?publisherToken=' + - params.publisherId + - '&adUnitId=' + - params.adUnitId + - '&timeout=' + - timeout + "https://s.seedtag.com/se/hb/timeout?publisherToken=" + + params.publisherId + + "&adUnitId=" + + params.adUnitId + + "&timeout=" + + timeout ) ).to.equal(true); }); From 0cc1bf68d173d9175cf8fafd129a8ec044f77768 Mon Sep 17 00:00:00 2001 From: Yohan Boutin Date: Tue, 8 Nov 2022 15:30:41 +0100 Subject: [PATCH 4/9] improve unit test --- test/spec/modules/seedtagBidAdapter_spec.js | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/test/spec/modules/seedtagBidAdapter_spec.js b/test/spec/modules/seedtagBidAdapter_spec.js index 815d379491b..8b1598f851b 100644 --- a/test/spec/modules/seedtagBidAdapter_spec.js +++ b/test/spec/modules/seedtagBidAdapter_spec.js @@ -29,7 +29,6 @@ function createInStreamSlotConfig(mediaType) { return getSlotConfigs(mediaType, { publisherId: PUBLISHER_ID, adUnitId: ADUNIT_ID, - placement: "inStream", }); } @@ -48,13 +47,7 @@ describe("Seedtag Adapter", function () { } ); }; - const placements = [ - "inBanner", - "inStream", - "inImage", - "inScreen", - "inArticle", - ]; + const placements = ["inBanner", "inImage", "inScreen", "inArticle"]; placements.forEach((placement) => { it("should be " + placement, function () { const isBidRequestValid = spec.isBidRequestValid( @@ -77,7 +70,6 @@ describe("Seedtag Adapter", function () { { publisherId: PUBLISHER_ID, adUnitId: ADUNIT_ID, - placement: "inStream", } ); const isBidRequestValid = spec.isBidRequestValid(slotConfig); @@ -95,7 +87,6 @@ describe("Seedtag Adapter", function () { { publisherId: PUBLISHER_ID, adUnitId: ADUNIT_ID, - placement: "inStream", } ); const isBidRequestValid = spec.isBidRequestValid(slotConfig); @@ -146,14 +137,8 @@ describe("Seedtag Adapter", function () { expect(isBidRequestValid).to.equal(false); }); }); + describe("when video mediaType object is not correct", function () { - function createVideoSlotconfig(mediaType) { - return getSlotConfigs(mediaType, { - publisherId: PUBLISHER_ID, - adUnitId: ADUNIT_ID, - placement: "inStream", - }); - } it("is a void object", function () { const isBidRequestValid = spec.isBidRequestValid( createInStreamSlotConfig({ video: {} }) From 763502e731ed6c2e5ad7127ee9ed32177a5d0d06 Mon Sep 17 00:00:00 2001 From: Yohan Boutin Date: Tue, 8 Nov 2022 16:07:27 +0100 Subject: [PATCH 5/9] fix adapter for instream support, and fix unit test --- modules/seedtagBidAdapter.js | 21 +++++----- test/spec/modules/seedtagBidAdapter_spec.js | 45 +++++++-------------- 2 files changed, 26 insertions(+), 40 deletions(-) diff --git a/modules/seedtagBidAdapter.js b/modules/seedtagBidAdapter.js index 2bc1e21d420..177501831ba 100644 --- a/modules/seedtagBidAdapter.js +++ b/modules/seedtagBidAdapter.js @@ -1,18 +1,16 @@ import { isArray, _map, triggerPixel } from "../src/utils.js"; import { registerBidder } from "../src/adapters/bidderFactory.js"; import { VIDEO, BANNER } from "../src/mediaTypes.js"; -import { config } from "../src/config.js"; 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_PLACEMENTS = { +const ALLOWED_DISPLAY_PLACEMENTS = { inImage: true, inScreen: true, inArticle: true, inBanner: true, - inVideo: true, }; // Global Vendor List Id @@ -61,12 +59,13 @@ function hasVideoMediaType(bid) { return !!bid.mediaTypes && !!bid.mediaTypes.video; } -function hasMandatoryParams(params) { +function hasMandatoryDisplayParams(bid) { + const p = bid.params; return ( - !!params.publisherId && - !!params.adUnitId && - !!params.placement && - !!ALLOWED_PLACEMENTS[params.placement] + !!p.publisherId && + !!p.adUnitId && + !!p.placement && + !!ALLOWED_DISPLAY_PLACEMENTS[p.placement] ); } @@ -74,6 +73,8 @@ function hasMandatoryVideoParams(bid) { const videoParams = getVideoParams(bid); return ( + !!bid.params.publisherId && + !!bid.params.adUnitId && hasVideoMediaType(bid) && !!videoParams.playerSize && isArray(videoParams.playerSize) && @@ -217,8 +218,8 @@ export const spec = { */ isBidRequestValid(bid) { return hasVideoMediaType(bid) - ? hasMandatoryParams(bid.params) && hasMandatoryVideoParams(bid) - : hasMandatoryParams(bid.params); + ? hasMandatoryVideoParams(bid) + : hasMandatoryDisplayParams(bid); }, /** diff --git a/test/spec/modules/seedtagBidAdapter_spec.js b/test/spec/modules/seedtagBidAdapter_spec.js index 8b1598f851b..f2c641ab8de 100644 --- a/test/spec/modules/seedtagBidAdapter_spec.js +++ b/test/spec/modules/seedtagBidAdapter_spec.js @@ -185,21 +185,26 @@ describe("Seedtag Adapter", function () { refererInfo: { page: "referer" }, timeout: 1000, }; - const mandatoryParams = { + const mandatoryDisplayParams = { publisherId: PUBLISHER_ID, adUnitId: ADUNIT_ID, placement: "inBanner", }; - const inStreamParams = Object.assign({}, mandatoryParams, { - video: { - mimes: "mp4", - }, - }); + const mandatoryVideoParams = { + publisherId: PUBLISHER_ID, + adUnitId: ADUNIT_ID, + }; const validBidRequests = [ - getSlotConfigs({ banner: {} }, mandatoryParams), + getSlotConfigs({ banner: {} }, mandatoryDisplayParams), getSlotConfigs( - { video: { context: "instream", playerSize: [[300, 200]] } }, - inStreamParams + { + video: { + context: "instream", + playerSize: [[300, 200]], + mimes: ["video/mp4"], + }, + }, + mandatoryVideoParams ), ]; it("Url params should be correct ", function () { @@ -224,26 +229,6 @@ describe("Seedtag Adapter", function () { expect(data.bidRequests[0].adUnitCode).to.equal("adunit-code"); }); - describe("adPosition param", function () { - it("should sended when publisher set adPosition param", function () { - const params = Object.assign({}, mandatoryParams, { - adPosition: 1, - }); - const validBidRequests = [getSlotConfigs({ banner: {} }, params)]; - const request = spec.buildRequests(validBidRequests, bidderRequest); - const data = JSON.parse(request.data); - expect(data.bidRequests[0].adPosition).to.equal(1); - }); - it("should not sended when publisher has not set adPosition param", function () { - const validBidRequests = [ - getSlotConfigs({ banner: {} }, mandatoryParams), - ]; - const request = spec.buildRequests(validBidRequests, bidderRequest); - const data = JSON.parse(request.data); - expect(data.bidRequests[0].adPosition).to.equal(undefined); - }); - }); - describe("GDPR params", function () { describe("when there arent consent management platform", function () { it("cmp should be false", function () { @@ -329,7 +314,7 @@ describe("Seedtag Adapter", function () { ); expect(videoBid.supplyTypes[0]).to.equal("video"); expect(videoBid.adUnitId).to.equal("000000"); - expect(videoBid.videoParams.mimes).to.equal("mp4"); + expect(videoBid.videoParams.mimes).to.eql(["video/mp4"]); expect(videoBid.videoParams.w).to.equal(300); expect(videoBid.videoParams.h).to.equal(200); expect(videoBid.sizes[0][0]).to.equal(300); From a9266fc89275526e84f02364562a062db541c80b Mon Sep 17 00:00:00 2001 From: Yohan Boutin Date: Wed, 9 Nov 2022 10:18:44 +0100 Subject: [PATCH 6/9] use inStream placement for instream context --- modules/seedtagBidAdapter.js | 13 +++------ test/spec/modules/seedtagBidAdapter_spec.js | 32 ++++++++++++--------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/modules/seedtagBidAdapter.js b/modules/seedtagBidAdapter.js index 177501831ba..e50bca57c64 100644 --- a/modules/seedtagBidAdapter.js +++ b/modules/seedtagBidAdapter.js @@ -6,12 +6,7 @@ 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 = { - inImage: true, - inScreen: true, - inArticle: true, - inBanner: true, -}; +const displayPlacements = ["inScreen", "inImage", "inArticle", "inBanner"]; // Global Vendor List Id // https://iabeurope.eu/vendor-list-tcf-v2-0/ @@ -64,8 +59,7 @@ function hasMandatoryDisplayParams(bid) { return ( !!p.publisherId && !!p.adUnitId && - !!p.placement && - !!ALLOWED_DISPLAY_PLACEMENTS[p.placement] + displayPlacements.indexOf(p.placement) > -1 ); } @@ -80,7 +74,8 @@ function hasMandatoryVideoParams(bid) { isArray(videoParams.playerSize) && videoParams.playerSize.length > 0 && // only instream is supported for video - videoParams.context === "instream" + videoParams.context === "instream" && + bid.params.placement === "inStream" ); } diff --git a/test/spec/modules/seedtagBidAdapter_spec.js b/test/spec/modules/seedtagBidAdapter_spec.js index f2c641ab8de..5c9e6306e00 100644 --- a/test/spec/modules/seedtagBidAdapter_spec.js +++ b/test/spec/modules/seedtagBidAdapter_spec.js @@ -29,6 +29,7 @@ function createInStreamSlotConfig(mediaType) { return getSlotConfigs(mediaType, { publisherId: PUBLISHER_ID, adUnitId: ADUNIT_ID, + placement: "inStream", }); } @@ -60,6 +61,16 @@ describe("Seedtag Adapter", function () { }); describe("when video slot has all mandatory params", function () { it("should return true, when video context is instream", function () { + const slotConfig = createInStreamSlotConfig({ + video: { + context: "instream", + playerSize: [[600, 200]], + }, + }); + const isBidRequestValid = spec.isBidRequestValid(slotConfig); + expect(isBidRequestValid).to.equal(true); + }); + it("should return true, when video context is instream, but placement is not inStream", function () { const slotConfig = getSlotConfigs( { video: { @@ -70,25 +81,19 @@ describe("Seedtag Adapter", function () { { publisherId: PUBLISHER_ID, adUnitId: ADUNIT_ID, + placement: "inBanner", } ); const isBidRequestValid = spec.isBidRequestValid(slotConfig); - expect(isBidRequestValid).to.equal(true); + expect(isBidRequestValid).to.equal(false); }); - it("should return false, when video context is outstream", function () { - const slotConfig = getSlotConfigs( - { - video: { - context: "outstream", - playerSize: [[600, 200]], - }, + const slotConfig = createInStreamSlotConfig({ + video: { + context: "outstream", + playerSize: [[600, 200]], }, - { - publisherId: PUBLISHER_ID, - adUnitId: ADUNIT_ID, - } - ); + }); const isBidRequestValid = spec.isBidRequestValid(slotConfig); expect(isBidRequestValid).to.equal(false); }); @@ -193,6 +198,7 @@ describe("Seedtag Adapter", function () { const mandatoryVideoParams = { publisherId: PUBLISHER_ID, adUnitId: ADUNIT_ID, + placement: "inStream", }; const validBidRequests = [ getSlotConfigs({ banner: {} }, mandatoryDisplayParams), From 40b167730816fe9690fc455cffc0fc61819c46c5 Mon Sep 17 00:00:00 2001 From: Yohan Boutin Date: Wed, 9 Nov 2022 11:57:50 +0100 Subject: [PATCH 7/9] use ALLOWED_DISPLAY_PLACEMENTS --- modules/seedtagBidAdapter.js | 9 +++++++-- modules/seedtagBidAdapter.md | 5 +++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/modules/seedtagBidAdapter.js b/modules/seedtagBidAdapter.js index e50bca57c64..9d29b11ac63 100644 --- a/modules/seedtagBidAdapter.js +++ b/modules/seedtagBidAdapter.js @@ -6,7 +6,12 @@ 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 displayPlacements = ["inScreen", "inImage", "inArticle", "inBanner"]; +const ALLOWED_DISPLAY_PLACEMENTS = [ + "inScreen", + "inImage", + "inArticle", + "inBanner", +]; // Global Vendor List Id // https://iabeurope.eu/vendor-list-tcf-v2-0/ @@ -59,7 +64,7 @@ function hasMandatoryDisplayParams(bid) { return ( !!p.publisherId && !!p.adUnitId && - displayPlacements.indexOf(p.placement) > -1 + ALLOWED_DISPLAY_PLACEMENTS.indexOf(p.placement) > -1 ); } diff --git a/modules/seedtagBidAdapter.md b/modules/seedtagBidAdapter.md index 18b6372940b..8ccfcfb701e 100644 --- a/modules/seedtagBidAdapter.md +++ b/modules/seedtagBidAdapter.md @@ -84,14 +84,14 @@ const adUnits = [ ] ``` -## inStream Video Ad Unit +## inStream Video ```js var adUnits = [{ code: 'video', mediaTypes: { video: { context: 'instream', // required - playerSize: [600, 300], // required + playerSize: [640, 360], // required // Video object as specified in OpenRTB 2.5 mimes: ['video/mp4'], // recommended minduration: 5, // optional @@ -113,6 +113,7 @@ var adUnits = [{ params: { publisherId: '0000-0000-01', // required adUnitId: '0000', // required + placement: 'inStream', // required } } ] From be8220cb6cbef240a106a1ba460cd24a1d1058df Mon Sep 17 00:00:00 2001 From: Yohan Boutin Date: Thu, 10 Nov 2022 10:32:37 +0100 Subject: [PATCH 8/9] fix lint error --- modules/seedtagBidAdapter.js | 75 ++--- test/spec/modules/seedtagBidAdapter_spec.js | 324 ++++++++++---------- 2 files changed, 200 insertions(+), 199 deletions(-) diff --git a/modules/seedtagBidAdapter.js b/modules/seedtagBidAdapter.js index 9d29b11ac63..1a4f903789b 100644 --- a/modules/seedtagBidAdapter.js +++ b/modules/seedtagBidAdapter.js @@ -1,16 +1,17 @@ -import { isArray, _map, triggerPixel } from "../src/utils.js"; -import { registerBidder } from "../src/adapters/bidderFactory.js"; -import { VIDEO, BANNER } from "../src/mediaTypes.js"; - -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"; +import { isArray, _map, triggerPixel } from '../src/utils.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { VIDEO, BANNER } from '../src/mediaTypes.js'; +import { config } from '../src/config.js'; + +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", + 'inScreen', + 'inImage', + 'inArticle', + 'inBanner', ]; // Global Vendor List Id @@ -18,14 +19,14 @@ const ALLOWED_DISPLAY_PLACEMENTS = [ const GVLID = 157; const mediaTypesMap = { - [BANNER]: "display", - [VIDEO]: "video", + [BANNER]: 'display', + [VIDEO]: 'video', }; const deviceConnection = { - FIXED: "fixed", - MOBILE: "mobile", - UNKNOWN: "unknown", + FIXED: 'fixed', + MOBILE: 'mobile', + UNKNOWN: 'unknown', }; const getConnectionType = () => { @@ -35,11 +36,11 @@ const getConnectionType = () => { navigator.webkitConnection || {}; switch (connection.type || connection.effectiveType) { - case "wifi": - case "ethernet": + case 'wifi': + case 'ethernet': return deviceConnection.FIXED; - case "cellular": - case "wimax": + case 'cellular': + case 'wimax': return deviceConnection.MOBILE; default: const isMobile = @@ -50,8 +51,8 @@ const getConnectionType = () => { }; function mapMediaType(seedtagMediaType) { - if (seedtagMediaType === "display") return BANNER; - if (seedtagMediaType === "video") return VIDEO; + if (seedtagMediaType === 'display') return BANNER; + if (seedtagMediaType === 'video') return VIDEO; else return seedtagMediaType; } @@ -79,8 +80,8 @@ function hasMandatoryVideoParams(bid) { isArray(videoParams.playerSize) && videoParams.playerSize.length > 0 && // only instream is supported for video - videoParams.context === "instream" && - bid.params.placement === "inStream" + videoParams.context === 'instream' && + bid.params.placement === 'inStream' ); } @@ -163,7 +164,7 @@ function ttfb() { const ttfb = (() => { // Timing API V2 try { - const entry = performance.getEntriesByType("navigation")[0]; + const entry = performance.getEntriesByType('navigation')[0]; return Math.round(entry.responseStart - entry.startTime); } catch (e) { // Timing API V1 @@ -184,7 +185,7 @@ function ttfb() { } export function getTimeoutUrl(data) { - let queryParams = ""; + let queryParams = ''; if ( isArray(data) && data[0] && @@ -195,11 +196,11 @@ export function getTimeoutUrl(data) { const timeout = data[0].timeout; queryParams = - "?publisherToken=" + + '?publisherToken=' + params.publisherId + - "&adUnitId=" + + '&adUnitId=' + params.adUnitId + - "&timeout=" + + '&timeout=' + timeout; } return SEEDTAG_SSP_ONTIMEOUT_ENDPOINT + queryParams; @@ -234,7 +235,7 @@ export const spec = { publisherToken: validBidRequests[0].params.publisherId, cmp: !!bidderRequest.gdprConsent, timeout: bidderRequest.timeout, - version: "$prebid.version$", + version: '$prebid.version$', connectionType: getConnectionType(), auctionStart: bidderRequest.auctionStart || Date.now(), ttfb: ttfb(), @@ -243,25 +244,25 @@ export const spec = { if (payload.cmp) { const gdprApplies = bidderRequest.gdprConsent.gdprApplies; - if (gdprApplies !== undefined) payload["ga"] = gdprApplies; - payload["cd"] = bidderRequest.gdprConsent.consentString; + if (gdprApplies !== undefined) payload['ga'] = gdprApplies; + payload['cd'] = bidderRequest.gdprConsent.consentString; } if (bidderRequest.uspConsent) { - payload["uspConsent"] = bidderRequest.uspConsent; + payload['uspConsent'] = bidderRequest.uspConsent; } if (validBidRequests[0].schain) { payload.schain = validBidRequests[0].schain; } - let coppa = config.getConfig("coppa"); + let coppa = config.getConfig('coppa'); if (coppa) { payload.coppa = coppa; } const payloadString = JSON.stringify(payload); return { - method: "POST", + method: 'POST', url: SEEDTAG_SSP_ENDPOINT, data: payloadString, }; @@ -295,7 +296,7 @@ export const spec = { const serverResponse = serverResponses[0]; if (syncOptions.iframeEnabled && serverResponse) { const cookieSyncUrl = serverResponse.body.cookieSync; - return cookieSyncUrl ? [{ type: "iframe", url: cookieSyncUrl }] : []; + return cookieSyncUrl ? [{ type: 'iframe', url: cookieSyncUrl }] : []; } else { return []; } diff --git a/test/spec/modules/seedtagBidAdapter_spec.js b/test/spec/modules/seedtagBidAdapter_spec.js index 5c9e6306e00..d0efd5f1f75 100644 --- a/test/spec/modules/seedtagBidAdapter_spec.js +++ b/test/spec/modules/seedtagBidAdapter_spec.js @@ -1,10 +1,10 @@ -import { expect } from "chai"; -import { spec, getTimeoutUrl } from "modules/seedtagBidAdapter.js"; -import * as utils from "src/utils.js"; -import { config } from "../../../src/config.js"; +import { expect } from 'chai'; +import { spec, getTimeoutUrl } from 'modules/seedtagBidAdapter.js'; +import * as utils from 'src/utils.js'; +import { config } from '../../../src/config.js'; -const PUBLISHER_ID = "0000-0000-01"; -const ADUNIT_ID = "000000"; +const PUBLISHER_ID = '0000-0000-01'; +const ADUNIT_ID = '000000'; function getSlotConfigs(mediaTypes, params) { return { @@ -13,15 +13,15 @@ function getSlotConfigs(mediaTypes, params) { [300, 250], [300, 600], ], - bidId: "30b31c1838de1e", - bidderRequestId: "22edbae2733bf6", - auctionId: "1d1a030790a475", + bidId: '30b31c1838de1e', + bidderRequestId: '22edbae2733bf6', + auctionId: '1d1a030790a475', bidRequestsCount: 1, - bidder: "seedtag", + bidder: 'seedtag', mediaTypes: mediaTypes, - src: "client", - transactionId: "d704d006-0d6e-4a09-ad6c-179e7e758096", - adUnitCode: "adunit-code", + src: 'client', + transactionId: 'd704d006-0d6e-4a09-ad6c-179e7e758096', + adUnitCode: 'adunit-code', }; } @@ -29,15 +29,15 @@ function createInStreamSlotConfig(mediaType) { return getSlotConfigs(mediaType, { publisherId: PUBLISHER_ID, adUnitId: ADUNIT_ID, - placement: "inStream", + placement: 'inStream', }); } -describe("Seedtag Adapter", function () { - describe("isBidRequestValid method", function () { - describe("returns true", function () { - describe("when banner slot config has all mandatory params", () => { - describe("and placement has the correct value", function () { +describe('Seedtag Adapter', function () { + describe('isBidRequestValid method', function () { + describe('returns true', function () { + describe('when banner slot config has all mandatory params', () => { + describe('and placement has the correct value', function () { const createBannerSlotConfig = (placement) => { return getSlotConfigs( { banner: {} }, @@ -48,9 +48,9 @@ describe("Seedtag Adapter", function () { } ); }; - const placements = ["inBanner", "inImage", "inScreen", "inArticle"]; + const placements = ['inBanner', 'inImage', 'inScreen', 'inArticle']; placements.forEach((placement) => { - it("should be " + placement, function () { + it('should be ' + placement, function () { const isBidRequestValid = spec.isBidRequestValid( createBannerSlotConfig(placement) ); @@ -59,38 +59,38 @@ describe("Seedtag Adapter", function () { }); }); }); - describe("when video slot has all mandatory params", function () { - it("should return true, when video context is instream", function () { + describe('when video slot has all mandatory params', function () { + it('should return true, when video context is instream', function () { const slotConfig = createInStreamSlotConfig({ video: { - context: "instream", + context: 'instream', playerSize: [[600, 200]], }, }); const isBidRequestValid = spec.isBidRequestValid(slotConfig); expect(isBidRequestValid).to.equal(true); }); - it("should return true, when video context is instream, but placement is not inStream", function () { + it('should return true, when video context is instream, but placement is not inStream', function () { const slotConfig = getSlotConfigs( { video: { - context: "instream", + context: 'instream', playerSize: [[600, 200]], }, }, { publisherId: PUBLISHER_ID, adUnitId: ADUNIT_ID, - placement: "inBanner", + placement: 'inBanner', } ); const isBidRequestValid = spec.isBidRequestValid(slotConfig); expect(isBidRequestValid).to.equal(false); }); - it("should return false, when video context is outstream", function () { + it('should return false, when video context is outstream', function () { const slotConfig = createInStreamSlotConfig({ video: { - context: "outstream", + context: 'outstream', playerSize: [[600, 200]], }, }); @@ -99,30 +99,30 @@ describe("Seedtag Adapter", function () { }); }); }); - describe("returns false", function () { - describe("when params are not correct", function () { + describe('returns false', function () { + describe('when params are not correct', function () { function createSlotConfig(params) { return getSlotConfigs({ banner: {} }, params); } - it("does not have the PublisherToken.", function () { + it('does not have the PublisherToken.', function () { const isBidRequestValid = spec.isBidRequestValid( createSlotConfig({ adUnitId: ADUNIT_ID, - placement: "inBanner", + placement: 'inBanner', }) ); expect(isBidRequestValid).to.equal(false); }); - it("does not have the AdUnitId.", function () { + it('does not have the AdUnitId.', function () { const isBidRequestValid = spec.isBidRequestValid( createSlotConfig({ publisherId: PUBLISHER_ID, - placement: "inBanner", + placement: 'inBanner', }) ); expect(isBidRequestValid).to.equal(false); }); - it("does not have the placement.", function () { + it('does not have the placement.', function () { const isBidRequestValid = spec.isBidRequestValid( createSlotConfig({ publisherId: PUBLISHER_ID, @@ -131,50 +131,50 @@ describe("Seedtag Adapter", function () { ); expect(isBidRequestValid).to.equal(false); }); - it("does not have a the correct placement.", function () { + it('does not have a the correct placement.', function () { const isBidRequestValid = spec.isBidRequestValid( createSlotConfig({ publisherId: PUBLISHER_ID, adUnitId: ADUNIT_ID, - placement: "another_thing", + placement: 'another_thing', }) ); expect(isBidRequestValid).to.equal(false); }); }); - describe("when video mediaType object is not correct", function () { - it("is a void object", function () { + describe('when video mediaType object is not correct', function () { + it('is a void object', function () { const isBidRequestValid = spec.isBidRequestValid( createInStreamSlotConfig({ video: {} }) ); expect(isBidRequestValid).to.equal(false); }); - it("does not have playerSize.", function () { + it('does not have playerSize.', function () { const isBidRequestValid = spec.isBidRequestValid( - createInStreamSlotConfig({ video: { context: "instream" } }) + createInStreamSlotConfig({ video: { context: 'instream' } }) ); expect(isBidRequestValid).to.equal(false); }); - it("is outstream ", function () { + it('is outstream ', function () { const isBidRequestValid = spec.isBidRequestValid( createInStreamSlotConfig({ video: { - context: "outstream", + context: 'outstream', playerSize: [[600, 200]], }, }) ); expect(isBidRequestValid).to.equal(false); }); - describe("order does not matter", function () { - it("when video is not the first slot", function () { + describe('order does not matter', function () { + it('when video is not the first slot', function () { const isBidRequestValid = spec.isBidRequestValid( createInStreamSlotConfig({ banner: {}, video: {} }) ); expect(isBidRequestValid).to.equal(false); }); - it("when video is the first slot", function () { + it('when video is the first slot', function () { const isBidRequestValid = spec.isBidRequestValid( createInStreamSlotConfig({ video: {}, banner: {} }) ); @@ -185,94 +185,94 @@ describe("Seedtag Adapter", function () { }); }); - describe("buildRequests method", function () { + describe('buildRequests method', function () { const bidderRequest = { - refererInfo: { page: "referer" }, + refererInfo: { page: 'referer' }, timeout: 1000, }; const mandatoryDisplayParams = { publisherId: PUBLISHER_ID, adUnitId: ADUNIT_ID, - placement: "inBanner", + placement: 'inBanner', }; const mandatoryVideoParams = { publisherId: PUBLISHER_ID, adUnitId: ADUNIT_ID, - placement: "inStream", + placement: 'inStream', }; const validBidRequests = [ getSlotConfigs({ banner: {} }, mandatoryDisplayParams), getSlotConfigs( { video: { - context: "instream", + context: 'instream', playerSize: [[300, 200]], - mimes: ["video/mp4"], + mimes: ['video/mp4'], }, }, mandatoryVideoParams ), ]; - it("Url params should be correct ", function () { + it('Url params should be correct ', function () { const request = spec.buildRequests(validBidRequests, bidderRequest); - expect(request.method).to.equal("POST"); - expect(request.url).to.equal("https://s.seedtag.com/c/hb/bid"); + expect(request.method).to.equal('POST'); + expect(request.url).to.equal('https://s.seedtag.com/c/hb/bid'); }); - it("Common data request should be correct", function () { + it('Common data request should be correct', function () { const now = Date.now(); const request = spec.buildRequests(validBidRequests, bidderRequest); const data = JSON.parse(request.data); - expect(data.url).to.equal("referer"); - expect(data.publisherToken).to.equal("0000-0000-01"); - expect(typeof data.version).to.equal("string"); + expect(data.url).to.equal('referer'); + expect(data.publisherToken).to.equal('0000-0000-01'); + expect(typeof data.version).to.equal('string'); expect( - ["fixed", "mobile", "unknown"].indexOf(data.connectionType) + ['fixed', 'mobile', 'unknown'].indexOf(data.connectionType) ).to.be.above(-1); expect(data.auctionStart).to.be.greaterThanOrEqual(now); expect(data.ttfb).to.be.greaterThanOrEqual(0); - expect(data.bidRequests[0].adUnitCode).to.equal("adunit-code"); + expect(data.bidRequests[0].adUnitCode).to.equal('adunit-code'); }); - describe("GDPR params", function () { - describe("when there arent consent management platform", function () { - it("cmp should be false", function () { + describe('GDPR params', function () { + describe('when there arent consent management platform', function () { + it('cmp should be false', function () { const request = spec.buildRequests(validBidRequests, bidderRequest); const data = JSON.parse(request.data); expect(data.cmp).to.equal(false); }); }); - describe("when there are consent management platform", function () { - it("cmps should be true and ga should not sended, when gdprApplies is undefined", function () { - bidderRequest["gdprConsent"] = { + describe('when there are consent management platform', function () { + it('cmps should be true and ga should not sended, when gdprApplies is undefined', function () { + bidderRequest['gdprConsent'] = { gdprApplies: undefined, - consentString: "consentString", + consentString: 'consentString', }; const request = spec.buildRequests(validBidRequests, bidderRequest); const data = JSON.parse(request.data); expect(data.cmp).to.equal(true); - expect(Object.keys(data).indexOf("data")).to.equal(-1); - expect(data.cd).to.equal("consentString"); + expect(Object.keys(data).indexOf('data')).to.equal(-1); + expect(data.cd).to.equal('consentString'); }); - it("cmps should be true and all gdpr parameters should be sended, when there are gdprApplies", function () { - bidderRequest["gdprConsent"] = { + it('cmps should be true and all gdpr parameters should be sended, when there are gdprApplies', function () { + bidderRequest['gdprConsent'] = { gdprApplies: true, - consentString: "consentString", + consentString: 'consentString', }; const request = spec.buildRequests(validBidRequests, bidderRequest); const data = JSON.parse(request.data); expect(data.cmp).to.equal(true); expect(data.ga).to.equal(true); - expect(data.cd).to.equal("consentString"); + expect(data.cd).to.equal('consentString'); }); - it("should expose gvlid", function () { + it('should expose gvlid', function () { expect(spec.gvlid).to.equal(157); }); - it("should handle uspConsent", function () { - const uspConsent = "1---"; + it('should handle uspConsent', function () { + const uspConsent = '1---'; - bidderRequest["uspConsent"] = uspConsent; + bidderRequest['uspConsent'] = uspConsent; const request = spec.buildRequests(validBidRequests, bidderRequest); const payload = JSON.parse(request.data); @@ -284,7 +284,7 @@ describe("Seedtag Adapter", function () { it("shouldn't send uspConsent when not available", function () { const uspConsent = undefined; - bidderRequest["uspConsent"] = uspConsent; + bidderRequest['uspConsent'] = uspConsent; const request = spec.buildRequests(validBidRequests, bidderRequest); const payload = JSON.parse(request.data); @@ -294,33 +294,33 @@ describe("Seedtag Adapter", function () { }); }); - describe("BidRequests params", function () { + describe('BidRequests params', function () { const request = spec.buildRequests(validBidRequests, bidderRequest); const data = JSON.parse(request.data); const bidRequests = data.bidRequests; - it("should request a Banner", function () { + it('should request a Banner', function () { const bannerBid = bidRequests[0]; - expect(bannerBid.id).to.equal("30b31c1838de1e"); + expect(bannerBid.id).to.equal('30b31c1838de1e'); expect(bannerBid.transactionId).to.equal( - "d704d006-0d6e-4a09-ad6c-179e7e758096" + 'd704d006-0d6e-4a09-ad6c-179e7e758096' ); - expect(bannerBid.supplyTypes[0]).to.equal("display"); - expect(bannerBid.adUnitId).to.equal("000000"); + expect(bannerBid.supplyTypes[0]).to.equal('display'); + expect(bannerBid.adUnitId).to.equal('000000'); expect(bannerBid.sizes[0][0]).to.equal(300); expect(bannerBid.sizes[0][1]).to.equal(250); expect(bannerBid.sizes[1][0]).to.equal(300); expect(bannerBid.sizes[1][1]).to.equal(600); expect(bannerBid.requestCount).to.equal(1); }); - it("should request an InStream Video", function () { + it('should request an InStream Video', function () { const videoBid = bidRequests[1]; - expect(videoBid.id).to.equal("30b31c1838de1e"); + expect(videoBid.id).to.equal('30b31c1838de1e'); expect(videoBid.transactionId).to.equal( - "d704d006-0d6e-4a09-ad6c-179e7e758096" + 'd704d006-0d6e-4a09-ad6c-179e7e758096' ); - expect(videoBid.supplyTypes[0]).to.equal("video"); - expect(videoBid.adUnitId).to.equal("000000"); - expect(videoBid.videoParams.mimes).to.eql(["video/mp4"]); + expect(videoBid.supplyTypes[0]).to.equal('video'); + expect(videoBid.adUnitId).to.equal('000000'); + expect(videoBid.videoParams.mimes).to.eql(['video/mp4']); expect(videoBid.videoParams.w).to.equal(300); expect(videoBid.videoParams.h).to.equal(200); expect(videoBid.sizes[0][0]).to.equal(300); @@ -331,8 +331,8 @@ describe("Seedtag Adapter", function () { }); }); - describe("COPPA param", function () { - it("should add COPPA param to payload when prebid config has parameter COPPA equal to true", function () { + describe('COPPA param', function () { + it('should add COPPA param to payload when prebid config has parameter COPPA equal to true', function () { config.setConfig({ coppa: true }); const request = spec.buildRequests(validBidRequests, bidderRequest); @@ -340,7 +340,7 @@ describe("Seedtag Adapter", function () { expect(data.coppa).to.equal(true); }); - it("should not add COPPA param to payload when prebid config has parameter COPPA equal to false", function () { + it('should not add COPPA param to payload when prebid config has parameter COPPA equal to false', function () { config.setConfig({ coppa: false }); const request = spec.buildRequests(validBidRequests, bidderRequest); @@ -348,28 +348,28 @@ describe("Seedtag Adapter", function () { expect(data.coppa).to.be.undefined; }); - it("should not add COPPA param to payload when prebid config has not parameter COPPA", function () { + it('should not add COPPA param to payload when prebid config has not parameter COPPA', function () { const request = spec.buildRequests(validBidRequests, bidderRequest); const data = JSON.parse(request.data); expect(data.coppa).to.be.undefined; }); }); - describe("schain param", function () { - it("should add schain to payload when exposed on validBidRequest", function () { + describe('schain param', function () { + it('should add schain to payload when exposed on validBidRequest', function () { // https://github.com/prebid/Prebid.js/blob/master/modules/schain.md#sample-code-for-passing-the-schain-object const schain = { - ver: "1.0", + ver: '1.0', complete: 1, nodes: [ { - asi: "indirectseller.com", - sid: "00001", + asi: 'indirectseller.com', + sid: '00001', hp: 1, }, { - asi: "indirectseller-2.com", - sid: "00002", + asi: 'indirectseller-2.com', + sid: '00002', hp: 1, }, ], @@ -397,191 +397,191 @@ describe("Seedtag Adapter", function () { }); }); - describe("interpret response method", function () { - it("should return a void array, when the server response are not correct.", function () { + describe('interpret response method', function () { + it('should return a void array, when the server response are not correct.', function () { const request = { data: JSON.stringify({}) }; const serverResponse = { body: {}, }; const bids = spec.interpretResponse(serverResponse, request); - expect(typeof bids).to.equal("object"); + expect(typeof bids).to.equal('object'); expect(bids.length).to.equal(0); }); - it("should return a void array, when the server response have no bids.", function () { + it('should return a void array, when the server response have no bids.', function () { const request = { data: JSON.stringify({}) }; const serverResponse = { body: { bids: [] } }; const bids = spec.interpretResponse(serverResponse, request); - expect(typeof bids).to.equal("object"); + expect(typeof bids).to.equal('object'); expect(bids.length).to.equal(0); }); - describe("when the server response return a bid", function () { - describe("the bid is a banner", function () { - it("should return a banner bid", function () { + describe('when the server response return a bid', function () { + describe('the bid is a banner', function () { + it('should return a banner bid', function () { const request = { data: JSON.stringify({}) }; const serverResponse = { body: { bids: [ { - bidId: "2159a54dc2566f", + bidId: '2159a54dc2566f', price: 0.5, - currency: "USD", - content: "content", + currency: 'USD', + content: 'content', width: 728, height: 90, - mediaType: "display", + mediaType: 'display', ttl: 360, - nurl: "testurl.com/nurl", - adomain: ["advertiserdomain.com"], + nurl: 'testurl.com/nurl', + adomain: ['advertiserdomain.com'], }, ], - cookieSync: { url: "" }, + cookieSync: { url: '' }, }, }; const bids = spec.interpretResponse(serverResponse, request); expect(bids.length).to.equal(1); - expect(bids[0].requestId).to.equal("2159a54dc2566f"); + expect(bids[0].requestId).to.equal('2159a54dc2566f'); expect(bids[0].cpm).to.equal(0.5); expect(bids[0].width).to.equal(728); expect(bids[0].height).to.equal(90); - expect(bids[0].currency).to.equal("USD"); + expect(bids[0].currency).to.equal('USD'); expect(bids[0].netRevenue).to.equal(true); - expect(bids[0].ad).to.equal("content"); - expect(bids[0].nurl).to.equal("testurl.com/nurl"); + expect(bids[0].ad).to.equal('content'); + expect(bids[0].nurl).to.equal('testurl.com/nurl'); expect(bids[0].meta.advertiserDomains).to.deep.equal([ - "advertiserdomain.com", + 'advertiserdomain.com', ]); }); }); - describe("the bid is a video", function () { - it("should return a instream bid", function () { + describe('the bid is a video', function () { + it('should return a instream bid', function () { const request = { data: JSON.stringify({}) }; const serverResponse = { body: { bids: [ { - bidId: "2159a54dc2566f", + bidId: '2159a54dc2566f', price: 0.5, - currency: "USD", - content: "content", + currency: 'USD', + content: 'content', width: 728, height: 90, - mediaType: "video", + mediaType: 'video', ttl: 360, nurl: undefined, }, ], - cookieSync: { url: "" }, + cookieSync: { url: '' }, }, }; const bids = spec.interpretResponse(serverResponse, request); expect(bids.length).to.equal(1); - expect(bids[0].requestId).to.equal("2159a54dc2566f"); + expect(bids[0].requestId).to.equal('2159a54dc2566f'); expect(bids[0].cpm).to.equal(0.5); expect(bids[0].width).to.equal(728); expect(bids[0].height).to.equal(90); - expect(bids[0].currency).to.equal("USD"); + expect(bids[0].currency).to.equal('USD'); expect(bids[0].netRevenue).to.equal(true); - expect(bids[0].vastXml).to.equal("content"); + expect(bids[0].vastXml).to.equal('content'); expect(bids[0].meta.advertiserDomains).to.deep.equal([]); }); }); }); }); - describe("user syncs method", function () { - it("should return empty array, when iframe sync option are disabled.", function () { + describe('user syncs method', function () { + it('should return empty array, when iframe sync option are disabled.', function () { const syncOption = { iframeEnabled: false }; - const serverResponses = [{ body: { cookieSync: "someUrl" } }]; + const serverResponses = [{ body: { cookieSync: 'someUrl' } }]; const cookieSyncArray = spec.getUserSyncs(syncOption, serverResponses); expect(cookieSyncArray.length).to.equal(0); }); - it("should return empty array, when the server response are wrong.", function () { + it('should return empty array, when the server response are wrong.', function () { const syncOption = { iframeEnabled: true }; const serverResponses = [{ body: {} }]; const cookieSyncArray = spec.getUserSyncs(syncOption, serverResponses); expect(cookieSyncArray.length).to.equal(0); }); - it("should return empty array, when the server response are void.", function () { + it('should return empty array, when the server response are void.', function () { const syncOption = { iframeEnabled: true }; - const serverResponses = [{ body: { cookieSync: "" } }]; + const serverResponses = [{ body: { cookieSync: '' } }]; const cookieSyncArray = spec.getUserSyncs(syncOption, serverResponses); expect(cookieSyncArray.length).to.equal(0); }); - it("should return a array with the cookie sync, when the server response with a cookie sync.", function () { + it('should return a array with the cookie sync, when the server response with a cookie sync.', function () { const syncOption = { iframeEnabled: true }; - const serverResponses = [{ body: { cookieSync: "someUrl" } }]; + const serverResponses = [{ body: { cookieSync: 'someUrl' } }]; const cookieSyncArray = spec.getUserSyncs(syncOption, serverResponses); expect(cookieSyncArray.length).to.equal(1); - expect(cookieSyncArray[0].type).to.equal("iframe"); - expect(cookieSyncArray[0].url).to.equal("someUrl"); + expect(cookieSyncArray[0].type).to.equal('iframe'); + expect(cookieSyncArray[0].url).to.equal('someUrl'); }); }); - describe("onTimeout", function () { + describe('onTimeout', function () { beforeEach(function () { - sinon.stub(utils, "triggerPixel"); + sinon.stub(utils, 'triggerPixel'); }); afterEach(function () { utils.triggerPixel.restore(); }); - it("should return the correct endpoint", function () { - const params = { publisherId: "0000", adUnitId: "11111" }; + it('should return the correct endpoint', function () { + const params = { publisherId: '0000', adUnitId: '11111' }; const timeout = 3000; const timeoutData = [{ params: [params], timeout }]; const timeoutUrl = getTimeoutUrl(timeoutData); expect(timeoutUrl).to.equal( - "https://s.seedtag.com/se/hb/timeout?publisherToken=" + + 'https://s.seedtag.com/se/hb/timeout?publisherToken=' + params.publisherId + - "&adUnitId=" + + '&adUnitId=' + params.adUnitId + - "&timeout=" + + '&timeout=' + timeout ); }); - it("should set the timeout pixel", function () { - const params = { publisherId: "0000", adUnitId: "11111" }; + it('should set the timeout pixel', function () { + const params = { publisherId: '0000', adUnitId: '11111' }; const timeout = 3000; const timeoutData = [{ params: [params], timeout }]; spec.onTimeout(timeoutData); expect( utils.triggerPixel.calledWith( - "https://s.seedtag.com/se/hb/timeout?publisherToken=" + + 'https://s.seedtag.com/se/hb/timeout?publisherToken=' + params.publisherId + - "&adUnitId=" + + '&adUnitId=' + params.adUnitId + - "&timeout=" + + '&timeout=' + timeout ) ).to.equal(true); }); }); - describe("onBidWon", function () { + describe('onBidWon', function () { beforeEach(function () { - sinon.stub(utils, "triggerPixel"); + sinon.stub(utils, 'triggerPixel'); }); afterEach(function () { utils.triggerPixel.restore(); }); - describe("without nurl", function () { + describe('without nurl', function () { const bid = {}; - it("does not create pixel ", function () { + it('does not create pixel ', function () { spec.onBidWon(bid); expect(utils.triggerPixel.called).to.equal(false); }); }); - describe("with nurl", function () { - const nurl = "http://seedtag_domain/won"; + describe('with nurl', function () { + const nurl = 'http://seedtag_domain/won'; const bid = { nurl }; - it("creates nurl pixel if bid nurl", function () { + it('creates nurl pixel if bid nurl', function () { spec.onBidWon({ nurl }); expect(utils.triggerPixel.calledWith(nurl)).to.equal(true); }); From edb855df1b592cf74963c7e9516ee93f98fe99f1 Mon Sep 17 00:00:00 2001 From: Yohan Boutin Date: Thu, 10 Nov 2022 14:22:03 +0100 Subject: [PATCH 9/9] empty commit to relaunch CI