prebid.js 7.34.0 → 7.35.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 (169) hide show
  1. package/.devcontainer/devcontainer.json +2 -1
  2. package/.github/workflows/issue_tracker.yml +1 -1
  3. package/dist/33acrossBidAdapter.js +1 -1
  4. package/dist/33acrossIdSystem.js +1 -1
  5. package/dist/adagioBidAdapter.js +1 -1
  6. package/dist/adbookpspBidAdapter.js +1 -1
  7. package/dist/adgenerationBidAdapter.js +1 -1
  8. package/dist/adrelevantisBidAdapter.js +1 -1
  9. package/dist/adtrgtmeBidAdapter.js +1 -1
  10. package/dist/adxcgBidAdapter.js +1 -1
  11. package/dist/adyoulikeBidAdapter.js +1 -1
  12. package/dist/ajaBidAdapter.js +1 -1
  13. package/dist/amxBidAdapter.js +1 -1
  14. package/dist/amxIdSystem.js +1 -1
  15. package/dist/appierAnalyticsAdapter.js +1 -1
  16. package/dist/appnexusBidAdapter.js +1 -1
  17. package/dist/asoBidAdapter.js +1 -1
  18. package/dist/axonixBidAdapter.js +1 -1
  19. package/dist/bidglassBidAdapter.js +1 -1
  20. package/dist/big-richmediaBidAdapter.js +1 -1
  21. package/dist/bridgewellBidAdapter.js +1 -1
  22. package/dist/brightMountainMediaBidAdapter.js +1 -1
  23. package/dist/carodaBidAdapter.js +1 -1
  24. package/dist/chtnwBidAdapter.js +1 -1
  25. package/dist/concertBidAdapter.js +1 -1
  26. package/dist/connectadBidAdapter.js +1 -1
  27. package/dist/consentManagement.js +1 -1
  28. package/dist/consumableBidAdapter.js +1 -1
  29. package/dist/conversantBidAdapter.js +1 -1
  30. package/dist/craftBidAdapter.js +1 -1
  31. package/dist/criteoBidAdapter.js +1 -1
  32. package/dist/cwireBidAdapter.js +1 -1
  33. package/dist/dspxBidAdapter.js +1 -1
  34. package/dist/eplanningBidAdapter.js +1 -1
  35. package/dist/feedadBidAdapter.js +1 -1
  36. package/dist/finativeBidAdapter.js +1 -1
  37. package/dist/glimpseBidAdapter.js +1 -1
  38. package/dist/gmosspBidAdapter.js +1 -1
  39. package/dist/goldbachBidAdapter.js +1 -1
  40. package/dist/gridBidAdapter.js +1 -1
  41. package/dist/gridNMBidAdapter.js +1 -1
  42. package/dist/gumgumBidAdapter.js +1 -1
  43. package/dist/h12mediaBidAdapter.js +1 -1
  44. package/dist/hadronIdSystem.js +1 -1
  45. package/dist/id5IdSystem.js +1 -1
  46. package/dist/improvedigitalBidAdapter.js +1 -1
  47. package/dist/inmarBidAdapter.js +1 -1
  48. package/dist/insticatorBidAdapter.js +1 -1
  49. package/dist/ixBidAdapter.js +1 -1
  50. package/dist/justpremiumBidAdapter.js +1 -1
  51. package/dist/konduitAnalyticsAdapter.js +1 -1
  52. package/dist/kueezBidAdapter.js +1 -1
  53. package/dist/kueezRtbBidAdapter.js +1 -1
  54. package/dist/lassoBidAdapter.js +1 -1
  55. package/dist/lifestreetBidAdapter.js +1 -1
  56. package/dist/liveyieldAnalyticsAdapter.js +1 -1
  57. package/dist/logicadBidAdapter.js +1 -1
  58. package/dist/loglyliftBidAdapter.js +1 -1
  59. package/dist/magniteAnalyticsAdapter.js +1 -1
  60. package/dist/malltvAnalyticsAdapter.js +1 -1
  61. package/dist/marsmediaBidAdapter.js +1 -1
  62. package/dist/mediafuseBidAdapter.js +1 -1
  63. package/dist/mediasquareBidAdapter.js +1 -1
  64. package/dist/mgidBidAdapter.js +1 -1
  65. package/dist/minutemediaBidAdapter.js +1 -1
  66. package/dist/nexx360BidAdapter.js +1 -1
  67. package/dist/not-for-prod/prebid.js +127 -137
  68. package/dist/oguryBidAdapter.js +1 -1
  69. package/dist/onetagBidAdapter.js +1 -1
  70. package/dist/ooloAnalyticsAdapter.js +1 -1
  71. package/dist/outbrainBidAdapter.js +1 -1
  72. package/dist/parrableIdSystem.js +1 -1
  73. package/dist/permutiveRtdProvider.js +1 -1
  74. package/dist/pixfutureBidAdapter.js +1 -1
  75. package/dist/prebid-core.js +1 -1
  76. package/dist/priceFloors.js +1 -1
  77. package/dist/publinkIdSystem.js +1 -1
  78. package/dist/pubmaticBidAdapter.js +1 -1
  79. package/dist/pubwiseAnalyticsAdapter.js +1 -1
  80. package/dist/pulsepointBidAdapter.js +1 -1
  81. package/dist/pxyzBidAdapter.js +1 -1
  82. package/dist/quantcastBidAdapter.js +1 -1
  83. package/dist/readpeakBidAdapter.js +1 -1
  84. package/dist/relaidoBidAdapter.js +1 -1
  85. package/dist/rhythmoneBidAdapter.js +1 -1
  86. package/dist/riseBidAdapter.js +1 -1
  87. package/dist/rubiconAnalyticsAdapter.js +1 -1
  88. package/dist/rubiconBidAdapter.js +1 -1
  89. package/dist/seedingAllianceBidAdapter.js +1 -1
  90. package/dist/seedtagBidAdapter.js +1 -1
  91. package/dist/sharethroughAnalyticsAdapter.js +1 -1
  92. package/dist/sharethroughBidAdapter.js +1 -1
  93. package/dist/shinezBidAdapter.js +1 -1
  94. package/dist/smaatoBidAdapter.js +1 -1
  95. package/dist/smartadserverBidAdapter.js +1 -1
  96. package/dist/smartxBidAdapter.js +1 -1
  97. package/dist/smartytechBidAdapter.js +1 -1
  98. package/dist/smilewantedBidAdapter.js +1 -1
  99. package/dist/sonobiBidAdapter.js +1 -1
  100. package/dist/sovrnAnalyticsAdapter.js +1 -1
  101. package/dist/sovrnBidAdapter.js +1 -1
  102. package/dist/sspBCBidAdapter.js +1 -1
  103. package/dist/sublimeBidAdapter.js +1 -1
  104. package/dist/synacormediaBidAdapter.js +1 -1
  105. package/dist/taboolaBidAdapter.js +1 -1
  106. package/dist/targetVideoBidAdapter.js +1 -1
  107. package/dist/teadsBidAdapter.js +1 -1
  108. package/dist/trionBidAdapter.js +1 -1
  109. package/dist/tripleliftBidAdapter.js +1 -1
  110. package/dist/ttdBidAdapter.js +1 -1
  111. package/dist/ucfunnelAnalyticsAdapter.js +1 -1
  112. package/dist/uid2IdSystem.js +1 -1
  113. package/dist/underdogmediaBidAdapter.js +1 -1
  114. package/dist/undertoneBidAdapter.js +1 -1
  115. package/dist/vidazooBidAdapter.js +1 -1
  116. package/dist/videobyteBidAdapter.js +1 -1
  117. package/dist/visxBidAdapter.js +1 -1
  118. package/dist/vuukleBidAdapter.js +1 -1
  119. package/dist/widespaceBidAdapter.js +1 -1
  120. package/dist/winrBidAdapter.js +1 -1
  121. package/dist/yahoosspBidAdapter.js +1 -1
  122. package/dist/yieldmoBidAdapter.js +1 -1
  123. package/dist/yieldoneAnalyticsAdapter.js +1 -1
  124. package/dist/zeta_global_sspBidAdapter.js +1 -1
  125. package/dist/zeusPrimeRtdProvider.js +4 -14
  126. package/integrationExamples/gpt/hello_world.html +0 -0
  127. package/modules/adyoulikeBidAdapter.js +2 -0
  128. package/modules/consentManagement.js +33 -5
  129. package/modules/cwireBidAdapter.js +169 -242
  130. package/modules/cwireBidAdapter.md +15 -14
  131. package/modules/hadronIdSystem.js +37 -32
  132. package/modules/nexx360BidAdapter.js +1 -2
  133. package/modules/onetagBidAdapter.js +12 -1
  134. package/modules/outbrainBidAdapter.js +103 -6
  135. package/modules/permutiveRtdProvider.js +17 -12
  136. package/modules/priceFloors.js +7 -8
  137. package/modules/pulsepointBidAdapter.js +2 -0
  138. package/modules/smartadserverBidAdapter.js +39 -28
  139. package/modules/smartyadsBidAdapter.md +9 -0
  140. package/modules/smartytechBidAdapter.js +67 -10
  141. package/modules/smartytechBidAdapter.md +44 -33
  142. package/modules/sonobiBidAdapter.js +17 -10
  143. package/modules/taboolaBidAdapter.js +2 -1
  144. package/modules/vidazooBidAdapter.js +56 -22
  145. package/modules/zeta_global_sspBidAdapter.js +15 -0
  146. package/modules/zeusPrimeRtdProvider.js +3 -323
  147. package/modules/zeusPrimeRtdProvider.md +3 -0
  148. package/package.json +1 -1
  149. package/src/auction.js +2 -11
  150. package/src/prebid.js +8 -0
  151. package/src/utils/cpm.js +17 -0
  152. package/test/spec/modules/adyoulikeBidAdapter_spec.js +3 -0
  153. package/test/spec/modules/consentManagement_spec.js +49 -1
  154. package/test/spec/modules/cwireBidAdapter_spec.js +249 -335
  155. package/test/spec/modules/hadronIdSystem_spec.js +4 -6
  156. package/test/spec/modules/nexx360BidAdapter_spec.js +0 -4
  157. package/test/spec/modules/onetagBidAdapter_spec.js +43 -0
  158. package/test/spec/modules/outbrainBidAdapter_spec.js +182 -18
  159. package/test/spec/modules/pulsepointBidAdapter_spec.js +11 -1
  160. package/test/spec/modules/smartadserverBidAdapter_spec.js +116 -5
  161. package/test/spec/modules/smartytechBidAdapter_spec.js +172 -14
  162. package/test/spec/modules/sonobiBidAdapter_spec.js +2 -1
  163. package/test/spec/modules/taboolaBidAdapter_spec.js +12 -3
  164. package/test/spec/modules/userId_spec.js +19 -14
  165. package/test/spec/modules/vidazooBidAdapter_spec.js +61 -22
  166. package/test/spec/modules/zeta_global_sspBidAdapter_spec.js +8 -0
  167. package/test/spec/unit/pbjs_api_spec.js +14 -0
  168. package/test/spec/unit/utils/cpm_spec.js +64 -0
  169. package/test/spec/modules/zeusPrimeRtdProvider_spec.js +0 -410
