prebid.js 6.4.0 → 6.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/integrationExamples/gpt/amp/creative.html +11 -33
  2. package/integrationExamples/gpt/x-domain/creative.html +53 -26
  3. package/modules/.submodules.json +2 -1
  4. package/modules/adagioBidAdapter.js +0 -8
  5. package/modules/adagioBidAdapter.md +1 -1
  6. package/modules/adbookpspBidAdapter.js +27 -10
  7. package/modules/adhashBidAdapter.js +3 -3
  8. package/modules/adkernelBidAdapter.js +2 -1
  9. package/modules/admanBidAdapter.js +10 -4
  10. package/modules/adomikAnalyticsAdapter.js +23 -11
  11. package/modules/adqueryIdSystem.js +103 -0
  12. package/modules/adqueryIdSystem.md +35 -0
  13. package/modules/adyoulikeBidAdapter.js +13 -9
  14. package/modules/appnexusBidAdapter.js +11 -0
  15. package/modules/bliinkBidAdapter.js +3 -2
  16. package/modules/brandmetricsRtdProvider.js +168 -0
  17. package/modules/brandmetricsRtdProvider.md +40 -0
  18. package/modules/colossussspBidAdapter.js +12 -8
  19. package/modules/colossussspBidAdapter.md +15 -1
  20. package/modules/compassBidAdapter.js +10 -3
  21. package/modules/consentManagement.js +7 -1
  22. package/modules/consumableBidAdapter.md +1 -1
  23. package/modules/criteoBidAdapter.js +10 -1
  24. package/modules/criteoIdSystem.js +29 -7
  25. package/modules/currency.js +26 -1
  26. package/modules/displayioBidAdapter.js +157 -0
  27. package/modules/displayioBidAdapter.md +148 -0
  28. package/modules/docereeBidAdapter.js +10 -1
  29. package/modules/docereeBidAdapter.md +2 -0
  30. package/modules/e_volutionBidAdapter.js +158 -0
  31. package/modules/glimpseBidAdapter.js +66 -44
  32. package/modules/gnetBidAdapter.js +3 -3
  33. package/modules/gnetBidAdapter.md +4 -4
  34. package/modules/gptPreAuction.js +55 -7
  35. package/modules/gumgumBidAdapter.js +56 -42
  36. package/modules/idImportLibrary.js +45 -8
  37. package/modules/idImportLibrary.md +4 -0
  38. package/modules/improvedigitalBidAdapter.js +24 -2
  39. package/modules/interactiveOffersBidAdapter.js +9 -6
  40. package/modules/ixBidAdapter.js +29 -12
  41. package/modules/jwplayerRtdProvider.js +71 -6
  42. package/modules/jwplayerRtdProvider.md +27 -11
  43. package/modules/kargoBidAdapter.js +2 -2
  44. package/modules/limelightDigitalBidAdapter.js +2 -1
  45. package/modules/livewrappedAnalyticsAdapter.js +3 -1
  46. package/modules/loglyliftBidAdapter.js +79 -0
  47. package/modules/loglyliftBidAdapter.md +55 -0
  48. package/modules/nextMillenniumBidAdapter.js +3 -1
  49. package/modules/oguryBidAdapter.js +9 -2
  50. package/modules/onetagBidAdapter.js +4 -2
  51. package/modules/optimeraRtdProvider.js +8 -1
  52. package/modules/ozoneBidAdapter.js +21 -64
  53. package/modules/pilotxBidAdapter.js +147 -0
  54. package/modules/pilotxBidAdapter.md +50 -0
  55. package/modules/proxistoreBidAdapter.js +0 -2
  56. package/modules/pubmaticAnalyticsAdapter.js +16 -0
  57. package/modules/richaudienceBidAdapter.js +3 -2
  58. package/modules/riseBidAdapter.js +1 -1
  59. package/modules/rtbhouseBidAdapter.js +14 -4
  60. package/modules/rtdModule/index.js +14 -15
  61. package/modules/rubiconAnalyticsAdapter.js +3 -2
  62. package/modules/seedingAllianceBidAdapter.js +3 -3
  63. package/modules/sharethroughBidAdapter.js +12 -17
  64. package/modules/showheroes-bsBidAdapter.js +13 -2
  65. package/modules/sovrnBidAdapter.js +93 -18
  66. package/modules/sovrnBidAdapter.md +80 -2
  67. package/modules/synacormediaBidAdapter.js +31 -10
  68. package/modules/tappxBidAdapter.js +8 -5
  69. package/modules/teadsBidAdapter.js +1 -2
  70. package/modules/undertoneBidAdapter.js +17 -1
  71. package/modules/userId/eids.js +7 -1
  72. package/modules/userId/userId.md +8 -0
  73. package/modules/viewability.js +177 -0
  74. package/modules/viewability.md +87 -0
  75. package/modules/welectBidAdapter.js +106 -0
  76. package/modules/yahoosspBidAdapter.js +2 -0
  77. package/modules/yieldmoBidAdapter.js +23 -5
  78. package/modules/zeta_global_sspAnalyticsAdapter.js +97 -0
  79. package/modules/zeta_global_sspAnalyticsAdapter.md +24 -0
  80. package/package.json +1 -1
  81. package/src/adRendering.js +38 -0
  82. package/src/auction.js +44 -9
  83. package/src/config.js +27 -3
  84. package/src/hook.js +5 -1
  85. package/src/prebid.js +21 -21
  86. package/src/secureCreatives.js +114 -44
  87. package/src/utils.js +25 -4
  88. package/test/helpers/syncPromise.js +71 -0
  89. package/test/spec/auctionmanager_spec.js +148 -16
  90. package/test/spec/config_spec.js +279 -0
  91. package/test/spec/modules/adagioBidAdapter_spec.js +0 -10
  92. package/test/spec/modules/adbookpspBidAdapter_spec.js +17 -3
  93. package/test/spec/modules/adhashBidAdapter_spec.js +2 -2
  94. package/test/spec/modules/admanBidAdapter_spec.js +2 -2
  95. package/test/spec/modules/adomikAnalyticsAdapter_spec.js +3 -1
  96. package/test/spec/modules/adqueryIdSystem_spec.js +74 -0
  97. package/test/spec/modules/adyoulikeBidAdapter_spec.js +49 -0
  98. package/test/spec/modules/appnexusBidAdapter_spec.js +27 -0
  99. package/test/spec/modules/bliinkBidAdapter_spec.js +2 -0
  100. package/test/spec/modules/brandmetricsRtdProvider_spec.js +191 -0
  101. package/test/spec/modules/colossussspBidAdapter_spec.js +5 -2
  102. package/test/spec/modules/compassBidAdapter_spec.js +1 -0
  103. package/test/spec/modules/consentManagement_spec.js +20 -0
  104. package/test/spec/modules/criteoBidAdapter_spec.js +21 -0
  105. package/test/spec/modules/criteoIdSystem_spec.js +6 -3
  106. package/test/spec/modules/currency_spec.js +21 -6
  107. package/test/spec/modules/displayioBidAdapter_spec.js +239 -0
  108. package/test/spec/modules/docereeBidAdapter_spec.js +9 -1
  109. package/test/spec/modules/e_volutionBidAdapter_spec.js +242 -0
  110. package/test/spec/modules/eids_spec.js +15 -0
  111. package/test/spec/modules/glimpseBidAdapter_spec.js +0 -18
  112. package/test/spec/modules/gnetBidAdapter_spec.js +6 -6
  113. package/test/spec/modules/gptPreAuction_spec.js +177 -2
  114. package/test/spec/modules/gumgumBidAdapter_spec.js +46 -0
  115. package/test/spec/modules/idImportLibrary_spec.js +197 -10
  116. package/test/spec/modules/improvedigitalBidAdapter_spec.js +42 -0
  117. package/test/spec/modules/ixBidAdapter_spec.js +104 -62
  118. package/test/spec/modules/jwplayerRtdProvider_spec.js +195 -2
  119. package/test/spec/modules/kargoBidAdapter_spec.js +1 -1
  120. package/test/spec/modules/limelightDigitalBidAdapter_spec.js +75 -17
  121. package/test/spec/modules/livewrappedAnalyticsAdapter_spec.js +22 -0
  122. package/test/spec/modules/loglyliftBidAdapter_spec.js +172 -0
  123. package/test/spec/modules/nextMillenniumBidAdapter_spec.js +1 -1
  124. package/test/spec/modules/oguryBidAdapter_spec.js +10 -2
  125. package/test/spec/modules/optimeraRtdProvider_spec.js +14 -1
  126. package/test/spec/modules/ozoneBidAdapter_spec.js +43 -31
  127. package/test/spec/modules/pilotxBidAdapter_spec.js +244 -0
  128. package/test/spec/modules/pubmaticAnalyticsAdapter_spec.js +13 -1
  129. package/test/spec/modules/realTimeDataModule_spec.js +67 -5
  130. package/test/spec/modules/richaudienceBidAdapter_spec.js +40 -0
  131. package/test/spec/modules/riseBidAdapter_spec.js +1 -1
  132. package/test/spec/modules/rtbhouseBidAdapter_spec.js +20 -0
  133. package/test/spec/modules/rubiconAnalyticsAdapter_spec.js +30 -0
  134. package/test/spec/modules/sharethroughBidAdapter_spec.js +91 -6
  135. package/test/spec/modules/showheroes-bsBidAdapter_spec.js +2 -0
  136. package/test/spec/modules/sovrnBidAdapter_spec.js +413 -333
  137. package/test/spec/modules/synacormediaBidAdapter_spec.js +70 -0
  138. package/test/spec/modules/tappxBidAdapter_spec.js +0 -19
  139. package/test/spec/modules/teadsBidAdapter_spec.js +14 -59
  140. package/test/spec/modules/undertoneBidAdapter_spec.js +55 -2
  141. package/test/spec/modules/userId_spec.js +68 -19
  142. package/test/spec/modules/viewability_spec.js +280 -0
  143. package/test/spec/modules/welectBidAdapter_spec.js +211 -0
  144. package/test/spec/modules/yahoosspBidAdapter_spec.js +10 -0
  145. package/test/spec/modules/zeta_global_sspAnalyticsAdapter_spec.js +427 -0
  146. package/test/spec/unit/pbjs_api_spec.js +20 -2
  147. package/test/spec/unit/secureCreatives_spec.js +85 -0
