prebid.js 6.24.0 → 6.26.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 (178) hide show
  1. package/dist/33acrossBidAdapter.js +1 -1
  2. package/dist/adagioBidAdapter.js +1 -1
  3. package/dist/adbookpspBidAdapter.js +1 -1
  4. package/dist/adgenerationBidAdapter.js +1 -1
  5. package/dist/adrelevantisBidAdapter.js +1 -1
  6. package/dist/adtelligentBidAdapter.js +1 -1
  7. package/dist/adxcgBidAdapter.js +1 -1
  8. package/dist/adyoulikeBidAdapter.js +1 -1
  9. package/dist/ajaBidAdapter.js +1 -1
  10. package/dist/amxBidAdapter.js +1 -1
  11. package/dist/amxIdSystem.js +1 -1
  12. package/dist/appierAnalyticsAdapter.js +1 -1
  13. package/dist/appnexusBidAdapter.js +1 -1
  14. package/dist/asoBidAdapter.js +1 -1
  15. package/dist/audiencerunBidAdapter.js +1 -1
  16. package/dist/axonixBidAdapter.js +1 -1
  17. package/dist/beopBidAdapter.js +1 -1
  18. package/dist/bidglassBidAdapter.js +1 -1
  19. package/dist/big-richmediaBidAdapter.js +1 -1
  20. package/dist/bluebillywigBidAdapter.js +1 -1
  21. package/dist/bridgewellBidAdapter.js +1 -1
  22. package/dist/brightMountainMediaBidAdapter.js +1 -1
  23. package/dist/concertBidAdapter.js +1 -1
  24. package/dist/connectadBidAdapter.js +1 -1
  25. package/dist/consumableBidAdapter.js +1 -1
  26. package/dist/conversantBidAdapter.js +1 -1
  27. package/dist/cpexIdSystem.js +1 -1
  28. package/dist/craftBidAdapter.js +1 -1
  29. package/dist/criteoBidAdapter.js +1 -1
  30. package/dist/currency.js +1 -1
  31. package/dist/dfpAdServerVideo.js +1 -1
  32. package/dist/dspxBidAdapter.js +1 -1
  33. package/dist/eplanningBidAdapter.js +1 -1
  34. package/dist/glimpseBidAdapter.js +1 -1
  35. package/dist/gmosspBidAdapter.js +1 -1
  36. package/dist/goldbachBidAdapter.js +1 -1
  37. package/dist/gravitoIdSystem.js +1 -0
  38. package/dist/gridBidAdapter.js +1 -1
  39. package/dist/gridNMBidAdapter.js +1 -1
  40. package/dist/gumgumBidAdapter.js +1 -1
  41. package/dist/h12mediaBidAdapter.js +1 -1
  42. package/dist/id5IdSystem.js +1 -1
  43. package/dist/impactifyBidAdapter.js +1 -1
  44. package/dist/improvedigitalBidAdapter.js +1 -1
  45. package/dist/inmarBidAdapter.js +1 -1
  46. package/dist/insticatorBidAdapter.js +1 -1
  47. package/dist/invibesBidAdapter.js +1 -1
  48. package/dist/ixBidAdapter.js +1 -1
  49. package/dist/jixieBidAdapter.js +1 -1
  50. package/dist/justpremiumBidAdapter.js +1 -1
  51. package/dist/kargoBidAdapter.js +1 -1
  52. package/dist/konduitAnalyticsAdapter.js +1 -1
  53. package/dist/liveIntentIdSystem.js +1 -1
  54. package/dist/liveyieldAnalyticsAdapter.js +1 -1
  55. package/dist/logicadBidAdapter.js +1 -1
  56. package/dist/loglyliftBidAdapter.js +1 -1
  57. package/dist/malltvAnalyticsAdapter.js +1 -1
  58. package/dist/marsmediaBidAdapter.js +1 -1
  59. package/dist/mediafuseBidAdapter.js +1 -1
  60. package/dist/mediakeysBidAdapter.js +1 -1
  61. package/dist/mediasquareBidAdapter.js +1 -1
  62. package/dist/mgidBidAdapter.js +1 -1
  63. package/dist/minutemediaBidAdapter.js +1 -1
  64. package/dist/not-for-prod/prebid.js +123 -121
  65. package/dist/oguryBidAdapter.js +1 -1
  66. package/dist/oneVideoBidAdapter.js +1 -1
  67. package/dist/onetagBidAdapter.js +1 -1
  68. package/dist/ooloAnalyticsAdapter.js +1 -1
  69. package/dist/outbrainBidAdapter.js +1 -1
  70. package/dist/parrableIdSystem.js +1 -1
  71. package/dist/pixfutureBidAdapter.js +1 -1
  72. package/dist/prebid-core.js +3 -3
  73. package/dist/publinkIdSystem.js +1 -1
  74. package/dist/pubmaticBidAdapter.js +1 -1
  75. package/dist/pubwiseAnalyticsAdapter.js +1 -1
  76. package/dist/pxyzBidAdapter.js +1 -1
  77. package/dist/quantcastBidAdapter.js +1 -1
  78. package/dist/readpeakBidAdapter.js +1 -1
  79. package/dist/relaidoBidAdapter.js +1 -1
  80. package/dist/rhythmoneBidAdapter.js +1 -1
  81. package/dist/riseBidAdapter.js +1 -1
  82. package/dist/rubiconAnalyticsAdapter.js +1 -1
  83. package/dist/rubiconBidAdapter.js +1 -1
  84. package/dist/seedingAllianceBidAdapter.js +1 -1
  85. package/dist/seedtagBidAdapter.js +1 -1
  86. package/dist/sharethroughAnalyticsAdapter.js +1 -1
  87. package/dist/sharethroughBidAdapter.js +1 -1
  88. package/dist/smaatoBidAdapter.js +1 -1
  89. package/dist/smartadserverBidAdapter.js +1 -1
  90. package/dist/smartxBidAdapter.js +1 -1
  91. package/dist/smilewantedBidAdapter.js +1 -1
  92. package/dist/sonobiBidAdapter.js +1 -1
  93. package/dist/sortableBidAdapter.js +1 -1
  94. package/dist/sovrnAnalyticsAdapter.js +1 -1
  95. package/dist/sovrnBidAdapter.js +1 -1
  96. package/dist/sspBCBidAdapter.js +1 -1
  97. package/dist/sublimeBidAdapter.js +1 -1
  98. package/dist/synacormediaBidAdapter.js +1 -1
  99. package/dist/targetVideoBidAdapter.js +1 -1
  100. package/dist/teadsBidAdapter.js +1 -1
  101. package/dist/trionBidAdapter.js +1 -1
  102. package/dist/tripleliftBidAdapter.js +1 -1
  103. package/dist/trustpidSystem.js +1 -1
  104. package/dist/trustxBidAdapter.js +1 -1
  105. package/dist/ttdBidAdapter.js +1 -1
  106. package/dist/ucfunnelAnalyticsAdapter.js +1 -1
  107. package/dist/underdogmediaBidAdapter.js +1 -1
  108. package/dist/undertoneBidAdapter.js +1 -1
  109. package/dist/userId.js +1 -1
  110. package/dist/vidazooBidAdapter.js +1 -1
  111. package/dist/videobyteBidAdapter.js +1 -1
  112. package/dist/videoheroesBidAdapter.js +1 -0
  113. package/dist/vidoomyBidAdapter.js +1 -1
  114. package/dist/visxBidAdapter.js +1 -1
  115. package/dist/vuukleBidAdapter.js +1 -1
  116. package/dist/weboramaRtdProvider.js +1 -1
  117. package/dist/widespaceBidAdapter.js +1 -1
  118. package/dist/winrBidAdapter.js +1 -1
  119. package/dist/yahoosspBidAdapter.js +1 -1
  120. package/dist/yieldmoBidAdapter.js +1 -1
  121. package/dist/yieldoneAnalyticsAdapter.js +1 -1
  122. package/dist/zeta_global_sspBidAdapter.js +1 -1
  123. package/integrationExamples/gpt/userId_example.html +3 -0
  124. package/integrationExamples/gpt/weboramaRtdProvider_example.html +65 -11
  125. package/modules/.submodules.json +2 -1
  126. package/modules/adagioBidAdapter.js +2 -0
  127. package/modules/adtelligentBidAdapter.js +3 -1
  128. package/modules/alkimiBidAdapter.md +10 -4
  129. package/modules/appnexusBidAdapter.js +13 -2
  130. package/modules/beopBidAdapter.js +51 -6
  131. package/modules/cpexIdSystem.js +1 -2
  132. package/modules/currency.js +4 -13
  133. package/modules/dacIdSystem.md +4 -4
  134. package/modules/dfpAdServerVideo.js +8 -0
  135. package/modules/gravitoIdSystem.js +57 -0
  136. package/modules/gravitoIdSystem.md +28 -0
  137. package/modules/improvedigitalBidAdapter.js +100 -43
  138. package/modules/invibesBidAdapter.js +55 -34
  139. package/modules/ixBidAdapter.js +62 -26
  140. package/modules/ixBidAdapter.md +42 -42
  141. package/modules/jixieBidAdapter.js +2 -0
  142. package/modules/kargoBidAdapter.js +23 -8
  143. package/modules/oguryBidAdapter.js +27 -1
  144. package/modules/trustpidSystem.js +9 -28
  145. package/modules/trustpidSystem.md +11 -34
  146. package/modules/userId/eids.js +6 -0
  147. package/modules/userId/index.js +30 -55
  148. package/modules/userId/userId.md +3 -11
  149. package/modules/videoheroesBidAdapter.js +267 -0
  150. package/modules/videoheroesBidAdapter.md +134 -0
  151. package/modules/vidoomyBidAdapter.js +2 -6
  152. package/modules/weboramaRtdProvider.js +515 -241
  153. package/modules/weboramaRtdProvider.md +488 -51
  154. package/modules/zeta_global_sspBidAdapter.js +1 -1
  155. package/package.json +4 -4
  156. package/src/adserver.js +7 -0
  157. package/src/hook.js +19 -1
  158. package/src/utils/promise.js +36 -0
  159. package/test/spec/modules/adtelligentBidAdapter_spec.js +1 -0
  160. package/test/spec/modules/appnexusBidAdapter_spec.js +37 -10
  161. package/test/spec/modules/beopBidAdapter_spec.js +15 -2
  162. package/test/spec/modules/dfpAdServerVideo_spec.js +45 -0
  163. package/test/spec/modules/gravitoIdSystem_spec.js +51 -0
  164. package/test/spec/modules/improvedigitalBidAdapter_spec.js +289 -72
  165. package/test/spec/modules/invibesBidAdapter_spec.js +98 -7
  166. package/test/spec/modules/ixBidAdapter_spec.js +132 -26
  167. package/test/spec/modules/jixieBidAdapter_spec.js +17 -0
  168. package/test/spec/modules/kargoBidAdapter_spec.js +45 -3
  169. package/test/spec/modules/liveIntentIdSystem_spec.js +2 -2
  170. package/test/spec/modules/loglyliftBidAdapter_spec.js +8 -0
  171. package/test/spec/modules/oguryBidAdapter_spec.js +181 -3
  172. package/test/spec/modules/trustpidSystem_spec.js +42 -19
  173. package/test/spec/modules/userId_spec.js +18 -0
  174. package/test/spec/modules/videoheroesBidAdapter_spec.js +363 -0
  175. package/test/spec/modules/weboramaRtdProvider_spec.js +2333 -266
  176. package/test/spec/modules/zeta_global_sspBidAdapter_spec.js +37 -24
  177. package/test/spec/unit/utils/promise_spec.js +49 -0
  178. package/test/spec/modules/medianetRtdProvider_spec.js +0 -146
@@ -6,23 +6,19 @@ import {
6
6
  } from 'test/mocks/xhr.js';
7
7
  import {
8
8
  storage,
9
- DEFAULT_LOCAL_STORAGE_USER_PROFILE_KEY
9
+ DEFAULT_LOCAL_STORAGE_USER_PROFILE_KEY,
10
+ DEFAULT_LOCAL_STORAGE_LITE_PROFILE_KEY
10
11
  } from '../../../modules/weboramaRtdProvider.js';
11
- import {
12
- config
13
- } from 'src/config.js';
14
- import {
15
- getGlobal
16
- } from 'src/prebidGlobal.js';
12
+
17
13
  import 'src/prebid.js';
18
14
 
19
15
  const responseHeader = {
20
16
  'Content-Type': 'application/json'
21
17
  };
22
18
 