@@ -1,382 +1,296 @@
1
- import { expect } from 'chai';
2
- import * as utils from '../../../src/utils.js';
3
- import { config } from '../../../src/config.js';
4
- import {
5
- spec,
6
- CW_PAGE_VIEW_ID,
7
- ENDPOINT_URL,
8
- RENDERER_URL,
9
- } from '../../../modules/cwireBidAdapter.js';
10
- import * as prebidGlobal from 'src/prebidGlobal.js';
11
-
12
- // ------------------------------------
13
- // Bid Request Builder
14
- // ------------------------------------
15
-
16
- const BID_DEFAULTS = {
17
- request: {
18
- bidder: 'cwire',
19
- auctionId: 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee',
20
- transactionId: 'txaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee',
21
- bidId: 'bid123445',
22
- bidderRequestId: 'brid12345',
23
- code: 'original-div',
24
- },
25
- params: {
26
- placementId: 123456,
27
- pageId: 777,
28
- },
29
- sizes: [[300, 250], [1, 1]],
30
- };
31
-
32
- const BidderRequestBuilder = function BidderRequestBuilder(options) {
33
- const defaults = {
34
- bidderCode: 'cwire',
35
- auctionId: BID_DEFAULTS.request.auctionId,
36
- bidderRequestId: BID_DEFAULTS.request.bidderRequestId,
37
- transactionId: BID_DEFAULTS.request.transactionId,
38
- timeout: 3000,
39
- };
40
-
41
- const request = {
42
- ...defaults,
43
- ...options
44
- };
45
-
46
- this.build = () => request;
47
- };
48
-
49
- const BidRequestBuilder = function BidRequestBuilder(options, deleteKeys) {
50
- const defaults = JSON.parse(JSON.stringify(BID_DEFAULTS));
51
-
52
- const request = {
53
- ...defaults.request,
54
- ...options
55
- };
56
-
57
- if (request && utils.isArray(deleteKeys)) {
58
- deleteKeys.forEach((k) => {
59
- delete request[k];
60
- })
61
- }
62
-
63
- this.withParams = (options, deleteKeys) => {
64
- request.params = {
65
- ...defaults.params,
66
- ...options
67
- };
68
- if (request && utils.isArray(deleteKeys)) {
69
- deleteKeys.forEach((k) => {
70
- delete request.params[k];
71
- })
72
- }
73
- return this;
74
- };
75
-
76
- this.build = () => request;
77
- };
1
+ import {expect} from 'chai';
2
+ import {newBidder} from '../../../src/adapters/bidderFactory';
3
+ import {BID_ENDPOINT, spec, storage} from '../../../modules/cwireBidAdapter';
4
+ import {deepClone, logInfo} from '../../../src/utils';
5
+ import * as utils from 'src/utils.js';
6
+ import {sandbox, stub} from 'sinon';
7
+ import {config} from '../../../src/config';
78
8
 