@@ -0,0 +1,191 @@
1
+ import * as brandmetricsRTD from '../../../modules/brandmetricsRtdProvider.js';
2
+ import {config} from 'src/config.js';
3
+
4
+ const VALID_CONFIG = {
5
+ name: 'brandmetrics',
6
+ waitForIt: true,
7
+ params: {
8
+ scriptId: '00000000-0000-0000-0000-000000000000',
9
+ bidders: ['ozone']
10
+ }
11
+ };
12
+
13
+ const NO_BIDDERS_CONFIG = {
14
+ name: 'brandmetrics',
15
+ waitForIt: true,
16
+ params: {
17
+ scriptId: '00000000-0000-0000-0000-000000000000'
18
+ }
19
+ };
20
+
21
+ const NO_SCRIPTID_CONFIG = {
22
+ name: 'brandmetrics',
23
+ waitForIt: true
24
+ };
25
+
26
+ const USER_CONSENT = {
27
+ gdpr: {
28
+ vendorData: {
29
+ vendor: {
30
+ consents: {
31
+ 422: true
32
+ }
33
+ },
34
+ purpose: {
35
+ consents: {
36
+ 1: true,
37
+ 7: true
38
+ }
39
+ }
40
+ },
41
+ gdprApplies: true
42
+ }
43
+ };
44
+
45
+ const NO_TCF_CONSENT = {
46
+ gdpr: {
47
+ vendorData: {
48
+ vendor: {
49
+ consents: {
50
+ 422: false
51
+ }
52
+ },
53
+ purpose: {
54
+ consents: {
55
+ 1: false,
56
+ 7: false
57
+ }
58
+ }
59
+ },
60
+ gdprApplies: true
61
+ }
62
+ };
63
+
64
+ const NO_USP_CONSENT = {
65
+ usp: '1NYY'
66
+ };
67
+
68
+ function mockSurveyLoaded(surveyConf) {
69
+ const commands = window._brandmetrics || [];
70
+ commands.forEach(command => {
71
+ if (command.cmd === '_addeventlistener') {
72
+ const conf = command.val;
73
+ if (conf.event === 'surveyloaded') {
74
+ conf.handler(surveyConf);
75
+ }
76
+ }
77
+ });
78
+ }
79
+
80
+ function scriptTagExists(url) {
81
+ const tags = document.getElementsByTagName('script');
82
+ for (let i = 0; i < tags.length; i++) {
83
+ if (tags[i].src === url) {
84
+ return true;
85
+ }
86
+ }
87
+ return false;
88
+ }
89
+
90
+ describe('BrandmetricsRTD module', () => {
91
+ beforeEach(function () {
92
+ const scriptTags = document.getElementsByTagName('script');
93
+ for (let i = 0; i < scriptTags.length; i++) {
94
+ if (scriptTags[i].src.indexOf('brandmetrics') !== -1) {
95
+ scriptTags[i].remove();
96
+ }
97
+ }
98
+ });
99
+
100
+ it('should init and return true', () => {
101
+ expect(brandmetricsRTD.brandmetricsSubmodule.init(VALID_CONFIG, USER_CONSENT)).to.equal(true);
102
+ });
103
+
104
+ it('should init and return true even if bidders is not included', () => {
105
+ expect(brandmetricsRTD.brandmetricsSubmodule.init(NO_BIDDERS_CONFIG, USER_CONSENT)).to.equal(true);
106
+ });
107
+
108
+ it('should init even if script- id is not configured', () => {
109
+ expect(brandmetricsRTD.brandmetricsSubmodule.init(NO_SCRIPTID_CONFIG, USER_CONSENT)).to.equal(true);
110
+ });
111
+
112
+ it('should not init when there is no TCF- consent', () => {
113
+ expect(brandmetricsRTD.brandmetricsSubmodule.init(VALID_CONFIG, NO_TCF_CONSENT)).to.equal(false);
114
+ });
115
+
116
+ it('should not init when there is no usp- consent', () => {
117
+ expect(brandmetricsRTD.brandmetricsSubmodule.init(VALID_CONFIG, NO_USP_CONSENT)).to.equal(false);
118
+ });
119
+ });
120
+
121
+ describe('getBidRequestData', () => {
122
+ beforeEach(function () {
123
+ config.resetConfig()
124
+ })
125
+
126
+ it('should set targeting keys for specified bidders', () => {
127
+ brandmetricsRTD.brandmetricsSubmodule.getBidRequestData({}, () => {
128
+ const bidderConfig = config.getBidderConfig()
129
+ const expected = VALID_CONFIG.params.bidders
130
+
131
+ expected.forEach(exp => {
132
+ expect(bidderConfig[exp].ortb2.user.ext.data.mockTargetKey).to.equal('mockMeasurementId')
133
+ })
134
+ }, VALID_CONFIG);
135
+
136
+ mockSurveyLoaded({
137
+ available: true,
138
+ conf: {
139
+ displayOption: {
140
+ type: 'pbjs',
141
+ targetKey: 'mockTargetKey'
142
+ }
143
+ },
144
+ survey: {
145
+ measurementId: 'mockMeasurementId'
146
+ }
147
+ });
148
+ });
149
+
150
+ it('should only set targeting keys when the brandmetrics survey- type is "pbjs"', () => {
151
+ mockSurveyLoaded({
152
+ available: true,
153
+ conf: {
154
+ displayOption: {
155
+ type: 'dfp',
156
+ targetKey: 'mockTargetKey'
157
+ }
158
+ },
159
+ survey: {
160
+ measurementId: 'mockMeasurementId'
161
+ }
162
+ });
163
+
164
+ brandmetricsRTD.brandmetricsSubmodule.getBidRequestData({}, () => {}, VALID_CONFIG);
165
+ const bidderConfig = config.getBidderConfig()
166
+ expect(Object.keys(bidderConfig).length).to.equal(0)
167
+ });
168
+
169
+ it('should use a default targeting key name if the brandmetrics- configuration does not include one', () => {
170
+ mockSurveyLoaded({
171
+ available: true,
172
+ conf: {
173
+ displayOption: {
174
+ type: 'pbjs',
175
+ }
176
+ },
177
+ survey: {
178
+ measurementId: 'mockMeasurementId'
179
+ }
180
+ });
181
+
182
+ brandmetricsRTD.brandmetricsSubmodule.getBidRequestData({}, () => {}, VALID_CONFIG);
183
+
184
+ const bidderConfig = config.getBidderConfig()
185
+ const expected = VALID_CONFIG.params.bidders
186
+
187
+ expected.forEach(exp => {
188
+ expect(bidderConfig[exp].ortb2.user.ext.data.brandmetrics_survey).to.equal('mockMeasurementId')
189
+ })
190
+ });
191
+ });
@@ -7,7 +7,8 @@ describe('ColossussspAdapter', function () {
7
7
  bidder: 'colossusssp',
8
8
  bidderRequestId: '145e1d6a7837c9',
9
9
  params: {
10
- placement_id: 0
10
+ placement_id: 0,
11
+ group_id: 0
11
12
  },
12
13
  placementCode: 'placementid_0',
13
14
  auctionId: '74f78609-a92d-4cf1-869f-1b244bbfb5d2',
@@ -60,6 +61,7 @@ describe('ColossussspAdapter', function () {
60
61
  });
61
62
  it('Should return false when placement_id is not a number', function () {
62
63
  bid.params.placement_id = 'aaa';
64
+ delete bid.params.group_id;
63
65
  expect(spec.isBidRequestValid(bid)).to.be.false;
64
66
  });
65
67
  });