23
- describe('weboramaRtdProvider', function () {
24
- describe('weboramaSubmodule', function () {
25
- it('successfully instantiates and call contextual api', function () {
19
+ describe('weboramaRtdProvider', function() {
20
+ describe('weboramaSubmodule', function() {
21
+ it('successfully instantiates and call contextual api', function() {
26
22
  const moduleConfig = {
27
23
  params: {
28
24
  weboCtxConf: {
@@ -35,7 +31,7 @@ describe('weboramaRtdProvider', function () {
35
31
  expect(weboramaSubmodule.init(moduleConfig)).to.equal(true);
36
32
  });
37
33
 
38
- it('instantiate without contextual token should fail', function () {
34
+ it('instantiate without contextual token should fail', function() {
39
35
  const moduleConfig = {
40
36
  params: {
41
37
  weboCtxConf: {}
@@ -44,7 +40,7 @@ describe('weboramaRtdProvider', function () {
44
40
  expect(weboramaSubmodule.init(moduleConfig)).to.equal(false);
45
41
  });
46
42
 
47
- it('instantiate with empty weboUserData conf should return true', function () {
43
+ it('instantiate with empty weboUserData conf should return true', function() {
48
44
  const moduleConfig = {
49
45
  params: {
50
46
  weboUserDataConf: {}
@@ -54,35 +50,33 @@ describe('weboramaRtdProvider', function () {
54
50
  });
55
51
  });
56
52
 
57
- describe('Handle Set Targeting', function () {
53
+ describe('Handle Set Targeting and Bid Request', function() {
58
54
  let sandbox;
59
55
 
60
- beforeEach(function () {
56
+ beforeEach(function() {
61
57
  sandbox = sinon.sandbox.create();
62
58
 
63
- storage.removeDataFromLocalStorage('webo_wam2gam_entry');
59
+ storage.removeDataFromLocalStorage(DEFAULT_LOCAL_STORAGE_USER_PROFILE_KEY);
64
60
 
65
- getGlobal().setConfig({
66
- ortb2: undefined
67
- });
61
+ storage.removeDataFromLocalStorage(DEFAULT_LOCAL_STORAGE_LITE_PROFILE_KEY);
68
62
  });
69
63
 
70
- afterEach(function () {
64
+ afterEach(function() {
71
65
  sandbox.restore();
72
66
  });
73
67
 
74
- describe('Add Contextual Data', function () {
75
- it('should set gam targeting and send to bidders by default', function () {
68
+ describe('Add site-centric data (contextual)', function() {
69
+ it('should set gam targeting and send to bidders by default', function() {
76
70
  let onDataResponse = {};
77
71
  const moduleConfig = {
78
72
  params: {
79
73
  weboCtxConf: {
80
74
  token: 'foo',
81
75
  targetURL: 'https://prebid.org',
82
- onData: (data, site) => {
76
+ onData: (data, meta) => {
83
77
  onDataResponse = {
84
78
  data: data,
85
- site: site,
79
+ meta: meta,
86
80
  };
87
81
  },
88
82
  }
@@ -92,9 +86,10 @@ describe('weboramaRtdProvider', function () {
92
86
  webo_ctx: ['foo', 'bar'],
93
87
  webo_ds: ['baz'],
94
88
  };
95
- const adUnitsCodes = ['adunit1', 'adunit2'];
89
+ const adUnitCode = 'adunit1';
96
90
  const reqBidsConfigObj = {
97
91
  adUnits: [{
92
+ code: adUnitCode,
98
93
  bids: [{
99
94
  bidder: 'smartadserver'
100
95
  }, {
@@ -124,11 +119,10 @@ describe('weboramaRtdProvider', function () {
124
119
 
125
120
  expect(onDoneSpy.calledOnce).to.be.true;
126
121
 
127
- const targeting = weboramaSubmodule.getTargetingData(adUnitsCodes, moduleConfig);
122
+ const targeting = weboramaSubmodule.getTargetingData([adUnitCode], moduleConfig);
128
123
 
129
124
  expect(targeting).to.deep.equal({
130
125
  'adunit1': data,
131
- 'adunit2': data,
132
126
  });
133
127
 
134
128
  expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5);
@@ -145,119 +139,532 @@ describe('weboramaRtdProvider', function () {
145
139
  },
146
140
  }
147
141
  });
148
- expect(getGlobal().getConfig('ortb2')).to.deep.equal({
149
- site: {
150
- ext: {
151
- data: data
152
- },
153
- }
154
- });
155
142
  expect(onDataResponse).to.deep.equal({
156
143
  data: data,
157
- site: true,
144
+ meta: {
145
+ user: false,
146
+ source: 'contextual',
147
+ isDefault: false,
148
+ },
158
149
  });
159
150
  });
160
151
 
161
- it('should set gam targeting but not send to bidders with setPrebidTargeting=true/sendToBidders=false', function () {
162
- const moduleConfig = {
163
- params: {
164
- weboCtxConf: {
165
- token: 'foo',
166
- targetURL: 'https://prebid.org',
167
- setPrebidTargeting: true,
168
- sendToBidders: false,
169
- }
170
- }
171
- };
172
- const data = {
173
- webo_ctx: ['foo', 'bar'],
174
- webo_ds: ['baz'],
152
+ describe('should set gam targeting and send to one specific bidder and multiple adunits', function() {
153
+ const testcases = {
154
+ 'single string': 'appnexus',
155
+ 'array with one entry': ['appnexus'],
156
+ 'map with one entry': {
157
+ 'appnexus': true
158
+ },
159
+ 'map complete': {
160
+ 'smartadserver': false,
161
+ 'pubmatic': false,
162
+ 'appnexus': true,
163
+ 'rubicon': false,
164
+ 'other': false,
165
+ },
166
+ 'callback': (bid) => {
167
+ return bid.bidder == 'appnexus'
168
+ },
175
169
  };
176
- const adUnitsCodes = ['adunit1', 'adunit2'];
177
- const reqBidsConfigObj = {
178
- adUnits: [{
179
- bids: [{
180
- bidder: 'smartadserver',
170
+
171
+ Object.keys(testcases).forEach(label => {
172
+ const sendToBidders = testcases[label];
173
+ it(`check sendToBidders as ${label}`, function() {
174
+ let onDataResponse = {};
175
+ const moduleConfig = {
181
176
  params: {
182
- target: 'foo=bar'
177
+ weboCtxConf: {
178
+ token: 'foo',
179
+ targetURL: 'https://prebid.org',
180
+ sendToBidders: sendToBidders,
181
+ onData: (data, meta) => {
182
+ onDataResponse = {
183
+ data: data,
184
+ meta: meta,
185
+ };
186
+ },
187
+ }
183
188
  }
184
- }, {
185
- bidder: 'pubmatic',
189
+ };
190
+ const data = {
191
+ webo_ctx: ['foo', 'bar'],
192
+ webo_ds: ['baz'],
193
+ };
194
+ const adUnitCode1 = 'adunit1';
195
+ const adUnitCode2 = 'adunit2';
196
+
197
+ const reqBidsConfigObj = {
198
+ adUnits: [{
199
+ code: adUnitCode1,
200
+ bids: [{
201
+ bidder: 'smartadserver'
202
+ }, {
203
+ bidder: 'pubmatic'
204
+ }, {
205
+ bidder: 'appnexus'
206
+ }, {
207
+ bidder: 'rubicon'
208
+ }, {
209
+ bidder: 'other'
210
+ }]
211
+ }, {
212
+ code: adUnitCode2,
213
+ bids: [{
214
+ bidder: 'smartadserver'
215
+ }, {
216
+ bidder: 'pubmatic'
217
+ }, {
218
+ bidder: 'appnexus'
219
+ }, {
220
+ bidder: 'rubicon'
221
+ }, {
222
+ bidder: 'other'
223
+ }]
224
+ }]
225
+ };
226
+
227
+ const onDoneSpy = sinon.spy();
228
+
229
+ expect(weboramaSubmodule.init(moduleConfig)).to.be.true;
230
+ weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig);
231
+
232
+ let request = server.requests[0];
233
+
234
+ expect(request.method).to.equal('GET');
235
+ expect(request.url).to.equal('https://ctx.weborama.com/api/profile?token=foo&url=https%3A%2F%2Fprebid.org&');
236
+ expect(request.withCredentials).to.be.false;
237
+
238
+ request.respond(200, responseHeader, JSON.stringify(data));
239
+
240
+ expect(onDoneSpy.calledOnce).to.be.true;
241
+
242
+ const targeting = weboramaSubmodule.getTargetingData([adUnitCode1, adUnitCode2], moduleConfig);
243
+
244
+ expect(targeting).to.deep.equal({
245
+ 'adunit1': data,
246
+ 'adunit2': data,
247
+ });
248
+
249
+ reqBidsConfigObj.adUnits.forEach(adUnit => {
250
+ expect(adUnit.bids.length).to.equal(5);
251
+ expect(adUnit.bids[0].params).to.be.undefined;
252
+ expect(adUnit.bids[1].params).to.be.undefined;
253
+ expect(adUnit.bids[2].params.keywords).to.deep.equal(data);
254
+ expect(adUnit.bids[3].params).to.be.undefined;
255
+ expect(adUnit.bids[4].ortb2).to.be.undefined;
256
+ });
257
+
258
+ expect(onDataResponse).to.deep.equal({
259
+ data: data,
260
+ meta: {
261
+ user: false,
262
+ source: 'contextual',
263
+ isDefault: false,
264
+ },
265
+ });
266
+ });
267
+ });
268
+ });
269
+
270
+ describe('should set gam targeting and send to one specific bidder and one adunit', function() {
271
+ const testcases = {
272
+ 'map with one entry': {
273
+ 'appnexus': ['adunit1']
274
+ },
275
+ 'callback': (bid, adUnitCode) => {
276
+ return bid.bidder == 'appnexus' && adUnitCode == 'adunit1';
277
+ },
278
+ };
279
+
280
+ Object.keys(testcases).forEach(label => {
281
+ const sendToBidders = testcases[label];
282
+ it(`check sendToBidders as ${label}`, function() {
283
+ let onDataResponse = {};
284
+ const moduleConfig = {
186
285
  params: {
187
- dctr: 'foo=bar'
286
+ weboCtxConf: {
287
+ token: 'foo',
288
+ targetURL: 'https://prebid.org',
289
+ sendToBidders: sendToBidders,
290
+ onData: (data, meta) => {
291
+ onDataResponse = {
292
+ data: data,
293
+ meta: meta,
294
+ };
295
+ },
296
+ }
188
297
  }
189
- }, {
190
- bidder: 'appnexus',
298
+ };
299
+ const data = {
300
+ webo_ctx: ['foo', 'bar'],
301
+ webo_ds: ['baz'],
302
+ };
303
+ const adUnitCode1 = 'adunit1';
304
+ const adUnitCode2 = 'adunit2';
305
+
306
+ const reqBidsConfigObj = {
307
+ adUnits: [{
308
+ code: adUnitCode1,
309
+ bids: [{
310
+ bidder: 'smartadserver'
311
+ }, {
312
+ bidder: 'pubmatic'
313
+ }, {
314
+ bidder: 'appnexus'
315
+ }, {
316
+ bidder: 'rubicon'
317
+ }, {
318
+ bidder: 'other'
319
+ }]
320
+ }, {
321
+ code: adUnitCode2,
322
+ bids: [{
323
+ bidder: 'smartadserver'
324
+ }, {
325
+ bidder: 'pubmatic'
326
+ }, {
327
+ bidder: 'appnexus'
328
+ }, {
329
+ bidder: 'rubicon'
330
+ }, {
331
+ bidder: 'other'
332
+ }]
333
+ }]
334
+ };
335
+
336
+ const onDoneSpy = sinon.spy();
337
+
338
+ expect(weboramaSubmodule.init(moduleConfig)).to.be.true;
339
+ weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig);
340
+
341
+ let request = server.requests[0];
342
+
343
+ expect(request.method).to.equal('GET');
344
+ expect(request.url).to.equal('https://ctx.weborama.com/api/profile?token=foo&url=https%3A%2F%2Fprebid.org&');
345
+ expect(request.withCredentials).to.be.false;
346
+
347
+ request.respond(200, responseHeader, JSON.stringify(data));
348
+
349
+ expect(onDoneSpy.calledOnce).to.be.true;
350
+
351
+ const targeting = weboramaSubmodule.getTargetingData([adUnitCode1, adUnitCode2], moduleConfig);
352
+
353
+ expect(targeting).to.deep.equal({
354
+ 'adunit1': data,
355
+ 'adunit2': data,
356
+ });
357
+
358
+ reqBidsConfigObj.adUnits.forEach(adUnit => {
359
+ expect(adUnit.bids.length).to.equal(5);
360
+ expect(adUnit.bids[0].params).to.be.undefined;
361
+ expect(adUnit.bids[1].params).to.be.undefined;
362
+ expect(adUnit.bids[3].params).to.be.undefined;
363
+ expect(adUnit.bids[4].ortb2).to.be.undefined;
364
+ });
365
+
366
+ expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal(data);
367
+ expect(reqBidsConfigObj.adUnits[1].bids[2].params).to.be.undefined;
368
+
369
+ expect(onDataResponse).to.deep.equal({
370
+ data: data,
371
+ meta: {
372
+ user: false,
373
+ source: 'contextual',
374
+ isDefault: false,
375
+ },
376
+ });
377
+ });
378
+ });
379
+ });
380
+
381
+ describe('should set gam targeting for multiple adunits but not send to bidders with setPrebidTargeting=<true>/sendToBidders=false', function() {
382
+ const testcases = {
383
+ 'boolean': true,
384
+ 'array with both units': ['adunit1', 'adunit2'],
385
+ 'callback': () => {
386
+ return true;
387
+ },
388
+ };
389
+
390
+ Object.keys(testcases).forEach(label => {
391
+ const setPrebidTargeting = testcases[label];
392
+ it(`check setPrebidTargeting as ${label}`, function() {
393
+ const moduleConfig = {
191
394
  params: {
192
- keywords: {
193
- foo: ['bar']
395
+ weboCtxConf: {
396
+ token: 'foo',
397
+ targetURL: 'https://prebid.org',
398
+ setPrebidTargeting: setPrebidTargeting,
399
+ sendToBidders: false,
194
400
  }
195
401
  }
196
- }, {
197
- bidder: 'rubicon',
198
- params: {
402
+ };
403
+ const data = {
404
+ webo_ctx: ['foo', 'bar'],
405
+ webo_ds: ['baz'],
406
+ };
407
+ const adUnitCode1 = 'adunit1';
408
+ const adUnitCode2 = 'adunit2';
409
+ const reqBidsConfigObj = {
410
+ adUnits: [{
411
+ code: adUnitCode1,
412
+ bids: [{
413
+ bidder: 'smartadserver',
414
+ params: {
415
+ target: 'foo=bar'
416
+ }
417
+ }, {
418
+ bidder: 'pubmatic',
419
+ params: {
420
+ dctr: 'foo=bar'
421
+ }
422
+ }, {
423
+ bidder: 'appnexus',
424
+ params: {
425
+ keywords: {
426
+ foo: ['bar']
427
+ }
428
+ }
429
+ }, {
430
+ bidder: 'rubicon',
431
+ params: {
432
+ inventory: {
433
+ foo: 'bar',
434
+ },
435
+ visitor: {
436
+ baz: 'bam',
437
+ }
438
+ }
439
+ }, {
440
+ bidder: 'other',
441
+ }]
442
+ }, {
443
+ code: adUnitCode2,
444
+ bids: [{
445
+ bidder: 'smartadserver',
446
+ params: {
447
+ target: 'foo=bar'
448
+ }
449
+ }, {
450
+ bidder: 'pubmatic',
451
+ params: {
452
+ dctr: 'foo=bar'
453
+ }
454
+ }, {
455
+ bidder: 'appnexus',
456
+ params: {
457
+ keywords: {
458
+ foo: ['bar']
459
+ }
460
+ }
461
+ }, {
462
+ bidder: 'rubicon',
463
+ params: {
464
+ inventory: {
465
+ foo: 'bar',
466
+ },
467
+ visitor: {
468
+ baz: 'bam',
469
+ }
470
+ }
471
+ }, {
472
+ bidder: 'other',
473
+ }]
474
+ }]
475
+ };
476
+ const onDoneSpy = sinon.spy();
477
+
478
+ expect(weboramaSubmodule.init(moduleConfig)).to.be.true;
479
+ weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig);
480
+
481
+ let request = server.requests[0];
482
+
483
+ expect(request.method).to.equal('GET');
484
+ expect(request.url).to.equal('https://ctx.weborama.com/api/profile?token=foo&url=https%3A%2F%2Fprebid.org&');
485
+ expect(request.withCredentials).to.be.false;
486
+
487
+ request.respond(200, responseHeader, JSON.stringify(data));
488
+
489
+ expect(onDoneSpy.calledOnce).to.be.true;
490
+
491
+ const targeting = weboramaSubmodule.getTargetingData([adUnitCode1, adUnitCode2], moduleConfig);
492
+
493
+ expect(targeting).to.deep.equal({
494
+ 'adunit1': data,
495
+ 'adunit2': data,
496
+ });
497
+
498
+ reqBidsConfigObj.adUnits.forEach(adUnit => {
499
+ expect(adUnit.bids.length).to.equal(5);
500
+ expect(adUnit.bids[0].params.target).to.equal('foo=bar');
501
+ expect(adUnit.bids[1].params.dctr).to.equal('foo=bar');
502
+ expect(adUnit.bids[2].params.keywords).to.deep.equal({
503
+ foo: ['bar']
504
+ });
505
+ expect(adUnit.bids[3].params).to.deep.equal({
199
506
  inventory: {
200
507
  foo: 'bar',
201
508
  },
202
509
  visitor: {
203
510
  baz: 'bam',
204
511
  }
205
- }
206
- }, {
207
- bidder: 'other',
208
- }]
209
- }]
210
- };
211
- const onDoneSpy = sinon.spy();
212
-
213
- expect(weboramaSubmodule.init(moduleConfig)).to.be.true;
214
- weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig);
215
-
216
- let request = server.requests[0];
217
-
218
- expect(request.method).to.equal('GET');
219
- expect(request.url).to.equal('https://ctx.weborama.com/api/profile?token=foo&url=https%3A%2F%2Fprebid.org&');
220
- expect(request.withCredentials).to.be.false;
221
-
222
- request.respond(200, responseHeader, JSON.stringify(data));
223
-
224
- expect(onDoneSpy.calledOnce).to.be.true;
512
+ });
225
513
 
226
- const targeting = weboramaSubmodule.getTargetingData(adUnitsCodes, moduleConfig);
227
-
228
- expect(targeting).to.deep.equal({
229
- 'adunit1': data,
230
- 'adunit2': data,
514
+ expect(adUnit.bids[4].ortb2).to.be.undefined;
515
+ });
516
+ });
231
517
  });
518
+ });
232
519
 
233
- expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5);
234
- expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('foo=bar');
235
- expect(reqBidsConfigObj.adUnits[0].bids[1].params.dctr).to.equal('foo=bar');
236
- expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal({
237
- foo: ['bar']
238
- });
239
- expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.deep.equal({
240
- inventory: {
241
- foo: 'bar',
520
+ describe('should set gam targeting for one adunit but not send to bidders with setPrebidTargeting=<true>/sendToBidders=false', function() {
521
+ const testcases = {
522
+ 'array with one unit': ['adunit1'],
523
+ 'callback': (adUnitCode) => {
524
+ return adUnitCode == 'adunit1';
242
525
  },
243
- visitor: {
244
- baz: 'bam',
245
- }
526
+ };
527
+
528
+ Object.keys(testcases).forEach(label => {
529
+ const setPrebidTargeting = testcases[label];
530
+ it(`check setPrebidTargeting as ${label}`, function() {
531
+ const moduleConfig = {
532
+ params: {
533
+ weboCtxConf: {
534
+ token: 'foo',
535
+ targetURL: 'https://prebid.org',
536
+ setPrebidTargeting: setPrebidTargeting,
537
+ sendToBidders: false,
538
+ }
539
+ }
540
+ };
541
+ const data = {
542
+ webo_ctx: ['foo', 'bar'],
543
+ webo_ds: ['baz'],
544
+ };
545
+ const adUnitCode1 = 'adunit1';
546
+ const adUnitCode2 = 'adunit2';
547
+ const reqBidsConfigObj = {
548
+ adUnits: [{
549
+ code: adUnitCode1,
550
+ bids: [{
551
+ bidder: 'smartadserver',
552
+ params: {
553
+ target: 'foo=bar'
554
+ }
555
+ }, {
556
+ bidder: 'pubmatic',
557
+ params: {
558
+ dctr: 'foo=bar'
559
+ }
560
+ }, {
561
+ bidder: 'appnexus',
562
+ params: {
563
+ keywords: {
564
+ foo: ['bar']
565
+ }
566
+ }
567
+ }, {
568
+ bidder: 'rubicon',
569
+ params: {
570
+ inventory: {
571
+ foo: 'bar',
572
+ },
573
+ visitor: {
574
+ baz: 'bam',
575
+ }
576
+ }
577
+ }, {
578
+ bidder: 'other',
579
+ }]
580
+ }, {
581
+ code: adUnitCode2,
582
+ bids: [{
583
+ bidder: 'smartadserver',
584
+ params: {
585
+ target: 'foo=bar'
586
+ }
587
+ }, {
588
+ bidder: 'pubmatic',
589
+ params: {
590
+ dctr: 'foo=bar'
591
+ }
592
+ }, {
593
+ bidder: 'appnexus',
594
+ params: {
595
+ keywords: {
596
+ foo: ['bar']
597
+ }
598
+ }
599
+ }, {
600
+ bidder: 'rubicon',
601
+ params: {
602
+ inventory: {
603
+ foo: 'bar',
604
+ },
605
+ visitor: {
606
+ baz: 'bam',
607
+ }
608
+ }
609
+ }, {
610
+ bidder: 'other',
611
+ }]
612
+ }]
613
+ };
614
+ const onDoneSpy = sinon.spy();
615
+
616
+ expect(weboramaSubmodule.init(moduleConfig)).to.be.true;
617
+ weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig);
618
+
619
+ let request = server.requests[0];
620
+
621
+ expect(request.method).to.equal('GET');
622
+ expect(request.url).to.equal('https://ctx.weborama.com/api/profile?token=foo&url=https%3A%2F%2Fprebid.org&');
623
+ expect(request.withCredentials).to.be.false;
624
+
625
+ request.respond(200, responseHeader, JSON.stringify(data));
626
+
627
+ expect(onDoneSpy.calledOnce).to.be.true;
628
+
629
+ const targeting = weboramaSubmodule.getTargetingData([adUnitCode1, adUnitCode2], moduleConfig);
630
+
631
+ expect(targeting).to.deep.equal({
632
+ 'adunit1': data,
633
+ 'adunit2': {},
634
+ });
635
+
636
+ reqBidsConfigObj.adUnits.forEach(adUnit => {
637
+ expect(adUnit.bids.length).to.equal(5);
638
+ expect(adUnit.bids[0].params.target).to.equal('foo=bar');
639
+ expect(adUnit.bids[1].params.dctr).to.equal('foo=bar');
640
+ expect(adUnit.bids[2].params.keywords).to.deep.equal({
641
+ foo: ['bar']
642
+ });
643
+ expect(adUnit.bids[3].params).to.deep.equal({
644
+ inventory: {
645
+ foo: 'bar',
646
+ },
647
+ visitor: {
648
+ baz: 'bam',
649
+ }
650
+ });
651
+
652
+ expect(adUnit.bids[4].ortb2).to.be.undefined;
653
+ });
654
+ });
246
655
  });
247
- expect(reqBidsConfigObj.adUnits[0].bids[4].ortb2).to.be.undefined;
248
- expect(getGlobal().getConfig('ortb2')).to.be.undefined;
249
656
  });
250
657
 
251
- it('should set gam targeting but not send to bidders with (submodule override) setPrebidTargeting=true/(global) sendToBidders=false', function () {
658
+ it('should set gam targeting but not send to bidders with (submodule override) setPrebidTargeting=true/(global) sendToBidders=false', function() {
252
659
  let onDataResponse = {};
253
660
  const moduleConfig = {
254
661
  params: {
255
662
  setPrebidTargeting: false,
256
663
  sendToBidders: false,
257
- onData: (data, site) => {
664
+ onData: (data, meta) => {
258
665
  onDataResponse = {
259
666
  data: data,
260
- site: site,
667
+ meta: meta,
261
668
  };
262
669
  },
263
670
  weboCtxConf: {
@@ -271,9 +678,10 @@ describe('weboramaRtdProvider', function () {
271
678
  webo_ctx: ['foo', 'bar'],
272
679
  webo_ds: ['baz'],
273
680
  };
274
- const adUnitsCodes = ['adunit1', 'adunit2'];
681
+ const adUnitCode = 'adunit1';
275
682
  const reqBidsConfigObj = {
276
683
  adUnits: [{
684
+ code: adUnitCode,
277
685
  bids: [{
278
686
  bidder: 'smartadserver',
279
687
  params: {
@@ -297,23 +705,25 @@ describe('weboramaRtdProvider', function () {
297
705
 
298
706
  expect(onDoneSpy.calledOnce).to.be.true;
299
707
 
300
- const targeting = weboramaSubmodule.getTargetingData(adUnitsCodes, moduleConfig);
708
+ const targeting = weboramaSubmodule.getTargetingData([adUnitCode], moduleConfig);
301
709
 
302
710
  expect(targeting).to.deep.equal({
303
711
  'adunit1': data,
304
- 'adunit2': data,
305
712
  });
306
713
 
307
714
  expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(1);
308
- expect(getGlobal().getConfig('ortb2')).to.be.undefined;
309
715
 
310
716
  expect(onDataResponse).to.deep.equal({
311
717
  data: data,
312
- site: true,
718
+ meta: {
719
+ user: false,
720
+ source: 'contextual',
721
+ isDefault: false,
722
+ },
313
723
  });
314
724
  });
315
725
 
316
- it('should not set gam targeting with setPrebidTargeting=false but send to bidders', function () {
726
+ it('should not set gam targeting with setPrebidTargeting=false but send to bidders', function() {
317
727
  const moduleConfig = {
318
728
  params: {
319
729
  weboCtxConf: {
@@ -327,9 +737,10 @@ describe('weboramaRtdProvider', function () {
327
737
  webo_ctx: ['foo', 'bar'],
328
738
  webo_ds: ['baz'],
329
739
  };
330
- const adUnitsCodes = ['adunit1', 'adunit2'];
740
+ const adUnitCode = 'adunit1';
331
741
  const reqBidsConfigObj = {
332
742
  adUnits: [{
743
+ code: adUnitCode,
333
744
  bids: [{
334
745
  bidder: 'smartadserver',
335
746
  params: {
@@ -377,9 +788,11 @@ describe('weboramaRtdProvider', function () {
377
788
 
378
789
  expect(onDoneSpy.calledOnce).to.be.true;
379
790
 
380
- const targeting = weboramaSubmodule.getTargetingData(adUnitsCodes, moduleConfig);
791
+ const targeting = weboramaSubmodule.getTargetingData([adUnitCode], moduleConfig);
381
792
 
382
- expect(targeting).to.deep.equal({});
793
+ expect(targeting).to.deep.equal({
794
+ 'adunit1': {},
795
+ });
383
796
 
384
797
  expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5);
385
798
  expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('foo=bar;webo_ctx=foo;webo_ctx=bar;webo_ds=baz');
@@ -406,16 +819,9 @@ describe('weboramaRtdProvider', function () {
406
819
  },
407
820
  }
408
821
  });
409
- expect(getGlobal().getConfig('ortb2')).to.deep.equal({
410
- site: {
411
- ext: {
412
- data: data
413
- },
414
- }
415
- });
416
822
  });
417
823
 
418
- it('should use default profile in case of api error', function () {
824
+ it('should use default profile in case of api error', function() {
419
825
  const defaultProfile = {
420
826
  webo_ctx: ['baz'],
421
827
  };
@@ -427,19 +833,20 @@ describe('weboramaRtdProvider', function () {
427
833
  targetURL: 'https://prebid.org',
428
834
  setPrebidTargeting: true,
429
835
  defaultProfile: defaultProfile,
430
- onData: (data, site) => {
836
+ onData: (data, meta) => {
431
837
  onDataResponse = {
432
838
  data: data,
433
- site: site,
839
+ meta: meta,
434
840
  };
435
841
  },
436
842
  }
437
843
  }
438
844
  };
439
845
 
440
- const adUnitsCodes = ['adunit1', 'adunit2'];
846
+ const adUnitCode = 'adunit1';
441
847
  const reqBidsConfigObj = {
442
848
  adUnits: [{
849
+ code: adUnitCode,
443
850
  bids: [{
444
851
  bidder: 'smartadserver'
445
852
  }, {
@@ -468,11 +875,10 @@ describe('weboramaRtdProvider', function () {
468
875
 
469
876
  expect(onDoneSpy.calledOnce).to.be.true;
470
877
 
471
- const targeting = weboramaSubmodule.getTargetingData(adUnitsCodes, moduleConfig);
878
+ const targeting = weboramaSubmodule.getTargetingData([adUnitCode], moduleConfig);
472
879
 
473
880
  expect(targeting).to.deep.equal({
474
881
  'adunit1': defaultProfile,
475
- 'adunit2': defaultProfile,
476
882
  });
477
883
 
478
884
  expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5);
@@ -489,53 +895,67 @@ describe('weboramaRtdProvider', function () {
489
895
  },
490
896
  }
491
897
  });
492
- expect(getGlobal().getConfig('ortb2')).to.deep.equal({
493
- site: {
494
- ext: {
495
- data: defaultProfile
496
- },
497
- }
498
- });
499
898
  expect(onDataResponse).to.deep.equal({
500
899
  data: defaultProfile,
501
- site: true,
900
+ meta: {
901
+ user: false,
902
+ source: 'contextual',
903
+ isDefault: true,
904
+ },
502
905
  });
503
906
  });
504
- });
505
907
 
506
- describe('Add user-centric data (WAM2GAM)', function () {
507
- it('should set gam targeting from local storage and send to bidders by default', function () {
908
+ it('should be possible update profile from callbacks for a given bidder/adUnitCode', function() {
508
909
  let onDataResponse = {};
509
910
  const moduleConfig = {
510
911
  params: {
511
- weboUserDataConf: {
512
- accountID: 12345,
513
- onData: (data, site) => {
912
+ weboCtxConf: {
913
+ token: 'foo',
914
+ targetURL: 'https://prebid.org',
915
+ setPrebidTargeting: (adUnitCode, data, meta) => {
916
+ if (adUnitCode == 'adunit1') {
917
+ data['webo_foo'] = ['bar'];
918
+ }
919
+ return true;
920
+ },
921
+ sendToBidders: (bid, adUnitCode, data, meta) => {
922
+ if (bid.bidder == 'appnexus' && adUnitCode == 'adunit1') {
923
+ data['webo_bar'] = ['baz'];
924
+ }
925
+ return true;
926
+ },
927
+ baseURLProfileAPI: 'ctx.test.weborama.com',
928
+ onData: (data, meta) => {
514
929
  onDataResponse = {
515
930
  data: data,
516
- site: site,
931
+ meta: meta,
517
932
  };
518
933
  },
519
934
  }
520
935
  }
521
936
  };
522
937
  const data = {
523
- webo_cs: ['foo', 'bar'],
524
- webo_audiences: ['baz'],
525
- };
526
-
527
- const entry = {
528
- targeting: data,
938
+ webo_ctx: ['foo', 'bar'],
939
+ webo_ds: ['baz'],
529
940
  };
530
-
531
- sandbox.stub(storage, 'localStorageIsEnabled').returns(true);
532
- sandbox.stub(storage, 'getDataFromLocalStorage')
533
- .withArgs(DEFAULT_LOCAL_STORAGE_USER_PROFILE_KEY)
534
- .returns(JSON.stringify(entry));
535
-
536
- const adUnitsCodes = ['adunit1', 'adunit2'];
941
+ const adUnitCode1 = 'adunit1';
942
+ const adUnitCode2 = 'adunit2';
537
943
  const reqBidsConfigObj = {
538
944
  adUnits: [{
945
+ code: adUnitCode1,
946
+ bids: [{
947
+ bidder: 'smartadserver'
948
+ }, {
949
+ bidder: 'pubmatic'
950
+ }, {
951
+ bidder: 'appnexus'
952
+ }, {
953
+ bidder: 'rubicon'
954
+ }, {
955
+ bidder: 'other'
956
+ }]
957
+ }, {
958
+ code: adUnitCode2,
539
959
  bids: [{
540
960
  bidder: 'smartadserver'
541
961
  }, {
@@ -549,53 +969,80 @@ describe('weboramaRtdProvider', function () {
549
969
  }]
550
970
  }]
551
971
  };
972
+
552
973
  const onDoneSpy = sinon.spy();
553
974
 
554
975
  expect(weboramaSubmodule.init(moduleConfig)).to.be.true;
555
976
  weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig);
556
977
 
978
+ let request = server.requests[0];
979
+
980
+ expect(request.method).to.equal('GET');
981
+ expect(request.url).to.equal('https://ctx.test.weborama.com/api/profile?token=foo&url=https%3A%2F%2Fprebid.org&');
982
+ expect(request.withCredentials).to.be.false;
983
+
984
+ request.respond(200, responseHeader, JSON.stringify(data));
985
+
557
986
  expect(onDoneSpy.calledOnce).to.be.true;
558
987
 
559
- const targeting = weboramaSubmodule.getTargetingData(adUnitsCodes, moduleConfig);
988
+ const targeting = weboramaSubmodule.getTargetingData([adUnitCode1, adUnitCode2], moduleConfig);
560
989
 
561
990
  expect(targeting).to.deep.equal({
562
- 'adunit1': data,
991
+ 'adunit1': {
992
+ webo_ctx: ['foo', 'bar'],
993
+ webo_ds: ['baz'],
994
+ webo_foo: ['bar'],
995
+ },
563
996
  'adunit2': data,
564
997
  });
565
998
 
566
- expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5);
567
- expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('webo_cs=foo;webo_cs=bar;webo_audiences=baz');
568
- expect(reqBidsConfigObj.adUnits[0].bids[1].params.dctr).to.equal('webo_cs=foo,bar|webo_audiences=baz');
569
- expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal(data);
570
- expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.deep.equal({
571
- visitor: data
572
- });
573
- expect(reqBidsConfigObj.adUnits[0].bids[4].ortb2).to.deep.equal({
574
- user: {
575
- ext: {
576
- data: data
577
- },
578
- }
999
+ reqBidsConfigObj.adUnits.forEach(adUnit => {
1000
+ expect(adUnit.bids.length).to.equal(5);
1001
+ expect(adUnit.bids[0].params.target).to.equal('webo_ctx=foo;webo_ctx=bar;webo_ds=baz');
1002
+ expect(adUnit.bids[1].params.dctr).to.equal('webo_ctx=foo,bar|webo_ds=baz');
1003
+ expect(adUnit.bids[3].params).to.deep.equal({
1004
+ inventory: data
1005
+ });
1006
+ expect(adUnit.bids[4].ortb2).to.deep.equal({
1007
+ site: {
1008
+ ext: {
1009
+ data: data
1010
+ },
1011
+ }
1012
+ });
579
1013
  });
580
- expect(getGlobal().getConfig('ortb2')).to.deep.equal({
581
- user: {
582
- ext: {
583
- data: data
584
- },
585
- }
1014
+
1015
+ expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal({
1016
+ webo_ctx: ['foo', 'bar'],
1017
+ webo_ds: ['baz'],
1018
+ webo_bar: ['baz'],
586
1019
  });
1020
+ expect(reqBidsConfigObj.adUnits[1].bids[2].params.keywords).to.deep.equal(data);
1021
+
587
1022
  expect(onDataResponse).to.deep.equal({
588
1023
  data: data,
589
- site: false,
1024
+ meta: {
1025
+ user: false,
1026
+ source: 'contextual',
1027
+ isDefault: false,
1028
+ },
590
1029
  });
591
1030
  });
1031
+ });
592
1032
 
593
- it('should set gam targeting but not send to bidders with setPrebidTargeting=true/sendToBidders=false', function () {
1033
+ describe('Add user-centric data (wam)', function() {
1034
+ it('should set gam targeting from local storage and send to bidders by default', function() {
1035
+ let onDataResponse = {};
594
1036
  const moduleConfig = {
595
1037
  params: {
596
1038
  weboUserDataConf: {
597
- setPrebidTargeting: true,
598
- sendToBidders: false
1039
+ accoundId: 12345,
1040
+ onData: (data, meta) => {
1041
+ onDataResponse = {
1042
+ data: data,
1043
+ meta: meta,
1044
+ };
1045
+ },
599
1046
  }
600
1047
  }
601
1048
  };
@@ -613,36 +1060,18 @@ describe('weboramaRtdProvider', function () {
613
1060
  .withArgs(DEFAULT_LOCAL_STORAGE_USER_PROFILE_KEY)
614
1061
  .returns(JSON.stringify(entry));
615
1062
 
616
- const adUnitsCodes = ['adunit1', 'adunit2'];
1063
+ const adUnitCode = 'adunit1';
617
1064
  const reqBidsConfigObj = {
618
1065
  adUnits: [{
1066
+ code: adUnitCode,
619
1067
  bids: [{
620
- bidder: 'smartadserver',
621
- params: {
622
- target: 'foo=bar'
623
- }
1068
+ bidder: 'smartadserver'
624
1069
  }, {
625
- bidder: 'pubmatic',
626
- params: {
627
- dctr: 'foo=bar'
628
- }
1070
+ bidder: 'pubmatic'
629
1071
  }, {
630
- bidder: 'appnexus',
631
- params: {
632
- keywords: {
633
- foo: ['bar']
634
- }
635
- }
1072
+ bidder: 'appnexus'
636
1073
  }, {
637
- bidder: 'rubicon',
638
- params: {
639
- inventory: {
640
- foo: 'bar'
641
- },
642
- visitor: {
643
- baz: 'bam'
644
- }
645
- }
1074
+ bidder: 'rubicon'
646
1075
  }, {
647
1076
  bidder: 'other'
648
1077
  }]
@@ -655,44 +1084,554 @@ describe('weboramaRtdProvider', function () {
655
1084
 
656
1085
  expect(onDoneSpy.calledOnce).to.be.true;
657
1086
 
658
- const targeting = weboramaSubmodule.getTargetingData(adUnitsCodes, moduleConfig);
1087
+ const targeting = weboramaSubmodule.getTargetingData([adUnitCode], moduleConfig);
659
1088
 
660
1089
  expect(targeting).to.deep.equal({
661
1090
  'adunit1': data,
662
- 'adunit2': data,
663
1091
  });
664
1092
 
665
1093
  expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5);
666
- expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('foo=bar');
667
- expect(reqBidsConfigObj.adUnits[0].bids[1].params.dctr).to.equal('foo=bar');
668
- expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal({
669
- foo: ['bar']
670
- });
1094
+ expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('webo_cs=foo;webo_cs=bar;webo_audiences=baz');
1095
+ expect(reqBidsConfigObj.adUnits[0].bids[1].params.dctr).to.equal('webo_cs=foo,bar|webo_audiences=baz');
1096
+ expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal(data);
671
1097
  expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.deep.equal({
672
- inventory: {
673
- foo: 'bar'
674
- },
675
- visitor: {
676
- baz: 'bam'
1098
+ visitor: data
1099
+ });
1100
+ expect(reqBidsConfigObj.adUnits[0].bids[4].ortb2).to.deep.equal({
1101
+ user: {
1102
+ ext: {
1103
+ data: data
1104
+ },
677
1105
  }
678
1106
  });
679
- expect(reqBidsConfigObj.adUnits[0].bids[4].ortb2).to.be.undefined;
680
- expect(getGlobal().getConfig('ortb2')).to.be.undefined;
1107
+ expect(onDataResponse).to.deep.equal({
1108
+ data: data,
1109
+ meta: {
1110
+ user: true,
1111
+ source: 'wam',
1112
+ isDefault: false,
1113
+ },
1114
+ });
681
1115
  });
682
1116
 
683
- it('should set gam targeting but not send to bidders with (submodule override) setPrebidTargeting=true/(global) sendToBidders=false', function () {
684
- let onDataResponse = {};
685
- const moduleConfig = {
686
- params: {
687
- setPrebidTargeting: false,
688
- sendToBidders: false,
689
- onData: (data, site) => {
1117
+ describe('should set gam targeting from local storage and send to one specific bidder and multiple adunits', function() {
1118
+ const testcases = {
1119
+ 'single string': 'appnexus',
1120
+ 'array with one entry': ['appnexus'],
1121
+ 'map with one entry': {
1122
+ 'appnexus': true
1123
+ },
1124
+ 'map complete': {
1125
+ 'smartadserver': false,
1126
+ 'pubmatic': false,
1127
+ 'appnexus': true,
1128
+ 'rubicon': false,
1129
+ 'other': false,
1130
+ },
1131
+ 'callback': (bid) => {
1132
+ return bid.bidder == 'appnexus'
1133
+ },
1134
+ };
1135
+
1136
+ Object.keys(testcases).forEach(label => {
1137
+ const sendToBidders = testcases[label];
1138
+ it(`check sendToBidders as ${label}`, function() {
1139
+ let onDataResponse = {};
1140
+ const moduleConfig = {
1141
+ params: {
1142
+ weboUserDataConf: {
1143
+ accountId: 12345,
1144
+ sendToBidders: sendToBidders,
1145
+ onData: (data, meta) => {
1146
+ onDataResponse = {
1147
+ data: data,
1148
+ meta: meta,
1149
+ };
1150
+ },
1151
+ }
1152
+ }
1153
+ };
1154
+ const data = {
1155
+ webo_cs: ['foo', 'bar'],
1156
+ webo_audiences: ['baz'],
1157
+ };
1158
+
1159
+ const entry = {
1160
+ targeting: data,
1161
+ };
1162
+
1163
+ sandbox.stub(storage, 'localStorageIsEnabled').returns(true);
1164
+ sandbox.stub(storage, 'getDataFromLocalStorage')
1165
+ .withArgs(DEFAULT_LOCAL_STORAGE_USER_PROFILE_KEY)
1166
+ .returns(JSON.stringify(entry));
1167
+
1168
+ const adUnitCode1 = 'adunit1';
1169
+ const adUnitCode2 = 'adunit2';
1170
+ const reqBidsConfigObj = {
1171
+ adUnits: [{
1172
+ code: adUnitCode1,
1173
+ bids: [{
1174
+ bidder: 'smartadserver'
1175
+ }, {
1176
+ bidder: 'pubmatic'
1177
+ }, {
1178
+ bidder: 'appnexus'
1179
+ }, {
1180
+ bidder: 'rubicon'
1181
+ }, {
1182
+ bidder: 'other'
1183
+ }]
1184
+ }, {
1185
+ code: adUnitCode2,
1186
+ bids: [{
1187
+ bidder: 'smartadserver'
1188
+ }, {
1189
+ bidder: 'pubmatic'
1190
+ }, {
1191
+ bidder: 'appnexus'
1192
+ }, {
1193
+ bidder: 'rubicon'
1194
+ }, {
1195
+ bidder: 'other'
1196
+ }]
1197
+ }]
1198
+ };
1199
+ const onDoneSpy = sinon.spy();
1200
+
1201
+ expect(weboramaSubmodule.init(moduleConfig)).to.be.true;
1202
+ weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig);
1203
+
1204
+ expect(onDoneSpy.calledOnce).to.be.true;
1205
+
1206
+ const targeting = weboramaSubmodule.getTargetingData([adUnitCode1, adUnitCode2], moduleConfig);
1207
+
1208
+ expect(targeting).to.deep.equal({
1209
+ 'adunit1': data,
1210
+ 'adunit2': data,
1211
+ });
1212
+
1213
+ reqBidsConfigObj.adUnits.forEach(adUnit => {
1214
+ expect(adUnit.bids.length).to.equal(5);
1215
+ expect(adUnit.bids[0].params).to.be.undefined;
1216
+ expect(adUnit.bids[1].params).to.be.undefined;
1217
+ expect(adUnit.bids[2].params.keywords).to.deep.equal(data);
1218
+ expect(adUnit.bids[3].params).to.be.undefined;
1219
+ expect(adUnit.bids[4].ortb2).to.be.undefined;
1220
+ });
1221
+
1222
+ expect(onDataResponse).to.deep.equal({
1223
+ data: data,
1224
+ meta: {
1225
+ user: true,
1226
+ source: 'wam',
1227
+ isDefault: false,
1228
+ },
1229
+ });
1230
+ });
1231
+ });
1232
+ });
1233
+
1234
+ describe('should set gam targeting from local storage and send to one specific bidder and one adunit', function() {
1235
+ const testcases = {
1236
+ 'map with one entry': {
1237
+ 'appnexus': ['adunit1']
1238
+ },
1239
+ 'callback': (bid, adUnitCode) => {
1240
+ return bid.bidder == 'appnexus' && adUnitCode == 'adunit1';
1241
+ },
1242
+ };
1243
+
1244
+ Object.keys(testcases).forEach(label => {
1245
+ const sendToBidders = testcases[label];
1246
+ it(`check sendToBidders as ${label}`, function() {
1247
+ let onDataResponse = {};
1248
+ const moduleConfig = {
1249
+ params: {
1250
+ weboUserDataConf: {
1251
+ accountId: 12345,
1252
+ sendToBidders: sendToBidders,
1253
+ onData: (data, meta) => {
1254
+ onDataResponse = {
1255
+ data: data,
1256
+ meta: meta,
1257
+ };
1258
+ },
1259
+ }
1260
+ }
1261
+ };
1262
+ const data = {
1263
+ webo_cs: ['foo', 'bar'],
1264
+ webo_audiences: ['baz'],
1265
+ };
1266
+
1267
+ const entry = {
1268
+ targeting: data,
1269
+ };
1270
+
1271
+ sandbox.stub(storage, 'localStorageIsEnabled').returns(true);
1272
+ sandbox.stub(storage, 'getDataFromLocalStorage')
1273
+ .withArgs(DEFAULT_LOCAL_STORAGE_USER_PROFILE_KEY)
1274
+ .returns(JSON.stringify(entry));
1275
+
1276
+ const adUnitCode1 = 'adunit1';
1277
+ const adUnitCode2 = 'adunit2';
1278
+ const reqBidsConfigObj = {
1279
+ adUnits: [{
1280
+ code: adUnitCode1,
1281
+ bids: [{
1282
+ bidder: 'smartadserver'
1283
+ }, {
1284
+ bidder: 'pubmatic'
1285
+ }, {
1286
+ bidder: 'appnexus'
1287
+ }, {
1288
+ bidder: 'rubicon'
1289
+ }, {
1290
+ bidder: 'other'
1291
+ }]
1292
+ }, {
1293
+ code: adUnitCode2,
1294
+ bids: [{
1295
+ bidder: 'smartadserver'
1296
+ }, {
1297
+ bidder: 'pubmatic'
1298
+ }, {
1299
+ bidder: 'appnexus'
1300
+ }, {
1301
+ bidder: 'rubicon'
1302
+ }, {
1303
+ bidder: 'other'
1304
+ }]
1305
+ }]
1306
+ };
1307
+ const onDoneSpy = sinon.spy();
1308
+
1309
+ expect(weboramaSubmodule.init(moduleConfig)).to.be.true;
1310
+ weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig);
1311
+
1312
+ expect(onDoneSpy.calledOnce).to.be.true;
1313
+
1314
+ const targeting = weboramaSubmodule.getTargetingData([adUnitCode1, adUnitCode2], moduleConfig);
1315
+
1316
+ expect(targeting).to.deep.equal({
1317
+ 'adunit1': data,
1318
+ 'adunit2': data,
1319
+ });
1320
+
1321
+ reqBidsConfigObj.adUnits.forEach(adUnit => {
1322
+ expect(adUnit.bids.length).to.equal(5);
1323
+ expect(adUnit.bids[0].params).to.be.undefined;
1324
+ expect(adUnit.bids[1].params).to.be.undefined;
1325
+ expect(adUnit.bids[3].params).to.be.undefined;
1326
+ expect(adUnit.bids[4].ortb2).to.be.undefined;
1327
+ });
1328
+
1329
+ expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal(data);
1330
+ expect(reqBidsConfigObj.adUnits[1].bids[2].params).to.be.undefined;
1331
+
1332
+ expect(onDataResponse).to.deep.equal({
1333
+ data: data,
1334
+ meta: {
1335
+ user: true,
1336
+ source: 'wam',
1337
+ isDefault: false,
1338
+ },
1339
+ });
1340
+ });
1341
+ });
1342
+ });
1343
+
1344
+ describe('should set gam targeting for multiple adunits but not send to bidders with setPrebidTargeting=<true>/sendToBidders=false', function() {
1345
+ const testcases = {
1346
+ 'boolean': true,
1347
+ 'array with both units': ['adunit1', 'adunit2'],
1348
+ 'callback': () => {
1349
+ return true;
1350
+ },
1351
+ };
1352
+
1353
+ Object.keys(testcases).forEach(label => {
1354
+ const setPrebidTargeting = testcases[label];
1355
+ it(`check setPrebidTargeting as ${label}`, function() {
1356
+ const moduleConfig = {
1357
+ params: {
1358
+ weboUserDataConf: {
1359
+ accoundId: 12345,
1360
+ setPrebidTargeting: setPrebidTargeting,
1361
+ sendToBidders: false
1362
+ }
1363
+ }
1364
+ };
1365
+ const data = {
1366
+ webo_cs: ['foo', 'bar'],
1367
+ webo_audiences: ['baz'],
1368
+ };
1369
+
1370
+ const entry = {
1371
+ targeting: data,
1372
+ };
1373
+
1374
+ sandbox.stub(storage, 'localStorageIsEnabled').returns(true);
1375
+ sandbox.stub(storage, 'getDataFromLocalStorage')
1376
+ .withArgs(DEFAULT_LOCAL_STORAGE_USER_PROFILE_KEY)
1377
+ .returns(JSON.stringify(entry));
1378
+
1379
+ const adUnitCode1 = 'adunit1';
1380
+ const adUnitCode2 = 'adunit2';
1381
+ const reqBidsConfigObj = {
1382
+ adUnits: [{
1383
+ code: adUnitCode1,
1384
+ bids: [{
1385
+ bidder: 'smartadserver',
1386
+ params: {
1387
+ target: 'foo=bar'
1388
+ }
1389
+ }, {
1390
+ bidder: 'pubmatic',
1391
+ params: {
1392
+ dctr: 'foo=bar'
1393
+ }
1394
+ }, {
1395
+ bidder: 'appnexus',
1396
+ params: {
1397
+ keywords: {
1398
+ foo: ['bar']
1399
+ }
1400
+ }
1401
+ }, {
1402
+ bidder: 'rubicon',
1403
+ params: {
1404
+ inventory: {
1405
+ foo: 'bar'
1406
+ },
1407
+ visitor: {
1408
+ baz: 'bam'
1409
+ }
1410
+ }
1411
+ }, {
1412
+ bidder: 'other'
1413
+ }]
1414
+ }, {
1415
+ code: adUnitCode2,
1416
+ bids: [{
1417
+ bidder: 'smartadserver',
1418
+ params: {
1419
+ target: 'foo=bar'
1420
+ }
1421
+ }, {
1422
+ bidder: 'pubmatic',
1423
+ params: {
1424
+ dctr: 'foo=bar'
1425
+ }
1426
+ }, {
1427
+ bidder: 'appnexus',
1428
+ params: {
1429
+ keywords: {
1430
+ foo: ['bar']
1431
+ }
1432
+ }
1433
+ }, {
1434
+ bidder: 'rubicon',
1435
+ params: {
1436
+ inventory: {
1437
+ foo: 'bar'
1438
+ },
1439
+ visitor: {
1440
+ baz: 'bam'
1441
+ }
1442
+ }
1443
+ }, {
1444
+ bidder: 'other'
1445
+ }]
1446
+ }]
1447
+ };
1448
+ const onDoneSpy = sinon.spy();
1449
+
1450
+ expect(weboramaSubmodule.init(moduleConfig)).to.be.true;
1451
+ weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig);
1452
+
1453
+ expect(onDoneSpy.calledOnce).to.be.true;
1454
+
1455
+ const targeting = weboramaSubmodule.getTargetingData([adUnitCode1, adUnitCode2], moduleConfig);
1456
+
1457
+ expect(targeting).to.deep.equal({
1458
+ 'adunit1': data,
1459
+ 'adunit2': data,
1460
+ });
1461
+
1462
+ reqBidsConfigObj.adUnits.forEach(adUnit => {
1463
+ expect(adUnit.bids.length).to.equal(5);
1464
+ expect(adUnit.bids[0].params.target).to.equal('foo=bar');
1465
+ expect(adUnit.bids[1].params.dctr).to.equal('foo=bar');
1466
+ expect(adUnit.bids[2].params.keywords).to.deep.equal({
1467
+ foo: ['bar']
1468
+ });
1469
+ expect(adUnit.bids[3].params).to.deep.equal({
1470
+ inventory: {
1471
+ foo: 'bar'
1472
+ },
1473
+ visitor: {
1474
+ baz: 'bam'
1475
+ }
1476
+ });
1477
+ expect(adUnit.bids[4].ortb2).to.be.undefined;
1478
+ });
1479
+ });
1480
+ });
1481
+ });
1482
+
1483
+ describe('should set gam targeting for one adunit but not send to bidders with setPrebidTargeting=<true>/sendToBidders=false', function() {
1484
+ const testcases = {
1485
+ 'array with one unit': ['adunit1'],
1486
+ 'callback': (adUnitCode) => {
1487
+ return adUnitCode == 'adunit1';
1488
+ },
1489
+ };
1490
+
1491
+ Object.keys(testcases).forEach(label => {
1492
+ const setPrebidTargeting = testcases[label];
1493
+ it(`check setPrebidTargeting as ${label}`, function() {
1494
+ const moduleConfig = {
1495
+ params: {
1496
+ weboUserDataConf: {
1497
+ accoundId: 12345,
1498
+ setPrebidTargeting: setPrebidTargeting,
1499
+ sendToBidders: false
1500
+ }
1501
+ }
1502
+ };
1503
+ const data = {
1504
+ webo_cs: ['foo', 'bar'],
1505
+ webo_audiences: ['baz'],
1506
+ };
1507
+
1508
+ const entry = {
1509
+ targeting: data,
1510
+ };
1511
+
1512
+ sandbox.stub(storage, 'localStorageIsEnabled').returns(true);
1513
+ sandbox.stub(storage, 'getDataFromLocalStorage')
1514
+ .withArgs(DEFAULT_LOCAL_STORAGE_USER_PROFILE_KEY)
1515
+ .returns(JSON.stringify(entry));
1516
+
1517
+ const adUnitCode1 = 'adunit1';
1518
+ const adUnitCode2 = 'adunit2';
1519
+ const reqBidsConfigObj = {
1520
+ adUnits: [{
1521
+ code: adUnitCode1,
1522
+ bids: [{
1523
+ bidder: 'smartadserver',
1524
+ params: {
1525
+ target: 'foo=bar'
1526
+ }
1527
+ }, {
1528
+ bidder: 'pubmatic',
1529
+ params: {
1530
+ dctr: 'foo=bar'
1531
+ }
1532
+ }, {
1533
+ bidder: 'appnexus',
1534
+ params: {
1535
+ keywords: {
1536
+ foo: ['bar']
1537
+ }
1538
+ }
1539
+ }, {
1540
+ bidder: 'rubicon',
1541
+ params: {
1542
+ inventory: {
1543
+ foo: 'bar'
1544
+ },
1545
+ visitor: {
1546
+ baz: 'bam'
1547
+ }
1548
+ }
1549
+ }, {
1550
+ bidder: 'other'
1551
+ }]
1552
+ }, {
1553
+ code: adUnitCode2,
1554
+ bids: [{
1555
+ bidder: 'smartadserver',
1556
+ params: {
1557
+ target: 'foo=bar'
1558
+ }
1559
+ }, {
1560
+ bidder: 'pubmatic',
1561
+ params: {
1562
+ dctr: 'foo=bar'
1563
+ }
1564
+ }, {
1565
+ bidder: 'appnexus',
1566
+ params: {
1567
+ keywords: {
1568
+ foo: ['bar']
1569
+ }
1570
+ }
1571
+ }, {
1572
+ bidder: 'rubicon',
1573
+ params: {
1574
+ inventory: {
1575
+ foo: 'bar'
1576
+ },
1577
+ visitor: {
1578
+ baz: 'bam'
1579
+ }
1580
+ }
1581
+ }, {
1582
+ bidder: 'other'
1583
+ }]
1584
+ }]
1585
+ };
1586
+ const onDoneSpy = sinon.spy();
1587
+
1588
+ expect(weboramaSubmodule.init(moduleConfig)).to.be.true;
1589
+ weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig);
1590
+
1591
+ expect(onDoneSpy.calledOnce).to.be.true;
1592
+
1593
+ const targeting = weboramaSubmodule.getTargetingData([adUnitCode1, adUnitCode2], moduleConfig);
1594
+
1595
+ expect(targeting).to.deep.equal({
1596
+ 'adunit1': data,
1597
+ 'adunit2': {},
1598
+ });
1599
+
1600
+ reqBidsConfigObj.adUnits.forEach(adUnit => {
1601
+ expect(adUnit.bids.length).to.equal(5);
1602
+ expect(adUnit.bids[0].params.target).to.equal('foo=bar');
1603
+ expect(adUnit.bids[1].params.dctr).to.equal('foo=bar');
1604
+ expect(adUnit.bids[2].params.keywords).to.deep.equal({
1605
+ foo: ['bar']
1606
+ });
1607
+ expect(adUnit.bids[3].params).to.deep.equal({
1608
+ inventory: {
1609
+ foo: 'bar'
1610
+ },
1611
+ visitor: {
1612
+ baz: 'bam'
1613
+ }
1614
+ });
1615
+ expect(adUnit.bids[4].ortb2).to.be.undefined;
1616
+ });
1617
+ });
1618
+ });
1619
+ });
1620
+
1621
+ it('should set gam targeting but not send to bidders with (submodule override) setPrebidTargeting=true/(global) sendToBidders=false', function() {
1622
+ let onDataResponse = {};
1623
+ const moduleConfig = {
1624
+ params: {
1625
+ setPrebidTargeting: false,
1626
+ sendToBidders: false,
1627
+ onData: (data, meta) => {
690
1628
  onDataResponse = {
691
1629
  data: data,
692
- site: site,
1630
+ meta: meta,
693
1631
  };
694
1632
  },
695
1633
  weboUserDataConf: {
1634
+ accoundId: 12345,
696
1635
  setPrebidTargeting: true, // submodule parameter will override module parameter
697
1636
  }
698
1637
  }
@@ -711,9 +1650,10 @@ describe('weboramaRtdProvider', function () {
711
1650
  .withArgs(DEFAULT_LOCAL_STORAGE_USER_PROFILE_KEY)
712
1651
  .returns(JSON.stringify(entry));
713
1652
 
714
- const adUnitsCodes = ['adunit1', 'adunit2'];
1653
+ const adUnitCode = 'adunit1';
715
1654
  const reqBidsConfigObj = {
716
1655
  adUnits: [{
1656
+ code: adUnitCode,
717
1657
  bids: [{
718
1658
  bidder: 'smartadserver',
719
1659
  params: {
@@ -729,26 +1669,29 @@ describe('weboramaRtdProvider', function () {
729
1669
 
730
1670
  expect(onDoneSpy.calledOnce).to.be.true;
731
1671
 
732
- const targeting = weboramaSubmodule.getTargetingData(adUnitsCodes, moduleConfig);
1672
+ const targeting = weboramaSubmodule.getTargetingData([adUnitCode], moduleConfig);
733
1673
 
734
1674
  expect(targeting).to.deep.equal({
735
1675
  'adunit1': data,
736
- 'adunit2': data,
737
1676
  });
738
1677
 
739
1678
  expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(1);
740
1679
  expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('foo=bar');
741
- expect(getGlobal().getConfig('ortb2')).to.be.undefined;
742
1680
  expect(onDataResponse).to.deep.equal({
743
1681
  data: data,
744
- site: false,
1682
+ meta: {
1683
+ user: true,
1684
+ source: 'wam',
1685
+ isDefault: false,
1686
+ },
745
1687
  });
746
1688
  });
747
1689
 
748
- it('should not set gam targeting with setPrebidTargeting=false but send to bidders', function () {
1690
+ it('should not set gam targeting with setPrebidTargeting=false but send to bidders', function() {
749
1691
  const moduleConfig = {
750
1692
  params: {
751
1693
  weboUserDataConf: {
1694
+ accoundId: 12345,
752
1695
  setPrebidTargeting: false,
753
1696
  }
754
1697
  }
@@ -767,9 +1710,10 @@ describe('weboramaRtdProvider', function () {
767
1710
  .withArgs(DEFAULT_LOCAL_STORAGE_USER_PROFILE_KEY)
768
1711
  .returns(JSON.stringify(entry));
769
1712
 
770
- const adUnitsCodes = ['adunit1', 'adunit2'];
1713
+ const adUnitCode = 'adunit1';
771
1714
  const reqBidsConfigObj = {
772
1715
  adUnits: [{
1716
+ code: adUnitCode,
773
1717
  bids: [{
774
1718
  bidder: 'smartadserver',
775
1719
  params: {
@@ -809,9 +1753,11 @@ describe('weboramaRtdProvider', function () {
809
1753
 
810
1754
  expect(onDoneSpy.calledOnce).to.be.true;
811
1755
 
812
- const targeting = weboramaSubmodule.getTargetingData(adUnitsCodes, moduleConfig);
1756
+ const targeting = weboramaSubmodule.getTargetingData([adUnitCode], moduleConfig);
813
1757
 
814
- expect(targeting).to.deep.equal({});
1758
+ expect(targeting).to.deep.equal({
1759
+ 'adunit1': {},
1760
+ });
815
1761
 
816
1762
  expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5);
817
1763
  expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('foo=bar;webo_cs=foo;webo_cs=bar;webo_audiences=baz');
@@ -838,22 +1784,16 @@ describe('weboramaRtdProvider', function () {
838
1784
  },
839
1785
  }
840
1786
  });
841
- expect(getGlobal().getConfig('ortb2')).to.deep.equal({
842
- user: {
843
- ext: {
844
- data: data
845
- },
846
- }
847
- });
848
1787
  });
849
1788
 
850
- it('should use default profile in case of nothing on local storage', function () {
1789
+ it('should use default profile in case of nothing on local storage', function() {
851
1790
  const defaultProfile = {
852
1791
  webo_audiences: ['baz']
853
1792
  };
854
1793
  const moduleConfig = {
855
1794
  params: {
856
1795
  weboUserDataConf: {
1796
+ accoundId: 12345,
857
1797
  setPrebidTargeting: true,
858
1798
  defaultProfile: defaultProfile,
859
1799
  }
@@ -862,9 +1802,10 @@ describe('weboramaRtdProvider', function () {
862
1802
 
863
1803
  sandbox.stub(storage, 'localStorageIsEnabled').returns(true);
864
1804
 
865
- const adUnitsCodes = ['adunit1', 'adunit2'];
1805
+ const adUnitCode = 'adunit1';
866
1806
  const reqBidsConfigObj = {
867
1807
  adUnits: [{
1808
+ code: adUnitCode,
868
1809
  bids: [{
869
1810
  bidder: 'smartadserver'
870
1811
  }, {
@@ -885,11 +1826,10 @@ describe('weboramaRtdProvider', function () {
885
1826
 
886
1827
  expect(onDoneSpy.calledOnce).to.be.true;
887
1828
 
888
- const targeting = weboramaSubmodule.getTargetingData(adUnitsCodes, moduleConfig);
1829
+ const targeting = weboramaSubmodule.getTargetingData([adUnitCode], moduleConfig);
889
1830
 
890
1831
  expect(targeting).to.deep.equal({
891
1832
  'adunit1': defaultProfile,
892
- 'adunit2': defaultProfile,
893
1833
  });
894
1834
 
895
1835
  expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5);
@@ -906,16 +1846,9 @@ describe('weboramaRtdProvider', function () {
906
1846
  },
907
1847
  }
908
1848
  });
909
- expect(getGlobal().getConfig('ortb2')).to.deep.equal({
910
- user: {
911
- ext: {
912
- data: defaultProfile
913
- },
914
- }
915
- });
916
1849
  });
917
1850
 
918
- it('should use default profile if cant read from local storage', function () {
1851
+ it('should use default profile if cant read from local storage', function() {
919
1852
  const defaultProfile = {
920
1853
  webo_audiences: ['baz']
921
1854
  };
@@ -923,12 +1856,13 @@ describe('weboramaRtdProvider', function () {
923
1856
  const moduleConfig = {
924
1857
  params: {
925
1858
  weboUserDataConf: {
1859
+ accoundId: 12345,
926
1860
  setPrebidTargeting: true,
927
1861
  defaultProfile: defaultProfile,
928
- onData: (data, site) => {
1862
+ onData: (data, meta) => {
929
1863
  onDataResponse = {
930
1864
  data: data,
931
- site: site,
1865
+ meta: meta,
932
1866
  };
933
1867
  },
934
1868
  }
@@ -937,9 +1871,10 @@ describe('weboramaRtdProvider', function () {
937
1871
 
938
1872
  sandbox.stub(storage, 'localStorageIsEnabled').returns(false);
939
1873
 
940
- const adUnitsCodes = ['adunit1', 'adunit2'];
1874
+ const adUnitCode = 'adunit1';
941
1875
  const reqBidsConfigObj = {
942
1876
  adUnits: [{
1877
+ code: adUnitCode,
943
1878
  bids: [{
944
1879
  bidder: 'smartadserver'
945
1880
  }, {
@@ -960,11 +1895,10 @@ describe('weboramaRtdProvider', function () {
960
1895
 
961
1896
  expect(onDoneSpy.calledOnce).to.be.true;
962
1897
 
963
- const targeting = weboramaSubmodule.getTargetingData(adUnitsCodes, moduleConfig);
1898
+ const targeting = weboramaSubmodule.getTargetingData([adUnitCode], moduleConfig);
964
1899
 
965
1900
  expect(targeting).to.deep.equal({
966
1901
  'adunit1': defaultProfile,
967
- 'adunit2': defaultProfile,
968
1902
  });
969
1903
 
970
1904
  expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5);
@@ -981,16 +1915,1149 @@ describe('weboramaRtdProvider', function () {
981
1915
  },
982
1916
  }
983
1917
  });
984
- expect(getGlobal().getConfig('ortb2')).to.deep.equal({
985
- user: {
1918
+ expect(onDataResponse).to.deep.equal({
1919
+ data: defaultProfile,
1920
+ meta: {
1921
+ user: true,
1922
+ source: 'wam',
1923
+ isDefault: true,
1924
+ },
1925
+ });
1926
+ });
1927
+
1928
+ it('should be possible update profile from callbacks for a given bidder/adUnitCode', function() {
1929
+ let onDataResponse = {};
1930
+ const moduleConfig = {
1931
+ params: {
1932
+ weboUserDataConf: {
1933
+ accoundId: 12345,
1934
+ targetURL: 'https://prebid.org',
1935
+ setPrebidTargeting: (adUnitCode, data, meta) => {
1936
+ if (adUnitCode == 'adunit1') {
1937
+ data['webo_foo'] = ['bar'];
1938
+ }
1939
+ return true;
1940
+ },
1941
+ sendToBidders: (bid, adUnitCode, data, meta) => {
1942
+ if (bid.bidder == 'appnexus' && adUnitCode == 'adunit1') {
1943
+ data['webo_bar'] = ['baz'];
1944
+ }
1945
+ return true;
1946
+ },
1947
+ onData: (data, meta) => {
1948
+ onDataResponse = {
1949
+ data: data,
1950
+ meta: meta,
1951
+ };
1952
+ },
1953
+ }
1954
+ }
1955
+ };
1956
+ const data = {
1957
+ webo_cs: ['foo', 'bar'],
1958
+ webo_audiences: ['baz'],
1959
+ };
1960
+
1961
+ const entry = {
1962
+ targeting: data,
1963
+ };
1964
+
1965
+ sandbox.stub(storage, 'localStorageIsEnabled').returns(true);
1966
+ sandbox.stub(storage, 'getDataFromLocalStorage')
1967
+ .withArgs(DEFAULT_LOCAL_STORAGE_USER_PROFILE_KEY)
1968
+ .returns(JSON.stringify(entry));
1969
+
1970
+ const adUnitCode1 = 'adunit1';
1971
+ const adUnitCode2 = 'adunit2';
1972
+ const reqBidsConfigObj = {
1973
+ adUnits: [{
1974
+ code: adUnitCode1,
1975
+ bids: [{
1976
+ bidder: 'smartadserver'
1977
+ }, {
1978
+ bidder: 'pubmatic'
1979
+ }, {
1980
+ bidder: 'appnexus'
1981
+ }, {
1982
+ bidder: 'rubicon'
1983
+ }, {
1984
+ bidder: 'other'
1985
+ }]
1986
+ }, {
1987
+ code: adUnitCode2,
1988
+ bids: [{
1989
+ bidder: 'smartadserver'
1990
+ }, {
1991
+ bidder: 'pubmatic'
1992
+ }, {
1993
+ bidder: 'appnexus'
1994
+ }, {
1995
+ bidder: 'rubicon'
1996
+ }, {
1997
+ bidder: 'other'
1998
+ }]
1999
+ }]
2000
+ };
2001
+
2002
+ const onDoneSpy = sinon.spy();
2003
+
2004
+ expect(weboramaSubmodule.init(moduleConfig)).to.be.true;
2005
+ weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig);
2006
+
2007
+ expect(onDoneSpy.calledOnce).to.be.true;
2008
+
2009
+ const targeting = weboramaSubmodule.getTargetingData([adUnitCode1, adUnitCode2], moduleConfig);
2010
+
2011
+ expect(targeting).to.deep.equal({
2012
+ 'adunit1': {
2013
+ webo_cs: ['foo', 'bar'],
2014
+ webo_audiences: ['baz'],
2015
+ webo_foo: ['bar'],
2016
+ },
2017
+ 'adunit2': data,
2018
+ });
2019
+
2020
+ reqBidsConfigObj.adUnits.forEach(adUnit => {
2021
+ expect(adUnit.bids.length).to.equal(5);
2022
+ expect(adUnit.bids[0].params.target).to.equal('webo_cs=foo;webo_cs=bar;webo_audiences=baz');
2023
+ expect(adUnit.bids[1].params.dctr).to.equal('webo_cs=foo,bar|webo_audiences=baz');
2024
+ expect(adUnit.bids[3].params).to.deep.equal({
2025
+ visitor: data
2026
+ });
2027
+ expect(adUnit.bids[4].ortb2).to.deep.equal({
2028
+ user: {
2029
+ ext: {
2030
+ data: data
2031
+ },
2032
+ }
2033
+ });
2034
+ });
2035
+
2036
+ expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal({
2037
+ webo_cs: ['foo', 'bar'],
2038
+ webo_audiences: ['baz'],
2039
+ webo_bar: ['baz'],
2040
+ });
2041
+ expect(reqBidsConfigObj.adUnits[1].bids[2].params.keywords).to.deep.equal(data);
2042
+
2043
+ expect(onDataResponse).to.deep.equal({
2044
+ data: data,
2045
+ meta: {
2046
+ user: true,
2047
+ source: 'wam',
2048
+ isDefault: false,
2049
+ },
2050
+ });
2051
+ });
2052
+ });
2053
+
2054
+ describe('Add support to sfbx lite', function() {
2055
+ it('should set gam targeting from local storage and send to bidders by default', function() {
2056
+ let onDataResponse = {};
2057
+ const moduleConfig = {
2058
+ params: {
2059
+ sfbxLiteDataConf: {
2060
+ onData: (data, meta) => {
2061
+ onDataResponse = {
2062
+ data: data,
2063
+ meta: meta,
2064
+ };
2065
+ },
2066
+ }
2067
+ }
2068
+ };
2069
+ const data = {
2070
+ lite_occupation: ['gérant', 'bénévole'],
2071
+ lite_hobbies: ['sport', 'cinéma'],
2072
+ };
2073
+
2074
+ const entry = {
2075
+ webo: data,
2076
+ };
2077
+
2078
+ sandbox.stub(storage, 'localStorageIsEnabled').returns(true);
2079
+ sandbox.stub(storage, 'getDataFromLocalStorage')
2080
+ .withArgs(DEFAULT_LOCAL_STORAGE_LITE_PROFILE_KEY)
2081
+ .returns(JSON.stringify(entry));
2082
+
2083
+ const adUnitCode = 'adunit1';
2084
+ const reqBidsConfigObj = {
2085
+ adUnits: [{
2086
+ code: adUnitCode,
2087
+ bids: [{
2088
+ bidder: 'smartadserver'
2089
+ }, {
2090
+ bidder: 'pubmatic'
2091
+ }, {
2092
+ bidder: 'appnexus'
2093
+ }, {
2094
+ bidder: 'rubicon'
2095
+ }, {
2096
+ bidder: 'other'
2097
+ }]
2098
+ }]
2099
+ };
2100
+ const onDoneSpy = sinon.spy();
2101
+
2102
+ expect(weboramaSubmodule.init(moduleConfig)).to.be.true;
2103
+ weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig);
2104
+
2105
+ expect(onDoneSpy.calledOnce).to.be.true;
2106
+
2107
+ const targeting = weboramaSubmodule.getTargetingData([adUnitCode], moduleConfig);
2108
+
2109
+ expect(targeting).to.deep.equal({
2110
+ 'adunit1': data,
2111
+ });
2112
+
2113
+ expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5);
2114
+ expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('lite_occupation=gérant;lite_occupation=bénévole;lite_hobbies=sport;lite_hobbies=cinéma');
2115
+ expect(reqBidsConfigObj.adUnits[0].bids[1].params.dctr).to.equal('lite_occupation=gérant,bénévole|lite_hobbies=sport,cinéma');
2116
+ expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal(data);
2117
+ expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.deep.equal({
2118
+ inventory: data,
2119
+ });
2120
+ expect(reqBidsConfigObj.adUnits[0].bids[4].ortb2).to.deep.equal({
2121
+ site: {
986
2122
  ext: {
987
- data: defaultProfile
2123
+ data: data,
988
2124
  },
989
- }
2125
+ },
990
2126
  });
991
2127
  expect(onDataResponse).to.deep.equal({
992
- data: defaultProfile,
993
- site: false,
2128
+ data: data,
2129
+ meta: {
2130
+ user: false,
2131
+ source: 'lite',
2132
+ isDefault: false,
2133
+ },
2134
+ });
2135
+ });
2136
+
2137
+ describe('should set gam targeting from local storage and send to one specific bidder and multiple adunits', function() {
2138
+ const testcases = {
2139
+ 'single string': 'appnexus',
2140
+ 'array with one entry': ['appnexus'],
2141
+ 'map with one entry': {
2142
+ 'appnexus': true
2143
+ },
2144
+ 'map complete': {
2145
+ 'smartadserver': false,
2146
+ 'pubmatic': false,
2147
+ 'appnexus': true,
2148
+ 'rubicon': false,
2149
+ 'other': false,
2150
+ },
2151
+ 'callback': (bid) => {
2152
+ return bid.bidder == 'appnexus'
2153
+ },
2154
+ };
2155
+
2156
+ Object.keys(testcases).forEach(label => {
2157
+ const sendToBidders = testcases[label];
2158
+ it(`check sendToBidders as ${label}`, function() {
2159
+ let onDataResponse = {};
2160
+ const moduleConfig = {
2161
+ params: {
2162
+ sfbxLiteDataConf: {
2163
+ sendToBidders: sendToBidders,
2164
+ onData: (data, meta) => {
2165
+ onDataResponse = {
2166
+ data: data,
2167
+ meta: meta,
2168
+ };
2169
+ },
2170
+ }
2171
+ }
2172
+ };
2173
+ const data = {
2174
+ lite_occupation: ['gérant', 'bénévole'],
2175
+ lite_hobbies: ['sport', 'cinéma'],
2176
+ };
2177
+
2178
+ const entry = {
2179
+ webo: data,
2180
+ };
2181
+
2182
+ sandbox.stub(storage, 'localStorageIsEnabled').returns(true);
2183
+ sandbox.stub(storage, 'getDataFromLocalStorage')
2184
+ .withArgs(DEFAULT_LOCAL_STORAGE_LITE_PROFILE_KEY)
2185
+ .returns(JSON.stringify(entry));
2186
+
2187
+ const adUnitCode1 = 'adunit1';
2188
+ const adUnitCode2 = 'adunit2';
2189
+ const reqBidsConfigObj = {
2190
+ adUnits: [{
2191
+ code: adUnitCode1,
2192
+ bids: [{
2193
+ bidder: 'smartadserver'
2194
+ }, {
2195
+ bidder: 'pubmatic'
2196
+ }, {
2197
+ bidder: 'appnexus'
2198
+ }, {
2199
+ bidder: 'rubicon'
2200
+ }, {
2201
+ bidder: 'other'
2202
+ }]
2203
+ }, {
2204
+ code: adUnitCode2,
2205
+ bids: [{
2206
+ bidder: 'smartadserver'
2207
+ }, {
2208
+ bidder: 'pubmatic'
2209
+ }, {
2210
+ bidder: 'appnexus'
2211
+ }, {
2212
+ bidder: 'rubicon'
2213
+ }, {
2214
+ bidder: 'other'
2215
+ }]
2216
+ }]
2217
+ };
2218
+ const onDoneSpy = sinon.spy();
2219
+
2220
+ expect(weboramaSubmodule.init(moduleConfig)).to.be.true;
2221
+ weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig);
2222
+
2223
+ expect(onDoneSpy.calledOnce).to.be.true;
2224
+
2225
+ const targeting = weboramaSubmodule.getTargetingData([adUnitCode1, adUnitCode2], moduleConfig);
2226
+
2227
+ expect(targeting).to.deep.equal({
2228
+ 'adunit1': data,
2229
+ 'adunit2': data,
2230
+ });
2231
+
2232
+ reqBidsConfigObj.adUnits.forEach(adUnit => {
2233
+ expect(adUnit.bids.length).to.equal(5);
2234
+ expect(adUnit.bids[0].params).to.be.undefined;
2235
+ expect(adUnit.bids[1].params).to.be.undefined;
2236
+ expect(adUnit.bids[2].params.keywords).to.deep.equal(data);
2237
+ expect(adUnit.bids[3].params).to.be.undefined;
2238
+ expect(adUnit.bids[4].ortb2).to.be.undefined;
2239
+ });
2240
+
2241
+ expect(onDataResponse).to.deep.equal({
2242
+ data: data,
2243
+ meta: {
2244
+ user: false,
2245
+ source: 'lite',
2246
+ isDefault: false,
2247
+ },
2248
+ });
2249
+ });
2250
+ });
2251
+ });
2252
+
2253
+ describe('should set gam targeting from local storage and send to one specific bidder and one adunit', function() {
2254
+ const testcases = {
2255
+ 'map with one entry': {
2256
+ 'appnexus': ['adunit1']
2257
+ },
2258
+ 'callback': (bid, adUnitCode) => {
2259
+ return bid.bidder == 'appnexus' && adUnitCode == 'adunit1';
2260
+ },
2261
+ };
2262
+
2263
+ Object.keys(testcases).forEach(label => {
2264
+ const sendToBidders = testcases[label];
2265
+ it(`check sendToBidders as ${label}`, function() {
2266
+ let onDataResponse = {};
2267
+ const moduleConfig = {
2268
+ params: {
2269
+ sfbxLiteDataConf: {
2270
+ sendToBidders: sendToBidders,
2271
+ onData: (data, meta) => {
2272
+ onDataResponse = {
2273
+ data: data,
2274
+ meta: meta,
2275
+ };
2276
+ },
2277
+ }
2278
+ }
2279
+ };
2280
+ const data = {
2281
+ lite_occupation: ['gérant', 'bénévole'],
2282
+ lite_hobbies: ['sport', 'cinéma'],
2283
+ };
2284
+
2285
+ const entry = {
2286
+ webo: data,
2287
+ };
2288
+
2289
+ sandbox.stub(storage, 'localStorageIsEnabled').returns(true);
2290
+ sandbox.stub(storage, 'getDataFromLocalStorage')
2291
+ .withArgs(DEFAULT_LOCAL_STORAGE_LITE_PROFILE_KEY)
2292
+ .returns(JSON.stringify(entry));
2293
+
2294
+ const adUnitCode1 = 'adunit1';
2295
+ const adUnitCode2 = 'adunit2';
2296
+ const reqBidsConfigObj = {
2297
+ adUnits: [{
2298
+ code: adUnitCode1,
2299
+ bids: [{
2300
+ bidder: 'smartadserver'
2301
+ }, {
2302
+ bidder: 'pubmatic'
2303
+ }, {
2304
+ bidder: 'appnexus'
2305
+ }, {
2306
+ bidder: 'rubicon'
2307
+ }, {
2308
+ bidder: 'other'
2309
+ }]
2310
+ }, {
2311
+ code: adUnitCode2,
2312
+ bids: [{
2313
+ bidder: 'smartadserver'
2314
+ }, {
2315
+ bidder: 'pubmatic'
2316
+ }, {
2317
+ bidder: 'appnexus'
2318
+ }, {
2319
+ bidder: 'rubicon'
2320
+ }, {
2321
+ bidder: 'other'
2322
+ }]
2323
+ }]
2324
+ };
2325
+ const onDoneSpy = sinon.spy();
2326
+
2327
+ expect(weboramaSubmodule.init(moduleConfig)).to.be.true;
2328
+ weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig);
2329
+
2330
+ expect(onDoneSpy.calledOnce).to.be.true;
2331
+
2332
+ const targeting = weboramaSubmodule.getTargetingData([adUnitCode1, adUnitCode2], moduleConfig);
2333
+
2334
+ expect(targeting).to.deep.equal({
2335
+ 'adunit1': data,
2336
+ 'adunit2': data,
2337
+ });
2338
+
2339
+ reqBidsConfigObj.adUnits.forEach(adUnit => {
2340
+ expect(adUnit.bids.length).to.equal(5);
2341
+ expect(adUnit.bids[0].params).to.be.undefined;
2342
+ expect(adUnit.bids[1].params).to.be.undefined;
2343
+ expect(adUnit.bids[3].params).to.be.undefined;
2344
+ expect(adUnit.bids[4].ortb2).to.be.undefined;
2345
+ });
2346
+
2347
+ expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal(data);
2348
+ expect(reqBidsConfigObj.adUnits[1].bids[2].params).to.be.undefined;
2349
+
2350
+ expect(onDataResponse).to.deep.equal({
2351
+ data: data,
2352
+ meta: {
2353
+ user: false,
2354
+ source: 'lite',
2355
+ isDefault: false,
2356
+ },
2357
+ });
2358
+ });
2359
+ });
2360
+ });
2361
+
2362
+ describe('should set gam targeting for multiple adunits but not send to bidders with setPrebidTargeting=<true>/sendToBidders=false', function() {
2363
+ const testcases = {
2364
+ 'boolean': true,
2365
+ 'array with both units': ['adunit1', 'adunit2'],
2366
+ 'callback': () => {
2367
+ return true;
2368
+ },
2369
+ };
2370
+
2371
+ Object.keys(testcases).forEach(label => {
2372
+ const setPrebidTargeting = testcases[label];
2373
+ it(`check setPrebidTargeting as ${label}`, function() {
2374
+ const moduleConfig = {
2375
+ params: {
2376
+ sfbxLiteDataConf: {
2377
+ setPrebidTargeting: setPrebidTargeting,
2378
+ sendToBidders: false
2379
+ }
2380
+ }
2381
+ };
2382
+ const data = {
2383
+ lite_occupation: ['gérant', 'bénévole'],
2384
+ lite_hobbies: ['sport', 'cinéma'],
2385
+ };
2386
+
2387
+ const entry = {
2388
+ webo: data,
2389
+ };
2390
+
2391
+ sandbox.stub(storage, 'localStorageIsEnabled').returns(true);
2392
+ sandbox.stub(storage, 'getDataFromLocalStorage')
2393
+ .withArgs(DEFAULT_LOCAL_STORAGE_LITE_PROFILE_KEY)
2394
+ .returns(JSON.stringify(entry));
2395
+
2396
+ const adUnitCode1 = 'adunit1';
2397
+ const adUnitCode2 = 'adunit2';
2398
+ const reqBidsConfigObj = {
2399
+ adUnits: [{
2400
+ code: adUnitCode1,
2401
+ bids: [{
2402
+ bidder: 'smartadserver',
2403
+ params: {
2404
+ target: 'foo=bar'
2405
+ }
2406
+ }, {
2407
+ bidder: 'pubmatic',
2408
+ params: {
2409
+ dctr: 'foo=bar'
2410
+ }
2411
+ }, {
2412
+ bidder: 'appnexus',
2413
+ params: {
2414
+ keywords: {
2415
+ foo: ['bar']
2416
+ }
2417
+ }
2418
+ }, {
2419
+ bidder: 'rubicon',
2420
+ params: {
2421
+ inventory: {
2422
+ foo: 'bar'
2423
+ },
2424
+ visitor: {
2425
+ baz: 'bam'
2426
+ }
2427
+ }
2428
+ }, {
2429
+ bidder: 'other'
2430
+ }]
2431
+ }, {
2432
+ code: adUnitCode2,
2433
+ bids: [{
2434
+ bidder: 'smartadserver',
2435
+ params: {
2436
+ target: 'foo=bar'
2437
+ }
2438
+ }, {
2439
+ bidder: 'pubmatic',
2440
+ params: {
2441
+ dctr: 'foo=bar'
2442
+ }
2443
+ }, {
2444
+ bidder: 'appnexus',
2445
+ params: {
2446
+ keywords: {
2447
+ foo: ['bar']
2448
+ }
2449
+ }
2450
+ }, {
2451
+ bidder: 'rubicon',
2452
+ params: {
2453
+ inventory: {
2454
+ foo: 'bar'
2455
+ },
2456
+ visitor: {
2457
+ baz: 'bam'
2458
+ }
2459
+ }
2460
+ }, {
2461
+ bidder: 'other'
2462
+ }]
2463
+ }]
2464
+ };
2465
+ const onDoneSpy = sinon.spy();
2466
+
2467
+ expect(weboramaSubmodule.init(moduleConfig)).to.be.true;
2468
+ weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig);
2469
+
2470
+ expect(onDoneSpy.calledOnce).to.be.true;
2471
+
2472
+ const targeting = weboramaSubmodule.getTargetingData([adUnitCode1, adUnitCode2], moduleConfig);
2473
+
2474
+ expect(targeting).to.deep.equal({
2475
+ 'adunit1': data,
2476
+ 'adunit2': data,
2477
+ });
2478
+
2479
+ reqBidsConfigObj.adUnits.forEach(adUnit => {
2480
+ expect(adUnit.bids.length).to.equal(5);
2481
+ expect(adUnit.bids[0].params.target).to.equal('foo=bar');
2482
+ expect(adUnit.bids[1].params.dctr).to.equal('foo=bar');
2483
+ expect(adUnit.bids[2].params.keywords).to.deep.equal({
2484
+ foo: ['bar']
2485
+ });
2486
+ expect(adUnit.bids[3].params).to.deep.equal({
2487
+ inventory: {
2488
+ foo: 'bar'
2489
+ },
2490
+ visitor: {
2491
+ baz: 'bam'
2492
+ }
2493
+ });
2494
+ expect(adUnit.bids[4].ortb2).to.be.undefined;
2495
+ });
2496
+ });
2497
+ });
2498
+ });
2499
+
2500
+ describe('should set gam targeting for one adunit but not send to bidders with setPrebidTargeting=<true>/sendToBidders=false', function() {
2501
+ const testcases = {
2502
+ 'array with one unit': ['adunit1'],
2503
+ 'callback': (adUnitCode) => {
2504
+ return adUnitCode == 'adunit1';
2505
+ },
2506
+ };
2507
+
2508
+ Object.keys(testcases).forEach(label => {
2509
+ const setPrebidTargeting = testcases[label];
2510
+ it(`check setPrebidTargeting as ${label}`, function() {
2511
+ const moduleConfig = {
2512
+ params: {
2513
+ sfbxLiteDataConf: {
2514
+ setPrebidTargeting: setPrebidTargeting,
2515
+ sendToBidders: false
2516
+ }
2517
+ }
2518
+ };
2519
+ const data = {
2520
+ lite_occupation: ['gérant', 'bénévole'],
2521
+ lite_hobbies: ['sport', 'cinéma'],
2522
+ };
2523
+
2524
+ const entry = {
2525
+ webo: data,
2526
+ };
2527
+
2528
+ sandbox.stub(storage, 'localStorageIsEnabled').returns(true);
2529
+ sandbox.stub(storage, 'getDataFromLocalStorage')
2530
+ .withArgs(DEFAULT_LOCAL_STORAGE_LITE_PROFILE_KEY)
2531
+ .returns(JSON.stringify(entry));
2532
+
2533
+ const adUnitCode1 = 'adunit1';
2534
+ const adUnitCode2 = 'adunit2';
2535
+ const reqBidsConfigObj = {
2536
+ adUnits: [{
2537
+ code: adUnitCode1,
2538
+ bids: [{
2539
+ bidder: 'smartadserver',
2540
+ params: {
2541
+ target: 'foo=bar'
2542
+ }
2543
+ }, {
2544
+ bidder: 'pubmatic',
2545
+ params: {
2546
+ dctr: 'foo=bar'
2547
+ }
2548
+ }, {
2549
+ bidder: 'appnexus',
2550
+ params: {
2551
+ keywords: {
2552
+ foo: ['bar']
2553
+ }
2554
+ }
2555
+ }, {
2556
+ bidder: 'rubicon',
2557
+ params: {
2558
+ inventory: {
2559
+ foo: 'bar'
2560
+ },
2561
+ visitor: {
2562
+ baz: 'bam'
2563
+ }
2564
+ }
2565
+ }, {
2566
+ bidder: 'other'
2567
+ }]
2568
+ }, {
2569
+ code: adUnitCode2,
2570
+ bids: [{
2571
+ bidder: 'smartadserver',
2572
+ params: {
2573
+ target: 'foo=bar'
2574
+ }
2575
+ }, {
2576
+ bidder: 'pubmatic',
2577
+ params: {
2578
+ dctr: 'foo=bar'
2579
+ }
2580
+ }, {
2581
+ bidder: 'appnexus',
2582
+ params: {
2583
+ keywords: {
2584
+ foo: ['bar']
2585
+ }
2586
+ }
2587
+ }, {
2588
+ bidder: 'rubicon',
2589
+ params: {
2590
+ inventory: {
2591
+ foo: 'bar'
2592
+ },
2593
+ visitor: {
2594
+ baz: 'bam'
2595
+ }
2596
+ }
2597
+ }, {
2598
+ bidder: 'other'
2599
+ }]
2600
+ }]
2601
+ };
2602
+ const onDoneSpy = sinon.spy();
2603
+
2604
+ expect(weboramaSubmodule.init(moduleConfig)).to.be.true;
2605
+ weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig);
2606
+
2607
+ expect(onDoneSpy.calledOnce).to.be.true;
2608
+
2609
+ const targeting = weboramaSubmodule.getTargetingData([adUnitCode1, adUnitCode2], moduleConfig);
2610
+
2611
+ expect(targeting).to.deep.equal({
2612
+ 'adunit1': data,
2613
+ 'adunit2': {},
2614
+ });
2615
+
2616
+ reqBidsConfigObj.adUnits.forEach(adUnit => {
2617
+ expect(adUnit.bids.length).to.equal(5);
2618
+ expect(adUnit.bids[0].params.target).to.equal('foo=bar');
2619
+ expect(adUnit.bids[1].params.dctr).to.equal('foo=bar');
2620
+ expect(adUnit.bids[2].params.keywords).to.deep.equal({
2621
+ foo: ['bar']
2622
+ });
2623
+ expect(adUnit.bids[3].params).to.deep.equal({
2624
+ inventory: {
2625
+ foo: 'bar'
2626
+ },
2627
+ visitor: {
2628
+ baz: 'bam'
2629
+ }
2630
+ });
2631
+ expect(adUnit.bids[4].ortb2).to.be.undefined;
2632
+ });
2633
+ });
2634
+ });
2635
+ });
2636
+
2637
+ it('should set gam targeting but not send to bidders with (submodule override) setPrebidTargeting=true/(global) sendToBidders=false', function() {
2638
+ let onDataResponse = {};
2639
+ const moduleConfig = {
2640
+ params: {
2641
+ setPrebidTargeting: false,
2642
+ sendToBidders: false,
2643
+ onData: (data, meta) => {
2644
+ onDataResponse = {
2645
+ data: data,
2646
+ meta: meta,
2647
+ };
2648
+ },
2649
+ sfbxLiteDataConf: {
2650
+ setPrebidTargeting: true, // submodule parameter will override module parameter
2651
+ }
2652
+ }
2653
+ };
2654
+ const data = {
2655
+ lite_occupation: ['gérant', 'bénévole'],
2656
+ lite_hobbies: ['sport', 'cinéma'],
2657
+ };
2658
+
2659
+ const entry = {
2660
+ webo: data,
2661
+ };
2662
+
2663
+ sandbox.stub(storage, 'localStorageIsEnabled').returns(true);
2664
+ sandbox.stub(storage, 'getDataFromLocalStorage')
2665
+ .withArgs(DEFAULT_LOCAL_STORAGE_LITE_PROFILE_KEY)
2666
+ .returns(JSON.stringify(entry));
2667
+
2668
+ const adUnitCode = 'adunit1';
2669
+ const reqBidsConfigObj = {
2670
+ adUnits: [{
2671
+ code: adUnitCode,
2672
+ bids: [{
2673
+ bidder: 'smartadserver',
2674
+ params: {
2675
+ target: 'foo=bar'
2676
+ }
2677
+ }]
2678
+ }]
2679
+ };
2680
+ const onDoneSpy = sinon.spy();
2681
+
2682
+ expect(weboramaSubmodule.init(moduleConfig)).to.be.true;
2683
+ weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig);
2684
+
2685
+ expect(onDoneSpy.calledOnce).to.be.true;
2686
+
2687
+ const targeting = weboramaSubmodule.getTargetingData([adUnitCode], moduleConfig);
2688
+
2689
+ expect(targeting).to.deep.equal({
2690
+ 'adunit1': data,
2691
+ });
2692
+
2693
+ expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(1);
2694
+ expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('foo=bar');
2695
+ expect(onDataResponse).to.deep.equal({
2696
+ data: data,
2697
+ meta: {
2698
+ user: false,
2699
+ source: 'lite',
2700
+ isDefault: false,
2701
+ },
2702
+ });
2703
+ });
2704
+
2705
+ it('should not set gam targeting with setPrebidTargeting=false but send to bidders', function() {
2706
+ const moduleConfig = {
2707
+ params: {
2708
+ sfbxLiteDataConf: {
2709
+ setPrebidTargeting: false,
2710
+ }
2711
+ }
2712
+ };
2713
+ const data = {
2714
+ lite_occupation: ['gérant', 'bénévole'],
2715
+ lite_hobbies: ['sport', 'cinéma'],
2716
+ };
2717
+
2718
+ const entry = {
2719
+ webo: data,
2720
+ };
2721
+
2722
+ sandbox.stub(storage, 'localStorageIsEnabled').returns(true);
2723
+ sandbox.stub(storage, 'getDataFromLocalStorage')
2724
+ .withArgs(DEFAULT_LOCAL_STORAGE_LITE_PROFILE_KEY)
2725
+ .returns(JSON.stringify(entry));
2726
+
2727
+ const adUnitCode = 'adunit1';
2728
+ const reqBidsConfigObj = {
2729
+ adUnits: [{
2730
+ code: adUnitCode,
2731
+ bids: [{
2732
+ bidder: 'smartadserver',
2733
+ params: {
2734
+ target: 'foo=bar'
2735
+ }
2736
+ }, {
2737
+ bidder: 'pubmatic',
2738
+ params: {
2739
+ dctr: 'foo=bar'
2740
+ }
2741
+ }, {
2742
+ bidder: 'appnexus',
2743
+ params: {
2744
+ keywords: {
2745
+ foo: ['bar']
2746
+ }
2747
+ }
2748
+ }, {
2749
+ bidder: 'rubicon',
2750
+ params: {
2751
+ inventory: {
2752
+ foo: 'bar',
2753
+ },
2754
+ visitor: {
2755
+ baz: 'bam',
2756
+ }
2757
+ }
2758
+ }, {
2759
+ bidder: 'other'
2760
+ }]
2761
+ }]
2762
+ };
2763
+ const onDoneSpy = sinon.spy();
2764
+
2765
+ expect(weboramaSubmodule.init(moduleConfig)).to.be.true;
2766
+ weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig);
2767
+
2768
+ expect(onDoneSpy.calledOnce).to.be.true;
2769
+
2770
+ const targeting = weboramaSubmodule.getTargetingData([adUnitCode], moduleConfig);
2771
+
2772
+ expect(targeting).to.deep.equal({
2773
+ 'adunit1': {},
2774
+ });
2775
+
2776
+ expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5);
2777
+ expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('foo=bar;lite_occupation=gérant;lite_occupation=bénévole;lite_hobbies=sport;lite_hobbies=cinéma');
2778
+ expect(reqBidsConfigObj.adUnits[0].bids[1].params.dctr).to.equal('foo=bar|lite_occupation=gérant,bénévole|lite_hobbies=sport,cinéma');
2779
+ expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal({
2780
+ foo: ['bar'],
2781
+ lite_occupation: ['gérant', 'bénévole'],
2782
+ lite_hobbies: ['sport', 'cinéma'],
2783
+ });
2784
+ expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.deep.equal({
2785
+ inventory: {
2786
+ foo: 'bar',
2787
+ lite_occupation: ['gérant', 'bénévole'],
2788
+ lite_hobbies: ['sport', 'cinéma'],
2789
+ },
2790
+ visitor: {
2791
+ baz: 'bam',
2792
+ }
2793
+ });
2794
+ expect(reqBidsConfigObj.adUnits[0].bids[4].ortb2).to.deep.equal({
2795
+ site: {
2796
+ ext: {
2797
+ data: data,
2798
+ },
2799
+ },
2800
+ });
2801
+ });
2802
+
2803
+ it('should use default profile in case of nothing on local storage', function() {
2804
+ const defaultProfile = {
2805
+ lite_hobbies: ['sport', 'cinéma'],
2806
+ };
2807
+ const moduleConfig = {
2808
+ params: {
2809
+ sfbxLiteDataConf: {
2810
+ setPrebidTargeting: true,
2811
+ defaultProfile: defaultProfile,
2812
+ }
2813
+ }
2814
+ };
2815
+
2816
+ sandbox.stub(storage, 'localStorageIsEnabled').returns(true);
2817
+
2818
+ const adUnitCode = 'adunit1';
2819
+ const reqBidsConfigObj = {
2820
+ adUnits: [{
2821
+ code: adUnitCode,
2822
+ bids: [{
2823
+ bidder: 'smartadserver'
2824
+ }, {
2825
+ bidder: 'pubmatic'
2826
+ }, {
2827
+ bidder: 'appnexus'
2828
+ }, {
2829
+ bidder: 'rubicon'
2830
+ }, {
2831
+ bidder: 'other'
2832
+ }]
2833
+ }]
2834
+ };
2835
+ const onDoneSpy = sinon.spy();
2836
+
2837
+ expect(weboramaSubmodule.init(moduleConfig)).to.be.true;
2838
+ weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig);
2839
+
2840
+ expect(onDoneSpy.calledOnce).to.be.true;
2841
+
2842
+ const targeting = weboramaSubmodule.getTargetingData([adUnitCode], moduleConfig);
2843
+
2844
+ expect(targeting).to.deep.equal({
2845
+ 'adunit1': defaultProfile,
2846
+ });
2847
+
2848
+ expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5);
2849
+ expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('lite_hobbies=sport;lite_hobbies=cinéma');
2850
+ expect(reqBidsConfigObj.adUnits[0].bids[1].params.dctr).to.equal('lite_hobbies=sport,cinéma');
2851
+ expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal(defaultProfile);
2852
+ expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.deep.equal({
2853
+ inventory: defaultProfile,
2854
+ });
2855
+ expect(reqBidsConfigObj.adUnits[0].bids[4].ortb2).to.deep.equal({
2856
+ site: {
2857
+ ext: {
2858
+ data: defaultProfile,
2859
+ },
2860
+ },
2861
+ });
2862
+ });
2863
+
2864
+ it('should use default profile if cant read from local storage', function() {
2865
+ const defaultProfile = {
2866
+ lite_hobbies: ['sport', 'cinéma'],
2867
+ };
2868
+ let onDataResponse = {};
2869
+ const moduleConfig = {
2870
+ params: {
2871
+ sfbxLiteDataConf: {
2872
+ setPrebidTargeting: true,
2873
+ defaultProfile: defaultProfile,
2874
+ onData: (data, meta) => {
2875
+ onDataResponse = {
2876
+ data: data,
2877
+ meta: meta,
2878
+ };
2879
+ },
2880
+ }
2881
+ }
2882
+ };
2883
+
2884
+ sandbox.stub(storage, 'localStorageIsEnabled').returns(false);
2885
+
2886
+ const adUnitCode = 'adunit1';
2887
+ const reqBidsConfigObj = {
2888
+ adUnits: [{
2889
+ code: adUnitCode,
2890
+ bids: [{
2891
+ bidder: 'smartadserver'
2892
+ }, {
2893
+ bidder: 'pubmatic'
2894
+ }, {
2895
+ bidder: 'appnexus'
2896
+ }, {
2897
+ bidder: 'rubicon'
2898
+ }, {
2899
+ bidder: 'other'
2900
+ }]
2901
+ }]
2902
+ };
2903
+ const onDoneSpy = sinon.spy();
2904
+
2905
+ expect(weboramaSubmodule.init(moduleConfig)).to.be.true;
2906
+ weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig);
2907
+
2908
+ expect(onDoneSpy.calledOnce).to.be.true;
2909
+
2910
+ const targeting = weboramaSubmodule.getTargetingData([adUnitCode], moduleConfig);
2911
+
2912
+ expect(targeting).to.deep.equal({
2913
+ 'adunit1': defaultProfile,
2914
+ });
2915
+
2916
+ expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5);
2917
+ expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('lite_hobbies=sport;lite_hobbies=cinéma');
2918
+ expect(reqBidsConfigObj.adUnits[0].bids[1].params.dctr).to.equal('lite_hobbies=sport,cinéma');
2919
+ expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal(defaultProfile);
2920
+ expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.deep.equal({
2921
+ inventory: defaultProfile,
2922
+ });
2923
+ expect(reqBidsConfigObj.adUnits[0].bids[4].ortb2).to.deep.equal({
2924
+ site: {
2925
+ ext: {
2926
+ data: defaultProfile,
2927
+ },
2928
+ },
2929
+ });
2930
+ expect(onDataResponse).to.deep.equal({
2931
+ data: defaultProfile,
2932
+ meta: {
2933
+ user: false,
2934
+ source: 'lite',
2935
+ isDefault: true,
2936
+ },
2937
+ });
2938
+ });
2939
+
2940
+ it('should be possible update profile from callbacks for a given bidder/adUnitCode', function() {
2941
+ let onDataResponse = {};
2942
+ const moduleConfig = {
2943
+ params: {
2944
+ sfbxLiteDataConf: {
2945
+ targetURL: 'https://prebid.org',
2946
+ setPrebidTargeting: (adUnitCode, data, meta) => {
2947
+ if (adUnitCode == 'adunit1') {
2948
+ data['lito_foo'] = ['bar'];
2949
+ }
2950
+ return true;
2951
+ },
2952
+ sendToBidders: (bid, adUnitCode, data, meta) => {
2953
+ if (bid.bidder == 'appnexus' && adUnitCode == 'adunit1') {
2954
+ data['lito_bar'] = ['baz'];
2955
+ }
2956
+ return true;
2957
+ },
2958
+ onData: (data, meta) => {
2959
+ onDataResponse = {
2960
+ data: data,
2961
+ meta: meta,
2962
+ };
2963
+ },
2964
+ }
2965
+ }
2966
+ };
2967
+ const data = {
2968
+ lite_occupation: ['gérant', 'bénévole'],
2969
+ lite_hobbies: ['sport', 'cinéma'],
2970
+ };
2971
+
2972
+ const entry = {
2973
+ webo: data,
2974
+ };
2975
+
2976
+ sandbox.stub(storage, 'localStorageIsEnabled').returns(true);
2977
+ sandbox.stub(storage, 'getDataFromLocalStorage')
2978
+ .withArgs(DEFAULT_LOCAL_STORAGE_LITE_PROFILE_KEY)
2979
+ .returns(JSON.stringify(entry));
2980
+
2981
+ const adUnitCode1 = 'adunit1';
2982
+ const adUnitCode2 = 'adunit2';
2983
+ const reqBidsConfigObj = {
2984
+ adUnits: [{
2985
+ code: adUnitCode1,
2986
+ bids: [{
2987
+ bidder: 'smartadserver'
2988
+ }, {
2989
+ bidder: 'pubmatic'
2990
+ }, {
2991
+ bidder: 'appnexus'
2992
+ }, {
2993
+ bidder: 'rubicon'
2994
+ }, {
2995
+ bidder: 'other'
2996
+ }]
2997
+ }, {
2998
+ code: adUnitCode2,
2999
+ bids: [{
3000
+ bidder: 'smartadserver'
3001
+ }, {
3002
+ bidder: 'pubmatic'
3003
+ }, {
3004
+ bidder: 'appnexus'
3005
+ }, {
3006
+ bidder: 'rubicon'
3007
+ }, {
3008
+ bidder: 'other'
3009
+ }]
3010
+ }]
3011
+ };
3012
+
3013
+ const onDoneSpy = sinon.spy();
3014
+
3015
+ expect(weboramaSubmodule.init(moduleConfig)).to.be.true;
3016
+ weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig);
3017
+
3018
+ expect(onDoneSpy.calledOnce).to.be.true;
3019
+
3020
+ const targeting = weboramaSubmodule.getTargetingData([adUnitCode1, adUnitCode2], moduleConfig);
3021
+
3022
+ expect(targeting).to.deep.equal({
3023
+ 'adunit1': {
3024
+ lite_occupation: ['gérant', 'bénévole'],
3025
+ lite_hobbies: ['sport', 'cinéma'],
3026
+ lito_foo: ['bar'],
3027
+ },
3028
+ 'adunit2': data,
3029
+ });
3030
+
3031
+ reqBidsConfigObj.adUnits.forEach(adUnit => {
3032
+ expect(adUnit.bids.length).to.equal(5);
3033
+ expect(adUnit.bids[0].params.target).to.equal('lite_occupation=gérant;lite_occupation=bénévole;lite_hobbies=sport;lite_hobbies=cinéma');
3034
+ expect(adUnit.bids[1].params.dctr).to.equal('lite_occupation=gérant,bénévole|lite_hobbies=sport,cinéma');
3035
+ expect(adUnit.bids[3].params).to.deep.equal({
3036
+ inventory: data,
3037
+ });
3038
+ expect(adUnit.bids[4].ortb2).to.deep.equal({
3039
+ site: {
3040
+ ext: {
3041
+ data: data,
3042
+ },
3043
+ },
3044
+ });
3045
+ });
3046
+
3047
+ expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal({
3048
+ lite_occupation: ['gérant', 'bénévole'],
3049
+ lite_hobbies: ['sport', 'cinéma'],
3050
+ lito_bar: ['baz'],
3051
+ });
3052
+ expect(reqBidsConfigObj.adUnits[1].bids[2].params.keywords).to.deep.equal(data);
3053
+
3054
+ expect(onDataResponse).to.deep.equal({
3055
+ data: data,
3056
+ meta: {
3057
+ user: false,
3058
+ source: 'lite',
3059
+ isDefault: false,
3060
+ },
994
3061
  });
995
3062
  });
996
3063
  });