79
9
  describe('C-WIRE bid adapter', () => {
80
- let sandbox;
81
-
82
- beforeEach(() => {
83
- sandbox = sinon.createSandbox();
10
+ config.setConfig({debug: true});
11
+ const adapter = newBidder(spec);
12
+ let bidRequests = [
13
+ {
14
+ 'bidder': 'cwire',
15
+ 'params': {
16
+ 'pageId': '4057',
17
+ 'placementId': 'ad-slot-bla'
18
+ },
19
+ 'adUnitCode': 'adunit-code',
20
+ 'sizes': [[300, 250], [300, 600]],
21
+ 'bidId': '30b31c1838de1e',
22
+ 'bidderRequestId': '22edbae2733bf6',
23
+ 'auctionId': '1d1a030790a475',
24
+ 'transactionId': '04f2659e-c005-4eb1-a57c-fa93145e3843'
25
+ }
26
+ ];
27
+ const response = {
28
+ body: {
29
+ 'cwid': '2ef90743-7936-4a82-8acf-e73382a64e94',
30
+ 'hash': '17112D98BBF55D3A',
31
+ 'bids': [{
32
+ 'html': '<h1>Hello world</h1>',
33
+ 'cpm': 100,
34
+ 'currency': 'CHF',
35
+ 'dimensions': [1, 1],
36
+ 'netRevenue': true,
37
+ 'creativeId': '3454',
38
+ 'requestId': '2c634d4ca5ccfb',
39
+ 'placementId': 177,
40
+ 'transactionId': 'b4b32618-1350-4828-b6f0-fbb5c329e9a4',
41
+ 'ttl': 360
42
+ }]
43
+ }
44
+ }
45
+ describe('inherited functions', function () {
46
+ it('exists and is a function', function () {
47
+ expect(adapter.callBids).to.exist.and.to.be.a('function');
48
+ expect(spec.isBidRequestValid).to.exist.and.to.be.a('function');
49
+ expect(spec.buildRequests).to.exist.and.to.be.a('function');
50
+ expect(spec.interpretResponse).to.exist.and.to.be.a('function');
51
+ });
84
52
  });
85
-
86
- afterEach(() => {
87
- sandbox.restore();
88
- config.resetConfig();
53
+ describe('buildRequests', function () {
54
+ it('sends bid request to ENDPOINT via POST', function () {
55
+ const request = spec.buildRequests(bidRequests);
56
+ expect(request.url).to.equal(BID_ENDPOINT);
57
+ expect(request.method).to.equal('POST');
58
+ });
89
59
  });
60
+ describe('buildRequests with given creative', function () {
61
+ let utilsStub;
90
62
 
91
- // START TESTING
92
- describe('C-WIRE - isBidRequestValid', function () {
93
- it('should return true when required params found', function () {
94
- const bid01 = new BidRequestBuilder().withParams().build();
95
- expect(spec.isBidRequestValid(bid01)).to.equal(true);
63
+ before(function () {
64
+ utilsStub = stub(utils, 'getParameterByName').callsFake(function () {
65
+ return 'str-str'
66
+ });
96
67
  });
97
68
 
98
- it('should fail if there is no placementId', function () {
99
- const bid01 = new BidRequestBuilder().withParams().build();
100
- delete bid01.params.placementId
101
- expect(spec.isBidRequestValid(bid01)).to.equal(false);
69
+ after(function () {
70
+ utilsStub.restore();
102
71
  });
103
72
 
104
- it('should fail if invalid placementId type', function () {
105
- const bid01 = new BidRequestBuilder().withParams().build();
106
- delete bid01.params.placementId;
107
- bid01.placementId = '322';
108
- expect(spec.isBidRequestValid(bid01)).to.equal(false);
73
+ it('should add creativeId if url parameter given', function () {
74
+ // set from bid.params
75
+ let bidRequest = deepClone(bidRequests[0]);
76
+
77
+ const request = spec.buildRequests([bidRequest]);
78
+ const payload = JSON.parse(request.data);
79
+ expect(payload.cwcreative).to.exist;
80
+ expect(payload.cwcreative).to.deep.equal('str-str');
81
+ });
82
+ })
83
+
84
+ describe('buildRequests reads adUnit offsetWidth and offsetHeight', function () {
85
+ before(function () {
86
+ const documentStub = sandbox.stub(document, 'getElementById');
87
+ documentStub.withArgs(`${bidRequests[0].adUnitCode}`).returns({
88
+ offsetWidth: 200,
89
+ offsetHeight: 250
90
+ });
109
91
  });
92
+ it('width and height should be set', function () {
93
+ let bidRequest = deepClone(bidRequests[0]);
110
94
 
111
- it('should fail if there is no pageId', function () {
112
- const bid01 = new BidRequestBuilder().withParams().build();
113
- delete bid01.params.pageId
114
- expect(spec.isBidRequestValid(bid01)).to.equal(false);
95
+ const request = spec.buildRequests([bidRequest]);
96
+ const payload = JSON.parse(request.data);
97
+ const el = document.getElementById(`${bidRequest.adUnitCode}`)
98
+
99
+ logInfo(JSON.stringify(payload))
100
+
101
+ expect(el).to.exist;
102
+ expect(payload.slots[0].cwExt.dimensions.width).to.equal(200);
103
+ expect(payload.slots[0].cwExt.dimensions.height).to.equal(250);
104
+ expect(payload.slots[0].cwExt.style.maxHeight).to.not.exist;
105
+ expect(payload.slots[0].cwExt.style.maxWidth).to.not.exist;
106
+ });
107
+ after(function () {
108
+ sandbox.restore()
109
+ });
110
+ });
111
+ describe('buildRequests reads style attributes', function () {
112
+ before(function () {
113
+ const documentStub = sandbox.stub(document, 'getElementById');
114
+ documentStub.withArgs(`${bidRequests[0].adUnitCode}`).returns({
115
+ style: {
116
+ maxWidth: '400px',
117
+ maxHeight: '350px',
118
+ }
119
+ });
115
120
  });
121
+ it('css maxWidth should be set', function () {
122
+ let bidRequest = deepClone(bidRequests[0]);
123
+
124
+ const request = spec.buildRequests([bidRequest]);
125
+ const payload = JSON.parse(request.data);
126
+ const el = document.getElementById(`${bidRequest.adUnitCode}`)
127
+
128
+ logInfo(JSON.stringify(payload))
116
129
 
117
- it('should fail if invalid pageId type', function () {
118
- const bid01 = new BidRequestBuilder().withParams().build();
119
- delete bid01.params.pageId;
120
- bid01.params.pageId = '3320';
121
- expect(spec.isBidRequestValid(bid01)).to.equal(false);
130
+ expect(el).to.exist;
131
+ expect(payload.slots[0].cwExt.style.maxWidth).to.eq('400px');
132
+ !expect(payload.slots[0].cwExt.style.maxHeight).to.eq('350px');
122
133
  });
134
+ after(function () {
135
+ sandbox.restore()
136
+ });
137
+ });
123
138
 
124
- it('should fail if cwcreative of type number', function () {
125
- const bid01 = new BidRequestBuilder().withParams().build();
126
- delete bid01.params.cwcreative;
127
- bid01.params.cwcreative = 3320;
128
- expect(spec.isBidRequestValid(bid01)).to.equal(false);
139
+ describe('buildRequests reads feature flags', function () {
140
+ before(function () {
141
+ sandbox.stub(utils, 'getParameterByName').callsFake(function () {
142
+ return 'feature1,feature2'
143
+ });
129
144
  });
130
145
 
131
- it('should pass with valid cwcreative of type string', function () {
132
- const bid01 = new BidRequestBuilder().withParams().build();
133
- bid01.params.cwcreative = 'i-am-a-string';
134
- expect(spec.isBidRequestValid(bid01)).to.equal(true);
146
+ it('read from url parameter', function () {
147
+ let bidRequest = deepClone(bidRequests[0]);
148
+
149
+ const request = spec.buildRequests([bidRequest]);
150
+ const payload = JSON.parse(request.data);
151
+
152
+ logInfo(JSON.stringify(payload))
153
+
154
+ expect(payload.featureFlags).to.exist;
155
+ expect(payload.featureFlags).to.include.members(['feature1', 'feature2']);
156
+ });
157
+ after(function () {
158
+ sandbox.restore()
135
159
  });
136
160
  });
137
161
 
138
- describe('C-WIRE - buildRequests()', function () {
139
- it('creates a valid request', function () {
140
- const bid01 = new BidRequestBuilder({
141
- mediaTypes: {
142
- banner: {
143
- sizes: [[1, 1]],
144
- }
145
- }
146
- }).withParams({
147
- cwcreative: '54321',
148
- cwapikey: 'xxx-xxx-yyy-zzz-uuid',
149
- refgroups: 'group_1',
150
- }).build();
151
-
152
- const bidderRequest01 = new BidderRequestBuilder().build();
153
-
154
- const requests = spec.buildRequests([bid01], bidderRequest01);
155
-
156
- expect(requests.data.slots.length).to.equal(1);
157
- expect(requests.data.cwid).to.be.null;
158
- expect(requests.data.cwid).to.be.null;
159
- expect(requests.data.slots[0].sizes[0]).to.equal('1x1');
160
- expect(requests.data.cwcreative).to.equal('54321');
161
- expect(requests.data.cwapikey).to.equal('xxx-xxx-yyy-zzz-uuid');
162
- expect(requests.data.refgroups[0]).to.equal('group_1');
162
+ describe('buildRequests reads cwgroups flag', function () {
163
+ before(function () {
164
+ sandbox.stub(utils, 'getParameterByName').callsFake(function () {
165
+ return 'group1,group2'
166
+ });
163
167
  });
164
168
 
165
- it('creates a valid request - read debug params from second bid', function () {
166
- const bid01 = new BidRequestBuilder().withParams().build();
169
+ it('read from url parameter', function () {
170
+ let bidRequest = deepClone(bidRequests[0]);
167
171
 
168
- const bid02 = new BidRequestBuilder({
169
- mediaTypes: {
170
- banner: {
171
- sizes: [[1, 1]],
172
- }
173
- }
174
- }).withParams({
175
- cwcreative: '1234',
176
- cwapikey: 'api_key_5',
177
- refgroups: 'group_5',
178
- }).build();
179
-
180
- const bidderRequest01 = new BidderRequestBuilder().build();
181
-
182
- const requests = spec.buildRequests([bid01, bid02], bidderRequest01);
183
-
184
- expect(requests.data.slots.length).to.equal(2);
185
- expect(requests.data.cwid).to.be.null;
186
- expect(requests.data.cwid).to.be.null;
187
- expect(requests.data.cwcreative).to.equal('1234');
188
- expect(requests.data.cwapikey).to.equal('api_key_5');
189
- expect(requests.data.refgroups[0]).to.equal('group_5');
172
+ const request = spec.buildRequests([bidRequest]);
173
+ const payload = JSON.parse(request.data);
174
+
175
+ logInfo(JSON.stringify(payload))
176
+
177
+ expect(payload.refgroups).to.exist;
178
+ expect(payload.refgroups).to.include.members(['group1', 'group2']);
179
+ });
180
+ after(function () {
181
+ sandbox.restore()
190
182
  });
183
+ })
191
184
 
192
- it('creates a valid request - read debug params from first bid, ignore second', function () {
193
- const bid01 = new BidRequestBuilder()
194
- .withParams({
195
- cwcreative: '33',
196
- cwapikey: 'api_key_33',
197
- refgroups: 'group_33',
198
- }).build();
199
-
200
- const bid02 = new BidRequestBuilder()
201
- .withParams({
202
- cwcreative: '1234',
203
- cwapikey: 'api_key_5',
204
- refgroups: 'group_5',
205
- }).build();
206
-
207
- const bidderRequest01 = new BidderRequestBuilder().build();
208
-
209
- const requests = spec.buildRequests([bid01, bid02], bidderRequest01);
210
-
211
- expect(requests.data.slots.length).to.equal(2);
212
- expect(requests.data.cwid).to.be.null;
213
- expect(requests.data.cwid).to.be.null;
214
- expect(requests.data.cwcreative).to.equal('33');
215
- expect(requests.data.cwapikey).to.equal('api_key_33');
216
- expect(requests.data.refgroups[0]).to.equal('group_33');
185
+ describe('buildRequests reads debug flag', function () {
186
+ before(function () {
187
+ sandbox.stub(utils, 'getParameterByName').callsFake(function () {
188
+ return 'true'
189
+ });
217
190
  });
218
191
 
219
- it('creates a valid request - read debug params from 3 different slots', function () {
220
- const bid01 = new BidRequestBuilder()
221
- .withParams({
222
- cwcreative: '33',
223
- }).build();
224
-
225
- const bid02 = new BidRequestBuilder()
226
- .withParams({
227
- cwapikey: 'api_key_5',
228
- }).build();
229
-
230
- const bid03 = new BidRequestBuilder()
231
- .withParams({
232
- refgroups: 'group_5',
233
- }).build();
234
- const bidderRequest01 = new BidderRequestBuilder().build();
235
-
236
- const requests = spec.buildRequests([bid01, bid02, bid03], bidderRequest01);
237
-
238
- expect(requests.data.slots.length).to.equal(3);
239
- expect(requests.data.cwid).to.be.null;
240
- expect(requests.data.cwid).to.be.null;
241
- expect(requests.data.cwcreative).to.equal('33');
242
- expect(requests.data.cwapikey).to.equal('api_key_5');
243
- expect(requests.data.refgroups[0]).to.equal('group_5');
192
+ it('read from url parameter', function () {
193
+ let bidRequest = deepClone(bidRequests[0]);
194
+
195
+ const request = spec.buildRequests([bidRequest]);
196
+ const payload = JSON.parse(request.data);
197
+
198
+ logInfo(JSON.stringify(payload))
199
+
200
+ expect(payload.debug).to.exist;
201
+ expect(payload.debug).to.equal(true);
202
+ });
203
+ after(function () {
204
+ sandbox.restore()
244
205
  });
206
+ })
245
207
 
246
- it('creates a valid request - config is overriden by URL params', function () {
247
- // for whatever reason stub for getWindowLocation does not work
248
- // so this was the closest way to test for get params
249
- const params = sandbox.stub(utils, 'getParameterByName');
250
- params.withArgs('cwgroups').returns('group_2');
251
- params.withArgs('cwcreative').returns('654321');
252
-
253
- const bid01 = new BidRequestBuilder({
254
- mediaTypes: {
255
- banner: {
256
- sizes: [[1, 1]],
257
- }
258
- }
259
- }).withParams({
260
- cwcreative: '54321',
261
- cwapikey: 'xxx-xxx-yyy-zzz',
262
- refgroups: 'group_1',
263
- }).build();
264
-
265
- const bidderRequest01 = new BidderRequestBuilder().build();
266
-
267
- const requests = spec.buildRequests([bid01], bidderRequest01);
268
-
269
- expect(requests.data.slots.length).to.equal(1);
270
- expect(requests.data.cwid).to.be.null;
271
- expect(requests.data.cwid).to.be.null;
272
- expect(requests.data.slots[0].sizes[0]).to.equal('1x1');
273
- expect(requests.data.cwcreative).to.equal('654321');
274
- expect(requests.data.cwapikey).to.equal('xxx-xxx-yyy-zzz');
275
- expect(requests.data.refgroups[0]).to.equal('group_2');
208
+ describe('buildRequests reads cw_id from Localstorage', function () {
209
+ before(function () {
210
+ sandbox.stub(storage, 'localStorageIsEnabled').callsFake(() => true);
211
+ sandbox.stub(storage, 'setDataInLocalStorage');
212
+ sandbox.stub(storage, 'getDataFromLocalStorage').callsFake((key) => 'taerfagerg');
276
213
  });
277
214
 
278
- it('creates a valid request - if params are not set, null or empty array are sent to the API', function () {
279
- const bid01 = new BidRequestBuilder({
280
- mediaTypes: {
281
- banner: {
282
- sizes: [[1, 1]],
283
- }
284
- }
285
- }).withParams().build();
215
+ it('cw_id is set', function () {
216
+ let bidRequest = deepClone(bidRequests[0]);
286
217
 
287
- const bidderRequest01 = new BidderRequestBuilder().build();
218
+ const request = spec.buildRequests([bidRequest]);
219
+ const payload = JSON.parse(request.data);
288
220
 
289
- const requests = spec.buildRequests([bid01], bidderRequest01);
221
+ logInfo(JSON.stringify(payload))
290
222
 
291
- expect(requests.data.slots.length).to.equal(1);
292
- expect(requests.data.cwid).to.be.null;
293
- expect(requests.data.cwid).to.be.null;
294
- expect(requests.data.slots[0].sizes[0]).to.equal('1x1');
295
- expect(requests.data.cwcreative).to.equal(null);
296
- expect(requests.data.cwapikey).to.equal(null);
297
- expect(requests.data.refgroups.length).to.equal(0);
223
+ expect(payload.cwid).to.exist;
224
+ expect(payload.cwid).to.equal('taerfagerg');
298
225
  });
299
- });
226
+ after(function () {
227
+ sandbox.restore()
228
+ });
229
+ })
300
230
 
301
- describe('C-WIRE - interpretResponse()', function () {
302
- const serverResponse = {
303
- body: {
304
- bids: [{
305
- html: '<div><h2>AD CONTENT</h2></div>',
306
- currency: 'CHF',
307
- cpm: 43.37,
308
- dimensions: [1, 1],
309
- netRevenue: true,
310
- creativeId: '1337',
311
- requestId: BID_DEFAULTS.request.bidId,
312
- ttl: 3500,
313
- }],
314
- }
315
- };
316
-
317
- const expectedResponse = [{
318
- ad: JSON.parse(JSON.stringify(serverResponse.body.bids[0].html)),
319
- bidderCode: BID_DEFAULTS.request.bidder,
320
- cpm: JSON.parse(JSON.stringify(serverResponse.body.bids[0].cpm)),
321
- creativeId: JSON.parse(JSON.stringify(serverResponse.body.bids[0].creativeId)),
322
- currency: JSON.parse(JSON.stringify(serverResponse.body.bids[0].currency)),
323
- height: JSON.parse(JSON.stringify(serverResponse.body.bids[0].dimensions[0])),
324
- width: JSON.parse(JSON.stringify(serverResponse.body.bids[0].dimensions[1])),
325
- netRevenue: JSON.parse(JSON.stringify(serverResponse.body.bids[0].netRevenue)),
326
- requestId: JSON.parse(JSON.stringify(serverResponse.body.bids[0].requestId)),
327
- ttl: JSON.parse(JSON.stringify(serverResponse.body.bids[0].ttl)),
328
- meta: {
329
- advertiserDomains: [],
330
- },
331
- mediaType: 'banner',
332
- }]
333
-
334
- it('correctly parses response', function () {
335
- const bid01 = new BidRequestBuilder({
336
- mediaTypes: {
337
- banner: {
338
- sizes: [[1, 1]],
339
- }
340
- }
341
- }).withParams().build();
231
+ describe('buildRequests maps flattens params for legacy compat', function () {
232
+ before(function () {
233
+ const documentStub = sandbox.stub(document, 'getElementById');
234
+ documentStub.withArgs(`${bidRequests[0].adUnitCode}`).returns({});
235
+ });
236
+ it('pageId flattened', function () {
237
+ let bidRequest = deepClone(bidRequests[0]);
342
238
 
343
- const bidderRequest01 = new BidderRequestBuilder().build();
344
- const requests = spec.buildRequests([bid01], bidderRequest01);
239
+ const request = spec.buildRequests([bidRequest]);
240
+ const payload = JSON.parse(request.data);
345
241
 
346
- const response = spec.interpretResponse(serverResponse, requests);
347
- expect(response).to.deep.equal(expectedResponse);
242
+ logInfo(JSON.stringify(payload))
243
+
244
+ expect(payload.slots[0].pageId).to.exist;
245
+ });
246
+ after(function () {
247
+ sandbox.restore()
348
248
  });
249
+ })
349
250
 
350
- it('attaches renderer', function () {
351
- const bid01 = new BidRequestBuilder({
352
- mediaTypes: {
353
- video: {
354
- playerSize: [[640, 480]],
355
- context: 'outstream',
356
- }
357
- }
358
- }).withParams().build();
359
- const bidderRequest01 = new BidderRequestBuilder().build();
251
+ describe('pageId and placementId are required params', function () {
252
+ it('invalid request', function () {
253
+ let bidRequest = deepClone(bidRequests[0]);
254
+ delete bidRequest.params
255
+
256
+ const valid = spec.isBidRequestValid(bidRequest);
257
+ expect(valid).to.be.false;
258
+ })
360
259
 
361
- const _serverResponse = utils.deepClone(serverResponse);
362
- _serverResponse.body.bids[0].vastXml = '<xml></xml>';
260
+ it('valid request', function () {
261
+ let bidRequest = deepClone(bidRequests[0]);
262
+ bidRequest.params.pageId = 42
263
+ bidRequest.params.placementId = 42
363
264
 
364
- const _expectedResponse = utils.deepClone(expectedResponse);
365
- _expectedResponse[0].mediaType = 'video';
366
- _expectedResponse[0].videoScript = JSON.parse(JSON.stringify(_serverResponse.body.bids[0].html));
367
- _expectedResponse[0].vastXml = JSON.parse(JSON.stringify(_serverResponse.body.bids[0].vastXml));
368
- delete _expectedResponse[0].ad;
265
+ const valid = spec.isBidRequestValid(bidRequest);
266
+ expect(valid).to.be.true;
267
+ })
369
268
 
370
- const requests = spec.buildRequests([bid01], bidderRequest01);
371
- expect(requests.data.slots[0].sizes).to.deep.equal(['640x480']);
269
+ it('cwcreative must be of type string', function () {
270
+ let bidRequest = deepClone(bidRequests[0]);
271
+ bidRequest.params.pageId = 42
272
+ bidRequest.params.placementId = 42
372
273
 
373
- const response = spec.interpretResponse(_serverResponse, requests);
374
- expect(response[0].renderer).to.exist;
375
- expect(response[0].renderer.url).to.equals(RENDERER_URL);
376
- expect(response[0].renderer.loaded).to.equals(false);
274
+ const valid = spec.isBidRequestValid(bidRequest);
275
+ expect(valid).to.be.true;
276
+ })
377
277
 
378
- delete response[0].renderer;
379
- expect(response).to.deep.equal(_expectedResponse);
380
- });
278
+ it('build request adds pageId', function () {
279
+ let bidRequest = deepClone(bidRequests[0]);
280
+
281
+ const request = spec.buildRequests([bidRequest]);
282
+ const payload = JSON.parse(request.data);
283
+
284
+ expect(payload.slots[0].pageId).to.exist;
285
+ })
286
+ });
287
+
288
+ describe('process serverResponse', function () {
289
+ it('html to ad mapping', function () {
290
+ let bidResponse = deepClone(response);
291
+ const bids = spec.interpretResponse(bidResponse, {});
292
+
293
+ expect(bids[0].ad).to.exist;
294
+ })
381
295
  });
382
296
  });
@@ -24,7 +24,7 @@ describe('HadronIdSystem', function () {
24
24
  const request = server.requests[0];
25
25
  expect(request.url).to.eq(`https://id.hadron.ad.gt/api/v1/pbhid?partner_id=0&_it=prebid`);
26
26
  request.respond(200, { 'Content-Type': 'application/json' }, JSON.stringify({ hadronId: 'testHadronId1' }));
27
- expect(callbackSpy.lastCall.lastArg).to.deep.equal({hadronId: 'testHadronId1'});
27
+ expect(callbackSpy.lastCall.lastArg).to.deep.equal({ id: { hadronId: 'testHadronId1' } });
28
28
  });
29
29
 
30
30
  it('gets a cached hadronid', function() {
@@ -33,10 +33,8 @@ describe('HadronIdSystem', function () {
33
33
  };
34
34
  getDataFromLocalStorageStub.withArgs('auHadronId').returns('tstCachedHadronId1');
35
35
 
36
- const callbackSpy = sinon.spy();
37
- const callback = hadronIdSubmodule.getId(config).callback;
38
- callback(callbackSpy);
39
- expect(callbackSpy.lastCall.lastArg).to.deep.equal({hadronId: 'tstCachedHadronId1'});
36
+ const result = hadronIdSubmodule.getId(config);
37
+ expect(result).to.deep.equal({ id: { hadronId: 'tstCachedHadronId1' } });
40
38
  });
41
39
 
42
40
  it('allows configurable id url', function() {
@@ -51,7 +49,7 @@ describe('HadronIdSystem', function () {
51
49
  const request = server.requests[0];
52
50
  expect(request.url).to.eq('https://hadronid.publync.com?partner_id=0&_it=prebid');
53
51
  request.respond(200, { 'Content-Type': 'application/json' }, JSON.stringify({ hadronId: 'testHadronId1' }));
54
- expect(callbackSpy.lastCall.lastArg).to.deep.equal({hadronId: 'testHadronId1'});
52
+ expect(callbackSpy.lastCall.lastArg).to.deep.equal({ id: { hadronId: 'testHadronId1' } });
55
53
  });
56
54
  });
57
55
  });