@@ -95,9 +97,10 @@ describe('ColossussspAdapter', function () {
95
97
  let placements = data['placements'];
96
98
  for (let i = 0; i < placements.length; i++) {
97
99
  let placement = placements[i];
98
- expect(placement).to.have.all.keys('placementId', 'eids', 'bidId', 'traffic', 'sizes', 'schain', 'floor', 'gpid');
100
+ expect(placement).to.have.all.keys('placementId', 'groupId', 'eids', 'bidId', 'traffic', 'sizes', 'schain', 'floor', 'gpid');
99
101
  expect(placement.schain).to.be.an('object')
100
102
  expect(placement.placementId).to.be.a('number');
103
+ expect(placement.groupId).to.be.a('number');
101
104
  expect(placement.bidId).to.be.a('string');
102
105
  expect(placement.traffic).to.be.a('string');
103
106
  expect(placement.sizes).to.be.an('array');
@@ -143,6 +143,7 @@ describe('CompassBidAdapter', function () {
143
143
  expect(placement.bidId).to.be.a('string');
144
144
  expect(placement.schain).to.be.an('object');
145
145
  expect(placement.bidfloor).to.exist.and.to.equal(0);
146
+ expect(placement.type).to.exist.and.to.equal('publisher');
146
147
 
147
148
  if (placement.adFormat === BANNER) {
148
149
  expect(placement.sizes).to.be.an('array');
@@ -715,6 +715,26 @@ describe('consentManagement', function () {
715
715
  expect(consent).to.be.null;
716
716
  });
717
717
 
718
+ it('allows the auction when CMP is unresponsive', (done) => {
719
+ setConsentConfig({
720
+ cmpApi: 'iab',
721
+ timeout: 10,
722
+ defaultGdprScope: true
723
+ });
724
+
725
+ requestBidsHook(() => {
726
+ didHookReturn = true;
727
+ }, {});
728
+
729
+ setTimeout(() => {
730
+ expect(didHookReturn).to.be.true;
731
+ const consent = gdprDataHandler.getConsentData();
732
+ expect(consent.gdprApplies).to.be.true;
733
+ expect(consent.consentString).to.be.undefined;
734
+ done();
735
+ }, 20);
736
+ });
737
+
718
738
  it('It still considers it a valid cmp response if gdprApplies is not a boolean', function () {
719
739
  // gdprApplies is undefined, should just still store consent response but use whatever defaultGdprScope was
720
740
  let testConsentData = {
@@ -663,6 +663,27 @@ describe('The Criteo bidding adapter', function () {
663
663
  expect(request.data.user.uspIab).to.equal('1YNY');
664
664
  });
665
665
 
666
+ it('should properly build a request with schain object', function () {
667
+ const expectedSchain = {
668
+ someProperty: 'someValue'
669
+ };
670
+ const bidRequests = [
671
+ {
672
+ bidder: 'criteo',
673
+ schain: expectedSchain,
674
+ adUnitCode: 'bid-123',
675
+ transactionId: 'transaction-123',
676
+ sizes: [[728, 90]],
677
+ params: {
678
+ zoneId: 123,
679
+ },
680
+ },
681
+ ];
682
+
683
+ const request = spec.buildRequests(bidRequests, bidderRequest);
684
+ expect(request.data.source.ext.schain).to.equal(expectedSchain);
685
+ });
686
+
666
687
  it('should properly build a request with if ccpa consent field is not provided', function () {
667
688
  const bidRequests = [
668
689
  {
@@ -116,16 +116,19 @@ describe('CriteoId module', function () {
116
116
  expect(setCookieStub.calledWith('cto_bundle')).to.be.false;
117
117
  expect(setLocalStorageStub.calledWith('cto_bundle')).to.be.false;
118
118
  } else if (response.bundle) {
119
- expect(setCookieStub.calledWith('cto_bundle', response.bundle, expirationTs)).to.be.true;
119
+ expect(setCookieStub.calledWith('cto_bundle', response.bundle, expirationTs, null, '.com')).to.be.true;
120
+ expect(setCookieStub.calledWith('cto_bundle', response.bundle, expirationTs, null, '.testdev.com')).to.be.true;
120
121
  expect(setLocalStorageStub.calledWith('cto_bundle', response.bundle)).to.be.true;
121
122
  expect(triggerPixelStub.called).to.be.false;
122
123
  }
123
124
 
124
125
  if (response.bidId) {
125
- expect(setCookieStub.calledWith('cto_bidid', response.bidId, expirationTs)).to.be.true;
126
+ expect(setCookieStub.calledWith('cto_bidid', response.bidId, expirationTs, null, '.com')).to.be.true;
127
+ expect(setCookieStub.calledWith('cto_bidid', response.bidId, expirationTs, null, '.testdev.com')).to.be.true;
126
128
  expect(setLocalStorageStub.calledWith('cto_bidid', response.bidId)).to.be.true;
127
129
  } else {
128
- expect(setCookieStub.calledWith('cto_bidid', '', pastDateString)).to.be.true;
130
+ expect(setCookieStub.calledWith('cto_bidid', '', pastDateString, null, '.com')).to.be.true;
131
+ expect(setCookieStub.calledWith('cto_bidid', '', pastDateString, null, '.testdev.com')).to.be.true;
129
132
  expect(removeFromLocalStorageStub.calledWith('cto_bidid')).to.be.true;
130
133
  }
131
134
  });
@@ -9,7 +9,8 @@ import {
9
9
  setConfig,
10
10
  addBidResponseHook,
11
11
  currencySupportEnabled,
12
- currencyRates
12
+ currencyRates,
13
+ ready
13
14
  } from 'modules/currency.js';
14
15
 
15
16
  var assert = require('chai').assert;
@@ -24,6 +25,7 @@ describe('currency', function () {
24
25
 
25
26
  beforeEach(function () {
26
27
  fakeCurrencyFileServer = sinon.fakeServer.create();
28
+ ready.reset();
27
29
  });
28
30
 
29
31
  afterEach(function () {
@@ -286,7 +288,7 @@ describe('currency', function () {
286
288
  });
287
289
 
288
290
  describe('currency.addBidResponseDecorator bidResponseQueue', function () {
289
- it('not run until currency rates file is loaded', function () {
291
+ it('not run until currency rates file is loaded', function (done) {
290
292
  setConfig({});
291
293
 
292
294
  fakeCurrencyFileServer.respondWith(JSON.stringify(getCurrencyRates()));
@@ -296,14 +298,27 @@ describe('currency', function () {
296
298
  setConfig({ 'adServerCurrency': 'JPY' });
297
299
 
298
300
  var marker = false;
299
- addBidResponseHook(function() {
301
+ let promiseResolved = false;
302
+ addBidResponseHook(Object.assign(function() {
300
303
  marker = true;
301
- }, 'elementId', bid);
304
+ }, {
305
+ bail: function (promise) {
306
+ promise.then(() => promiseResolved = true);
307
+ }
308
+ }), 'elementId', bid);
302
309
 
303
310
  expect(marker).to.equal(false);
304
311
 
305
- fakeCurrencyFileServer.respond();
306
- expect(marker).to.equal(true);
312
+ setTimeout(() => {
313
+ expect(promiseResolved).to.be.false;
314
+ fakeCurrencyFileServer.respond();
315
+
316
+ setTimeout(() => {
317
+ expect(marker).to.equal(true);
318
+ expect(promiseResolved).to.be.true;
319
+ done();
320
+ });
321
+ });
307
322
  });
308
323
  });
309
324
 
@@ -0,0 +1,239 @@
1
+ import { expect } from 'chai'
2
+ import {spec} from 'modules/displayioBidAdapter.js'
3
+
4
+ describe('Displayio adapter', function () {
5
+ const BIDDER = 'displayio'
6
+ const bidRequests = [{
7
+ bidId: 'bidId_001',
8
+ bidder: BIDDER,
9
+ adUnitCode: 'adUnit_001',
10
+ auctionId: 'auctionId_001',
11
+ bidderRequestId: 'bidderRequestId_001',
12
+ mediaTypes: {
13
+ banner: {
14
+ sizes: [[320, 480]]
15
+ },
16
+ video: {
17
+ sizes: [[360, 640]]
18
+ },
19
+ },
20
+ params: {
21
+ siteId: 1,
22
+ placementId: 1,
23
+ adsSrvDomain: 'adsSrvDomain',
24
+ cdnDomain: 'cdnDomain',
25
+ }
26
+ }]
27
+ const bidderRequest = {
28
+ refererInfo: {
29
+ referer: 'testprebid.com'
30
+ }
31
+ }
32
+
33
+ describe('isBidRequestValid', function () {
34
+ it('should return true when required params found', function() {
35
+ const validBid = spec.isBidRequestValid(bidRequests[0])
36
+ expect(validBid).to.be.true
37
+ })
38
+
39
+ const bidRequestsNoParams = [{
40
+ bidder: BIDDER,
41
+ }]
42
+ it('should not validate without params', function () {
43
+ const request = spec.isBidRequestValid(bidRequestsNoParams, bidderRequest)
44
+ expect(request).to.be.false
45
+ })
46
+
47
+ const noSiteId = {
48
+ bidder: BIDDER,
49
+ params: {
50
+ placementId: 1,
51
+ adsSrvDomain: 'adsSrvDomain',
52
+ cdnDomain: 'cdnDomain',
53
+ }
54
+ }
55
+ it('should not validate without siteId', function() {
56
+ const invalidBid = spec.isBidRequestValid(noSiteId)
57
+ expect(invalidBid).to.be.false
58
+ })
59
+
60
+ const noPlacementId = {
61
+ bidder: BIDDER,
62
+ params: {
63
+ siteId: 1,
64
+ adsSrvDomain: 'adsSrvDomain',
65
+ cdnDomain: 'cdnDomain',
66
+ }
67
+ }
68
+ it('should not validate without placementId', function() {
69
+ const invalidBid = spec.isBidRequestValid(noPlacementId)
70
+ expect(invalidBid).to.be.false
71
+ })
72
+
73
+ const noAdsSrvDomain = {
74
+ bidder: BIDDER,
75
+ params: {
76
+ siteId: 1,
77
+ placementId: 1,
78
+ cdnDomain: 'cdnDomain',
79
+ }
80
+ }
81
+ it('should not validate without adsSrvDomain', function() {
82
+ const invalidBid = spec.isBidRequestValid(noAdsSrvDomain)
83
+ expect(invalidBid).to.be.false
84
+ })
85
+
86
+ const noCdnDomain = {
87
+ bidder: BIDDER,
88
+ params: {
89
+ siteId: 1,
90
+ placementId: 1,
91
+ adsSrvDomain: 'adsSrvDomain',
92
+ }
93
+ }
94
+ it('should not validate without cdnDomain', function() {
95
+ const invalidBid = spec.isBidRequestValid(noCdnDomain)
96
+ expect(invalidBid).to.be.false
97
+ })
98
+ })
99
+
100
+ describe('buildRequests', function () {
101
+ it('should build request', function() {
102
+ const request = spec.buildRequests(bidRequests, bidderRequest)
103
+ expect(request).to.not.be.empty
104
+ })
105
+
106
+ it('sends bid request to the endpoint via POST', function () {
107
+ const request = spec.buildRequests(bidRequests, bidderRequest)
108
+ expect(request[0].method).to.equal('POST')
109
+ })
110
+
111
+ it('sends all bid parameters', function () {
112
+ const request = spec.buildRequests(bidRequests, bidderRequest)
113
+ expect(request[0]).to.have.keys(['headers', 'data', 'method', 'url'])
114
+ })
115
+
116
+ it('should not crash when there is no media types', function () {
117
+ const bidRequestsNoMediaTypes = [{
118
+ bidder: BIDDER,
119
+ params: {
120
+ siteId: 1,
121
+ placementId: 1,
122
+ adsSrvDomain: 'adsSrvDomain',
123
+ cdnDomain: 'cdnDomain',
124
+ }
125
+ }]
126
+ const request = spec.buildRequests(bidRequestsNoMediaTypes, bidderRequest)
127
+ expect(request[0]).to.have.keys(['headers', 'data', 'method', 'url'])
128
+ })
129
+ })
130
+
131
+ describe('_getPayload', function () {
132
+ const payload = spec._getPayload(bidRequests[0], bidderRequest)
133
+ it('should not be empty', function() {
134
+ expect(payload).to.not.be.empty
135
+ })
136
+
137
+ it('should have userSession', function() {
138
+ expect(payload.userSession).to.be.a('string')
139
+ })
140
+
141
+ it('should have data object', function() {
142
+ expect(payload.data).to.be.a('object')
143
+ })
144
+
145
+ it('should have complianceData object', function() {
146
+ expect(payload.data.complianceData).to.be.a('object')
147
+ })
148
+
149
+ it('should have device object', function() {
150
+ expect(payload.data.device).to.be.a('object')
151
+ })
152
+
153
+ it('should have omidpn', function() {
154
+ expect(payload.data.omidpn).to.be.a('string')
155
+ })
156
+
157
+ it('should have integration', function() {
158
+ expect(payload.data.integration).to.be.a('string')
159
+ })
160
+
161
+ it('should have bidId', function() {
162
+ expect(payload.data.id).to.not.be.empty
163
+ })
164
+
165
+ it('should have action getPlacement', function() {
166
+ expect(payload.data.action).to.be.equal('getPlacement')
167
+ })
168
+
169
+ it('should have app parameter', function() {
170
+ expect(payload.data.app).to.be.a('number')
171
+ })
172
+
173
+ it('should have placement parameter', function() {
174
+ expect(payload.data.placement).to.be.a('number')
175
+ })
176
+ })
177
+
178
+ describe('interpretResponse', function () {
179
+ const response = {
180
+ body: {
181
+ status: 'ok',
182
+ data: {
183
+ ads: [{
184
+ ad: {
185
+ data: {
186
+ id: '001',
187
+ ecpm: 100,
188
+ w: 32,
189
+ h: 480,
190
+ markup: 'test ad'
191
+ }
192
+ },
193
+ subtype: 'html'
194
+ }],
195
+ }
196
+ }
197
+ }
198
+ const serverRequest = {
199
+ data: {
200
+ data: {
201
+ id: 'id_001',
202
+ data: {
203
+ ref: 'testprebid.com'
204
+ }
205
+ }
206
+ }
207
+ }
208
+
209
+ let ir = spec.interpretResponse(response, serverRequest)
210
+
211
+ expect(ir.length).to.equal(1)
212
+
213
+ ir = ir[0]
214
+
215
+ it('should have requestId', function() {
216
+ expect(ir.requestId).to.be.a('string')
217
+ })
218
+
219
+ it('should have cpm', function() {
220
+ expect(ir.cpm).to.be.a('number')
221
+ })
222
+
223
+ it('should have width', function() {
224
+ expect(ir.width).to.be.a('number')
225
+ })
226
+
227
+ it('should have height', function() {
228
+ expect(ir.height).to.be.a('number')
229
+ })
230
+
231
+ it('should have creativeId', function() {
232
+ expect(ir.creativeId).to.be.a('number')
233
+ })
234
+
235
+ it('should have ad', function() {
236
+ expect(ir.ad).to.be.a('string')
237
+ })
238
+ })
239
+ })
@@ -31,6 +31,8 @@ describe('BidlabBidAdapter', function () {
31
31
  bidder: 'doceree',
32
32
  params: {
33
33
  placementId: 'DOC_7jm9j5eqkl0xvc5w',
34
+ gdpr: '1',
35
+ gdprConsent: 'CPQfU1jPQfU1jG0AAAENAwCAAAAAAAAAAAAAAAAAAAAA.IGLtV_T9fb2vj-_Z99_tkeYwf95y3p-wzhheMs-8NyZeH_B4Wv2MyvBX4JiQKGRgksjLBAQdtHGlcTQgBwIlViTLMYk2MjzNKJrJEilsbO2dYGD9Pn8HT3ZCY70-vv__7v3ff_3g'
34
36
  }
35
37
  };
36
38
 
@@ -44,6 +46,12 @@ describe('BidlabBidAdapter', function () {
44
46
  });
45
47
  });
46
48
 
49
+ describe('isGdprConsentPresent', function () {
50
+ it('Should return true if gdpr consent is present', function () {
51
+ expect(spec.isGdprConsentPresent(bid)).to.be.true;
52
+ });
53
+ });
54
+
47
55
  describe('buildRequests', function () {
48
56
  let serverRequest = spec.buildRequests([bid]);
49
57
  serverRequest = serverRequest[0]
@@ -56,7 +64,7 @@ describe('BidlabBidAdapter', function () {
56
64
  expect(serverRequest.method).to.equal('GET');
57
65
  });
58
66
  it('Returns valid URL', function () {
59
- expect(serverRequest.url).to.equal('https://bidder.doceree.com/v1/adrequest?id=DOC_7jm9j5eqkl0xvc5w&pubRequestedURL=undefined&loggedInUser=JTdCJTIyZ2VuZGVyJTIyJTNBJTIyJTIyJTJDJTIyZW1haWwlMjIlM0ElMjIlMjIlMkMlMjJoYXNoZWRFbWFpbCUyMiUzQSUyMiUyMiUyQyUyMmZpcnN0TmFtZSUyMiUzQSUyMiUyMiUyQyUyMmxhc3ROYW1lJTIyJTNBJTIyJTIyJTJDJTIybnBpJTIyJTNBJTIyJTIyJTJDJTIyaGFzaGVkTlBJJTIyJTNBJTIyJTIyJTJDJTIyY2l0eSUyMiUzQSUyMiUyMiUyQyUyMnppcENvZGUlMjIlM0ElMjIlMjIlMkMlMjJzcGVjaWFsaXphdGlvbiUyMiUzQSUyMiUyMiU3RA%3D%3D&prebidjs=true&requestId=testing&');
67
+ expect(serverRequest.url).to.equal('https://bidder.doceree.com/v1/adrequest?id=DOC_7jm9j5eqkl0xvc5w&pubRequestedURL=undefined&loggedInUser=JTdCJTIyZ2VuZGVyJTIyJTNBJTIyJTIyJTJDJTIyZW1haWwlMjIlM0ElMjIlMjIlMkMlMjJoYXNoZWRFbWFpbCUyMiUzQSUyMiUyMiUyQyUyMmZpcnN0TmFtZSUyMiUzQSUyMiUyMiUyQyUyMmxhc3ROYW1lJTIyJTNBJTIyJTIyJTJDJTIybnBpJTIyJTNBJTIyJTIyJTJDJTIyaGFzaGVkTlBJJTIyJTNBJTIyJTIyJTJDJTIyY2l0eSUyMiUzQSUyMiUyMiUyQyUyMnppcENvZGUlMjIlM0ElMjIlMjIlMkMlMjJzcGVjaWFsaXphdGlvbiUyMiUzQSUyMiUyMiU3RA%3D%3D&prebidjs=true&requestId=testing&gdpr=1&gdpr_consent=CPQfU1jPQfU1jG0AAAENAwCAAAAAAAAAAAAAAAAAAAAA.IGLtV_T9fb2vj-_Z99_tkeYwf95y3p-wzhheMs-8NyZeH_B4Wv2MyvBX4JiQKGRgksjLBAQdtHGlcTQgBwIlViTLMYk2MjzNKJrJEilsbO2dYGD9Pn8HT3ZCY70-vv__7v3ff_3g&');
60
68
  });
61
69
  });
62
70
  describe('interpretResponse', function () {