From 8bfb476b27ba13b4ce18703f63503dbe68ab53f9 Mon Sep 17 00:00:00 2001 From: Desvillettes Aurelien Date: Mon, 11 Oct 2021 13:40:40 +0200 Subject: [PATCH 1/3] add TTD URL in getUserSyncs method and related unit tests --- modules/oguryBidAdapter.js | 14 +++++--- test/spec/modules/oguryBidAdapter_spec.js | 44 +++++++++++++++-------- 2 files changed, 40 insertions(+), 18 deletions(-) diff --git a/modules/oguryBidAdapter.js b/modules/oguryBidAdapter.js index fcbb89c5188..c7a722b2003 100644 --- a/modules/oguryBidAdapter.js +++ b/modules/oguryBidAdapter.js @@ -24,10 +24,16 @@ function isBidRequestValid(bid) { function getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent) { if (!syncOptions.pixelEnabled) return []; - return [{ - type: 'image', - url: `${MS_COOKIE_SYNC_DOMAIN}/v1/init-sync/bid-switch?iab_string=${(gdprConsent && gdprConsent.consentString) || ''}&source=prebid` - }] + return [ + { + type: 'image', + url: `${MS_COOKIE_SYNC_DOMAIN}/v1/init-sync/bid-switch?iab_string=${(gdprConsent && gdprConsent.consentString) || ''}&source=prebid` + }, + { + type: 'image', + url: `${MS_COOKIE_SYNC_DOMAIN}/ttd/init-sync?iab_string=${(gdprConsent && gdprConsent.consentString) || ''}&source=prebid` + } + ] } function buildRequests(validBidRequests, bidderRequest) { diff --git a/test/spec/modules/oguryBidAdapter_spec.js b/test/spec/modules/oguryBidAdapter_spec.js index d3a154b3989..25d483a931c 100644 --- a/test/spec/modules/oguryBidAdapter_spec.js +++ b/test/spec/modules/oguryBidAdapter_spec.js @@ -119,22 +119,26 @@ describe('OguryBidAdapter', function () { }; }); - it('should return syncs array with an element of type image', () => { + it('should return syncs array with two elements of type image', () => { const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent); - expect(userSyncs).to.have.lengthOf(1); + expect(userSyncs).to.have.lengthOf(2); expect(userSyncs[0].type).to.equal('image'); expect(userSyncs[0].url).to.contain('https://ms-cookie-sync.presage.io/v1/init-sync/bid-switch'); + expect(userSyncs[1].type).to.equal('image'); + expect(userSyncs[1].url).to.contain('https://ms-cookie-sync.presage.io/ttd/init-sync'); }); it('should set the source as query param', () => { const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent); expect(userSyncs[0].url).to.contain('source=prebid'); + expect(userSyncs[1].url).to.contain('source=prebid'); }); it('should set the tcString as query param', () => { const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent); expect(userSyncs[0].url).to.contain(`iab_string=${gdprConsent.consentString}`); + expect(userSyncs[1].url).to.contain(`iab_string=${gdprConsent.consentString}`); }); it('should return an empty array when pixel is disable', () => { @@ -142,70 +146,82 @@ describe('OguryBidAdapter', function () { expect(spec.getUserSyncs(syncOptions, [], gdprConsent)).to.have.lengthOf(0); }); - it('should return syncs array with an element of type image when consentString is undefined', () => { + it('should return syncs array with two elements of type image when consentString is undefined', () => { gdprConsent = { gdprApplies: true, consentString: undefined }; const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent); - expect(userSyncs).to.have.lengthOf(1); + expect(userSyncs).to.have.lengthOf(2); expect(userSyncs[0].type).to.equal('image'); expect(userSyncs[0].url).to.equal('https://ms-cookie-sync.presage.io/v1/init-sync/bid-switch?iab_string=&source=prebid') + expect(userSyncs[1].type).to.equal('image'); + expect(userSyncs[1].url).to.equal('https://ms-cookie-sync.presage.io/ttd/init-sync?iab_string=&source=prebid') }); - it('should return syncs array with an element of type image when consentString is null', () => { + it('should return syncs array with two elements of type image when consentString is null', () => { gdprConsent = { gdprApplies: true, consentString: null }; const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent); - expect(userSyncs).to.have.lengthOf(1); + expect(userSyncs).to.have.lengthOf(2); expect(userSyncs[0].type).to.equal('image'); expect(userSyncs[0].url).to.equal('https://ms-cookie-sync.presage.io/v1/init-sync/bid-switch?iab_string=&source=prebid') + expect(userSyncs[1].type).to.equal('image'); + expect(userSyncs[1].url).to.equal('https://ms-cookie-sync.presage.io/ttd/init-sync?iab_string=&source=prebid') }); - it('should return syncs array with an element of type image when gdprConsent is undefined', () => { + it('should return syncs array with two elements of type image when gdprConsent is undefined', () => { gdprConsent = undefined; const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent); - expect(userSyncs).to.have.lengthOf(1); + expect(userSyncs).to.have.lengthOf(2); expect(userSyncs[0].type).to.equal('image'); expect(userSyncs[0].url).to.equal('https://ms-cookie-sync.presage.io/v1/init-sync/bid-switch?iab_string=&source=prebid') + expect(userSyncs[1].type).to.equal('image'); + expect(userSyncs[1].url).to.equal('https://ms-cookie-sync.presage.io/ttd/init-sync?iab_string=&source=prebid') }); - it('should return syncs array with an element of type image when gdprConsent is null', () => { + it('should return syncs array with two elements of type image when gdprConsent is null', () => { gdprConsent = null; const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent); - expect(userSyncs).to.have.lengthOf(1); + expect(userSyncs).to.have.lengthOf(2); expect(userSyncs[0].type).to.equal('image'); expect(userSyncs[0].url).to.equal('https://ms-cookie-sync.presage.io/v1/init-sync/bid-switch?iab_string=&source=prebid') + expect(userSyncs[1].type).to.equal('image'); + expect(userSyncs[1].url).to.equal('https://ms-cookie-sync.presage.io/ttd/init-sync?iab_string=&source=prebid') }); - it('should return syncs array with an element of type image when gdprConsent is null and gdprApplies is false', () => { + it('should return syncs array with two elements of type image when gdprConsent is null and gdprApplies is false', () => { gdprConsent = { gdprApplies: false, consentString: null }; const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent); - expect(userSyncs).to.have.lengthOf(1); + expect(userSyncs).to.have.lengthOf(2); expect(userSyncs[0].type).to.equal('image'); expect(userSyncs[0].url).to.equal('https://ms-cookie-sync.presage.io/v1/init-sync/bid-switch?iab_string=&source=prebid') + expect(userSyncs[1].type).to.equal('image'); + expect(userSyncs[1].url).to.equal('https://ms-cookie-sync.presage.io/ttd/init-sync?iab_string=&source=prebid') }); - it('should return syncs array with an element of type image when gdprConsent is empty string and gdprApplies is false', () => { + it('should return syncs array with two elements of type image when gdprConsent is empty string and gdprApplies is false', () => { gdprConsent = { gdprApplies: false, consentString: '' }; const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent); - expect(userSyncs).to.have.lengthOf(1); + expect(userSyncs).to.have.lengthOf(2); expect(userSyncs[0].type).to.equal('image'); expect(userSyncs[0].url).to.equal('https://ms-cookie-sync.presage.io/v1/init-sync/bid-switch?iab_string=&source=prebid') + expect(userSyncs[1].type).to.equal('image'); + expect(userSyncs[1].url).to.equal('https://ms-cookie-sync.presage.io/ttd/init-sync?iab_string=&source=prebid') }); }); From d08020c56cfa83a54f2660610e942b5ed5524813 Mon Sep 17 00:00:00 2001 From: Desvillettes Aurelien Date: Mon, 11 Oct 2021 15:12:44 +0200 Subject: [PATCH 2/3] Refactor unit tests naming --- test/spec/modules/oguryBidAdapter_spec.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/spec/modules/oguryBidAdapter_spec.js b/test/spec/modules/oguryBidAdapter_spec.js index 25d483a931c..878314cf68e 100644 --- a/test/spec/modules/oguryBidAdapter_spec.js +++ b/test/spec/modules/oguryBidAdapter_spec.js @@ -119,7 +119,7 @@ describe('OguryBidAdapter', function () { }; }); - it('should return syncs array with two elements of type image', () => { + it('should return sync array with two elements of type image', () => { const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent); expect(userSyncs).to.have.lengthOf(2); @@ -146,7 +146,7 @@ describe('OguryBidAdapter', function () { expect(spec.getUserSyncs(syncOptions, [], gdprConsent)).to.have.lengthOf(0); }); - it('should return syncs array with two elements of type image when consentString is undefined', () => { + it('should return sync array with two elements of type image when consentString is undefined', () => { gdprConsent = { gdprApplies: true, consentString: undefined @@ -160,7 +160,7 @@ describe('OguryBidAdapter', function () { expect(userSyncs[1].url).to.equal('https://ms-cookie-sync.presage.io/ttd/init-sync?iab_string=&source=prebid') }); - it('should return syncs array with two elements of type image when consentString is null', () => { + it('should return sync array with two elements of type image when consentString is null', () => { gdprConsent = { gdprApplies: true, consentString: null @@ -174,7 +174,7 @@ describe('OguryBidAdapter', function () { expect(userSyncs[1].url).to.equal('https://ms-cookie-sync.presage.io/ttd/init-sync?iab_string=&source=prebid') }); - it('should return syncs array with two elements of type image when gdprConsent is undefined', () => { + it('should return sync array with two elements of type image when gdprConsent is undefined', () => { gdprConsent = undefined; const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent); @@ -185,7 +185,7 @@ describe('OguryBidAdapter', function () { expect(userSyncs[1].url).to.equal('https://ms-cookie-sync.presage.io/ttd/init-sync?iab_string=&source=prebid') }); - it('should return syncs array with two elements of type image when gdprConsent is null', () => { + it('should return sync array with two elements of type image when gdprConsent is null', () => { gdprConsent = null; const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent); @@ -196,7 +196,7 @@ describe('OguryBidAdapter', function () { expect(userSyncs[1].url).to.equal('https://ms-cookie-sync.presage.io/ttd/init-sync?iab_string=&source=prebid') }); - it('should return syncs array with two elements of type image when gdprConsent is null and gdprApplies is false', () => { + it('should return sync array with two elements of type image when gdprConsent is null and gdprApplies is false', () => { gdprConsent = { gdprApplies: false, consentString: null @@ -210,7 +210,7 @@ describe('OguryBidAdapter', function () { expect(userSyncs[1].url).to.equal('https://ms-cookie-sync.presage.io/ttd/init-sync?iab_string=&source=prebid') }); - it('should return syncs array with two elements of type image when gdprConsent is empty string and gdprApplies is false', () => { + it('should return sync array with two elements of type image when gdprConsent is empty string and gdprApplies is false', () => { gdprConsent = { gdprApplies: false, consentString: '' From adf48da598443a6f57a8df35ad44e00221f5715b Mon Sep 17 00:00:00 2001 From: Desvillettes Aurelien Date: Mon, 11 Oct 2021 15:26:16 +0200 Subject: [PATCH 3/3] refactor unit test name --- test/spec/modules/oguryBidAdapter_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/modules/oguryBidAdapter_spec.js b/test/spec/modules/oguryBidAdapter_spec.js index 878314cf68e..51e586460bd 100644 --- a/test/spec/modules/oguryBidAdapter_spec.js +++ b/test/spec/modules/oguryBidAdapter_spec.js @@ -129,7 +129,7 @@ describe('OguryBidAdapter', function () { expect(userSyncs[1].url).to.contain('https://ms-cookie-sync.presage.io/ttd/init-sync'); }); - it('should set the source as query param', () => { + it('should set the same source as query param', () => { const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent); expect(userSyncs[0].url).to.contain('source=prebid'); expect(userSyncs[1].url).to.contain('source=prebid');