From d04b912d6bea69a2fe79886d0b9bfae22e41316f Mon Sep 17 00:00:00 2001 From: Aleksei Surovenko Date: Thu, 8 Jun 2023 11:45:46 +0200 Subject: [PATCH 1/7] ZetaGlobalSsp: change logic with mediaType --- modules/zeta_global_sspBidAdapter.js | 20 ++---- .../modules/zeta_global_sspBidAdapter_spec.js | 70 +++++++++++++++++++ 2 files changed, 77 insertions(+), 13 deletions(-) diff --git a/modules/zeta_global_sspBidAdapter.js b/modules/zeta_global_sspBidAdapter.js index 4f13787e219..042d600deed 100644 --- a/modules/zeta_global_sspBidAdapter.js +++ b/modules/zeta_global_sspBidAdapter.js @@ -11,11 +11,9 @@ const TIMEOUT_URL = 'https://ssp.disqus.com/timeout/prebid'; const USER_SYNC_URL_IFRAME = 'https://ssp.disqus.com/sync?type=iframe'; const USER_SYNC_URL_IMAGE = 'https://ssp.disqus.com/sync?type=image'; const DEFAULT_CUR = 'USD'; -const TTL = 200; +const TTL = 300; const NET_REV = true; -const VIDEO_REGEX = new RegExp(/VAST\s+version/); - const DATA_TYPES = { 'NUMBER': 'number', 'STRING': 'string', @@ -191,6 +189,7 @@ export const spec = { currency: response.cur, width: zetaBid.w, height: zetaBid.h, + mediaType: bidRequest.data.imp[0].video ? VIDEO : BANNER, ad: zetaBid.adm, ttl: TTL, creativeId: zetaBid.crid, @@ -202,6 +201,9 @@ export const spec = { }; } provideMediaType(zetaBid, bid); + if (bid.mediaType === VIDEO) { + bid.vastXml = bid.ad; + } bidResponses.push(bid); }) }) @@ -334,17 +336,9 @@ function provideEids(request, payload) { } function provideMediaType(zetaBid, bid) { - if (zetaBid.ext && zetaBid.ext.bidtype) { - if (zetaBid.ext.bidtype === VIDEO) { - bid.mediaType = VIDEO; - bid.vastXml = bid.ad; - } else { - bid.mediaType = BANNER; - } - } else { - if (VIDEO_REGEX.test(bid.ad)) { + if (zetaBid.ext && zetaBid.ext.prebid && zetaBid.ext.prebid.type) { + if (zetaBid.ext.prebid.type === VIDEO) { bid.mediaType = VIDEO; - bid.vastXml = bid.ad; } else { bid.mediaType = BANNER; } diff --git a/test/spec/modules/zeta_global_sspBidAdapter_spec.js b/test/spec/modules/zeta_global_sspBidAdapter_spec.js index 28d7ba21de4..966b4d86f0e 100644 --- a/test/spec/modules/zeta_global_sspBidAdapter_spec.js +++ b/test/spec/modules/zeta_global_sspBidAdapter_spec.js @@ -171,6 +171,31 @@ describe('Zeta Ssp Bid Adapter', function () { params: params }]; + const response = { + body: { + id: '12345', + seatbid: [ + { + bid: [ + { + id: 'auctionId', + impid: 'impId', + price: 0.0, + adm: 'adMarkup', + crid: 'creativeId', + adomain: [ + 'https://example.com' + ], + h: 250, + w: 300 + } + ] + } + ], + cur: 'USD' + } + }; + it('Test the bid validation function', function () { const validBid = spec.isBidRequestValid(bannerRequest[0]); const invalidBid = spec.isBidRequestValid(null); @@ -465,4 +490,49 @@ describe('Zeta Ssp Bid Adapter', function () { expect(payload.imp[0].banner.format[2].w).to.eql(100); expect(payload.imp[0].banner.format[2].h).to.eql(150); }); + + it('Test the response default mediaType:banner', function () { + const bidRequest = { + data: bannerRequest + } + + const bidResponse = spec.interpretResponse(response, bidRequest); + expect(bidResponse).to.not.be.empty; + expect(bidResponse.length).to.eql(1); + expect(bidResponse[0].mediaType).to.eql(BANNER); + expect(bidResponse[0].ad).to.eql(response.body.seatbid[0].bid[0].adm); + expect(bidResponse[0].vastXml).to.be.undefined; + }); + + it('Test the response default mediaType:video', function () { + const bidRequest = { + data: videoRequest + } + + const bidResponse = spec.interpretResponse(response, bidRequest); + expect(bidResponse).to.not.be.empty; + expect(bidResponse.length).to.eql(1); + expect(bidResponse[0].mediaType).to.eql(VIDEO); + expect(bidResponse[0].ad).to.eql(response.body.seatbid[0].bid[0].adm); + expect(bidResponse[0].vastXml).to.eql(response.body.seatbid[0].bid[0].adm); + }); + + it('Test the response mediaType:video from response bid ext', function () { + const bidRequest = { + data: bannerRequest + } + + response.body.seatbid[0].bid[0].ext = { + prebid: { + type: 'video' + } + } + + const bidResponse = spec.interpretResponse(response, bidRequest); + expect(bidResponse).to.not.be.empty; + expect(bidResponse.length).to.eql(1); + expect(bidResponse[0].mediaType).to.eql(VIDEO); + expect(bidResponse[0].ad).to.eql(response.body.seatbid[0].bid[0].adm); + expect(bidResponse[0].vastXml).to.eql(response.body.seatbid[0].bid[0].adm); + }); }); From c670660d5da3f8d61d4122630379e6afbe61f407 Mon Sep 17 00:00:00 2001 From: Aleksei Surovenko Date: Thu, 8 Jun 2023 12:11:03 +0200 Subject: [PATCH 2/7] ZetaGlobalSsp: fix build --- modules/zeta_global_sspBidAdapter.js | 7 ++++--- .../modules/zeta_global_sspBidAdapter_spec.js | 18 +++++++++--------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/modules/zeta_global_sspBidAdapter.js b/modules/zeta_global_sspBidAdapter.js index 042d600deed..e2caa98439e 100644 --- a/modules/zeta_global_sspBidAdapter.js +++ b/modules/zeta_global_sspBidAdapter.js @@ -189,7 +189,6 @@ export const spec = { currency: response.cur, width: zetaBid.w, height: zetaBid.h, - mediaType: bidRequest.data.imp[0].video ? VIDEO : BANNER, ad: zetaBid.adm, ttl: TTL, creativeId: zetaBid.crid, @@ -200,7 +199,7 @@ export const spec = { advertiserDomains: zetaBid.adomain }; } - provideMediaType(zetaBid, bid); + provideMediaType(zetaBid, bid, bidRequest.data); if (bid.mediaType === VIDEO) { bid.vastXml = bid.ad; } @@ -335,13 +334,15 @@ function provideEids(request, payload) { } } -function provideMediaType(zetaBid, bid) { +function provideMediaType(zetaBid, bid, bidRequest) { if (zetaBid.ext && zetaBid.ext.prebid && zetaBid.ext.prebid.type) { if (zetaBid.ext.prebid.type === VIDEO) { bid.mediaType = VIDEO; } else { bid.mediaType = BANNER; } + } else { + bid.mediaType = bidRequest.imp[0].video ? VIDEO : BANNER; } } diff --git a/test/spec/modules/zeta_global_sspBidAdapter_spec.js b/test/spec/modules/zeta_global_sspBidAdapter_spec.js index 966b4d86f0e..12e617743d8 100644 --- a/test/spec/modules/zeta_global_sspBidAdapter_spec.js +++ b/test/spec/modules/zeta_global_sspBidAdapter_spec.js @@ -171,7 +171,7 @@ describe('Zeta Ssp Bid Adapter', function () { params: params }]; - const response = { + const responseData = { body: { id: '12345', seatbid: [ @@ -496,11 +496,11 @@ describe('Zeta Ssp Bid Adapter', function () { data: bannerRequest } - const bidResponse = spec.interpretResponse(response, bidRequest); + const bidResponse = spec.interpretResponse(responseData, bidRequest); expect(bidResponse).to.not.be.empty; expect(bidResponse.length).to.eql(1); expect(bidResponse[0].mediaType).to.eql(BANNER); - expect(bidResponse[0].ad).to.eql(response.body.seatbid[0].bid[0].adm); + expect(bidResponse[0].ad).to.eql(responseData.body.seatbid[0].bid[0].adm); expect(bidResponse[0].vastXml).to.be.undefined; }); @@ -509,12 +509,12 @@ describe('Zeta Ssp Bid Adapter', function () { data: videoRequest } - const bidResponse = spec.interpretResponse(response, bidRequest); + const bidResponse = spec.interpretResponse(responseData, bidRequest); expect(bidResponse).to.not.be.empty; expect(bidResponse.length).to.eql(1); expect(bidResponse[0].mediaType).to.eql(VIDEO); - expect(bidResponse[0].ad).to.eql(response.body.seatbid[0].bid[0].adm); - expect(bidResponse[0].vastXml).to.eql(response.body.seatbid[0].bid[0].adm); + expect(bidResponse[0].ad).to.eql(responseData.body.seatbid[0].bid[0].adm); + expect(bidResponse[0].vastXml).to.eql(responseData.body.seatbid[0].bid[0].adm); }); it('Test the response mediaType:video from response bid ext', function () { @@ -528,11 +528,11 @@ describe('Zeta Ssp Bid Adapter', function () { } } - const bidResponse = spec.interpretResponse(response, bidRequest); + const bidResponse = spec.interpretResponse(responseData, bidRequest); expect(bidResponse).to.not.be.empty; expect(bidResponse.length).to.eql(1); expect(bidResponse[0].mediaType).to.eql(VIDEO); - expect(bidResponse[0].ad).to.eql(response.body.seatbid[0].bid[0].adm); - expect(bidResponse[0].vastXml).to.eql(response.body.seatbid[0].bid[0].adm); + expect(bidResponse[0].ad).to.eql(responseData.body.seatbid[0].bid[0].adm); + expect(bidResponse[0].vastXml).to.eql(responseData.body.seatbid[0].bid[0].adm); }); }); From 3b7e322d6789e833eed750cdb243447df612ef70 Mon Sep 17 00:00:00 2001 From: Aleksei Surovenko Date: Thu, 8 Jun 2023 12:53:12 +0200 Subject: [PATCH 3/7] ZetaGlobalSsp: fix tests --- modules/zeta_global_sspBidAdapter.js | 6 +- .../modules/zeta_global_sspBidAdapter_spec.js | 108 ++++++++++++++---- 2 files changed, 84 insertions(+), 30 deletions(-) diff --git a/modules/zeta_global_sspBidAdapter.js b/modules/zeta_global_sspBidAdapter.js index e2caa98439e..4fe1fc53a7c 100644 --- a/modules/zeta_global_sspBidAdapter.js +++ b/modules/zeta_global_sspBidAdapter.js @@ -336,11 +336,7 @@ function provideEids(request, payload) { function provideMediaType(zetaBid, bid, bidRequest) { if (zetaBid.ext && zetaBid.ext.prebid && zetaBid.ext.prebid.type) { - if (zetaBid.ext.prebid.type === VIDEO) { - bid.mediaType = VIDEO; - } else { - bid.mediaType = BANNER; - } + bid.mediaType = zetaBid.ext.prebid.type === VIDEO ? VIDEO : BANNER; } else { bid.mediaType = bidRequest.imp[0].video ? VIDEO : BANNER; } diff --git a/test/spec/modules/zeta_global_sspBidAdapter_spec.js b/test/spec/modules/zeta_global_sspBidAdapter_spec.js index 12e617743d8..75bae0e6e7b 100644 --- a/test/spec/modules/zeta_global_sspBidAdapter_spec.js +++ b/test/spec/modules/zeta_global_sspBidAdapter_spec.js @@ -171,7 +171,7 @@ describe('Zeta Ssp Bid Adapter', function () { params: params }]; - const responseData = { + const zetaResponse = { body: { id: '12345', seatbid: [ @@ -194,6 +194,62 @@ describe('Zeta Ssp Bid Adapter', function () { ], cur: 'USD' } + } + + const responseBannerPayload = { + data: { + id: '123', + site: { + id: 'SITE_ID', + page: 'page.com', + domain: 'domain.com' + }, + user: { + id: '45asdf9tydhrty789adfad4678rew656789', + buyeruid: '1234567890' + }, + cur: [ + 'USD' + ], + imp: [ + { + id: '1', + banner: { + h: 600, + w: 160 + } + } + ], + at: 1 + } + }; + + const responseVideoPayload = { + data: { + id: '123', + site: { + id: 'SITE_ID', + page: 'page.com', + domain: 'domain.com' + }, + user: { + id: '45asdf9tydhrty789adfad4678rew656789', + buyeruid: '1234567890' + }, + cur: [ + 'USD' + ], + imp: [ + { + id: '1', + video: { + h: 600, + w: 160 + } + } + ], + at: 1 + } }; it('Test the bid validation function', function () { @@ -285,7 +341,7 @@ describe('Zeta Ssp Bid Adapter', function () { } }; - const bidResponse = spec.interpretResponse(response, null); + const bidResponse = spec.interpretResponse(response, {data: responseBannerPayload}); expect(bidResponse).to.not.be.empty; const bid1 = bidResponse[0]; @@ -492,47 +548,49 @@ describe('Zeta Ssp Bid Adapter', function () { }); it('Test the response default mediaType:banner', function () { - const bidRequest = { - data: bannerRequest - } - - const bidResponse = spec.interpretResponse(responseData, bidRequest); + const bidResponse = spec.interpretResponse(zetaResponse, responseBannerPayload); expect(bidResponse).to.not.be.empty; expect(bidResponse.length).to.eql(1); expect(bidResponse[0].mediaType).to.eql(BANNER); - expect(bidResponse[0].ad).to.eql(responseData.body.seatbid[0].bid[0].adm); + expect(bidResponse[0].ad).to.eql(zetaResponse.body.seatbid[0].bid[0].adm); expect(bidResponse[0].vastXml).to.be.undefined; }); it('Test the response default mediaType:video', function () { - const bidRequest = { - data: videoRequest - } - - const bidResponse = spec.interpretResponse(responseData, bidRequest); + const bidResponse = spec.interpretResponse(zetaResponse, responseVideoPayload); expect(bidResponse).to.not.be.empty; expect(bidResponse.length).to.eql(1); expect(bidResponse[0].mediaType).to.eql(VIDEO); - expect(bidResponse[0].ad).to.eql(responseData.body.seatbid[0].bid[0].adm); - expect(bidResponse[0].vastXml).to.eql(responseData.body.seatbid[0].bid[0].adm); + expect(bidResponse[0].ad).to.eql(zetaResponse.body.seatbid[0].bid[0].adm); + expect(bidResponse[0].vastXml).to.eql(zetaResponse.body.seatbid[0].bid[0].adm); }); - it('Test the response mediaType:video from response bid ext', function () { - const bidRequest = { - data: bannerRequest - } - - response.body.seatbid[0].bid[0].ext = { + it('Test the response mediaType:video from ext param', function () { + zetaResponse.body.seatbid[0].bid[0].ext = { prebid: { type: 'video' } } - - const bidResponse = spec.interpretResponse(responseData, bidRequest); + const bidResponse = spec.interpretResponse(zetaResponse, responseBannerPayload); expect(bidResponse).to.not.be.empty; expect(bidResponse.length).to.eql(1); expect(bidResponse[0].mediaType).to.eql(VIDEO); - expect(bidResponse[0].ad).to.eql(responseData.body.seatbid[0].bid[0].adm); - expect(bidResponse[0].vastXml).to.eql(responseData.body.seatbid[0].bid[0].adm); + expect(bidResponse[0].ad).to.eql(zetaResponse.body.seatbid[0].bid[0].adm); + expect(bidResponse[0].vastXml).to.eql(zetaResponse.body.seatbid[0].bid[0].adm); }); + + it('Test the response mediaType:banner from ext param', function () { + zetaResponse.body.seatbid[0].bid[0].ext = { + prebid: { + type: 'banner' + } + } + const bidResponse = spec.interpretResponse(zetaResponse, responseVideoPayload); + expect(bidResponse).to.not.be.empty; + expect(bidResponse.length).to.eql(1); + expect(bidResponse[0].mediaType).to.eql(BANNER); + expect(bidResponse[0].ad).to.eql(zetaResponse.body.seatbid[0].bid[0].adm); + expect(bidResponse[0].vastXml).to.be.undefined; + }); + }); From 30980ee7e10c7a61621129972df5c730a14817c9 Mon Sep 17 00:00:00 2001 From: Aleksei Surovenko Date: Thu, 8 Jun 2023 12:54:52 +0200 Subject: [PATCH 4/7] ZetaGlobalSsp: fix tests (2) --- test/spec/modules/zeta_global_sspBidAdapter_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/modules/zeta_global_sspBidAdapter_spec.js b/test/spec/modules/zeta_global_sspBidAdapter_spec.js index 75bae0e6e7b..30079095c3e 100644 --- a/test/spec/modules/zeta_global_sspBidAdapter_spec.js +++ b/test/spec/modules/zeta_global_sspBidAdapter_spec.js @@ -341,7 +341,7 @@ describe('Zeta Ssp Bid Adapter', function () { } }; - const bidResponse = spec.interpretResponse(response, {data: responseBannerPayload}); + const bidResponse = spec.interpretResponse(response, responseBannerPayload); expect(bidResponse).to.not.be.empty; const bid1 = bidResponse[0]; From df38287190b75569544f247b4ffc2b91d0547534 Mon Sep 17 00:00:00 2001 From: Aleksei Surovenko Date: Thu, 8 Jun 2023 13:02:54 +0200 Subject: [PATCH 5/7] ZetaGlobalSsp: fix lint --- test/spec/modules/zeta_global_sspBidAdapter_spec.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/spec/modules/zeta_global_sspBidAdapter_spec.js b/test/spec/modules/zeta_global_sspBidAdapter_spec.js index 30079095c3e..0556933c6ed 100644 --- a/test/spec/modules/zeta_global_sspBidAdapter_spec.js +++ b/test/spec/modules/zeta_global_sspBidAdapter_spec.js @@ -592,5 +592,4 @@ describe('Zeta Ssp Bid Adapter', function () { expect(bidResponse[0].ad).to.eql(zetaResponse.body.seatbid[0].bid[0].adm); expect(bidResponse[0].vastXml).to.be.undefined; }); - }); From ac87818c540369ae356967bee2cb241ed086d753 Mon Sep 17 00:00:00 2001 From: Aleksei Surovenko Date: Thu, 8 Jun 2023 13:12:14 +0200 Subject: [PATCH 6/7] ZetaGlobalSsp: fix tests (3) --- test/spec/modules/zeta_global_sspBidAdapter_spec.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/spec/modules/zeta_global_sspBidAdapter_spec.js b/test/spec/modules/zeta_global_sspBidAdapter_spec.js index 0556933c6ed..66e8d60cd24 100644 --- a/test/spec/modules/zeta_global_sspBidAdapter_spec.js +++ b/test/spec/modules/zeta_global_sspBidAdapter_spec.js @@ -305,7 +305,10 @@ describe('Zeta Ssp Bid Adapter', function () { 'https://example.com' ], h: 250, - w: 300 + w: 300, + ext: { + bidtype: 'banner' + } }, { id: 'auctionId2', @@ -332,7 +335,10 @@ describe('Zeta Ssp Bid Adapter', function () { 'https://example3.com' ], h: 400, - w: 300 + w: 300, + ext: { + bidtype: 'video' + } } ] } From 02895c16693a17cbf79ca2ef0bdc196b0b97f230 Mon Sep 17 00:00:00 2001 From: Aleksei Surovenko Date: Thu, 8 Jun 2023 13:18:09 +0200 Subject: [PATCH 7/7] ZetaGlobalSsp: fix tests (4) --- test/spec/modules/zeta_global_sspBidAdapter_spec.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/test/spec/modules/zeta_global_sspBidAdapter_spec.js b/test/spec/modules/zeta_global_sspBidAdapter_spec.js index 66e8d60cd24..601f4546a29 100644 --- a/test/spec/modules/zeta_global_sspBidAdapter_spec.js +++ b/test/spec/modules/zeta_global_sspBidAdapter_spec.js @@ -307,7 +307,9 @@ describe('Zeta Ssp Bid Adapter', function () { h: 250, w: 300, ext: { - bidtype: 'banner' + prebid: { + type: 'banner' + } } }, { @@ -322,7 +324,9 @@ describe('Zeta Ssp Bid Adapter', function () { h: 150, w: 200, ext: { - bidtype: 'video' + prebid: { + type: 'video' + } } }, { @@ -337,7 +341,9 @@ describe('Zeta Ssp Bid Adapter', function () { h: 400, w: 300, ext: { - bidtype: 'video' + prebid: { + type: 'video' + } } } ]