prebid.js 5.17.0 → 6.0.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.
- package/.babelrc.js +3 -6
- package/README.md +3 -1
- package/browsers.json +1 -8
- package/integrationExamples/gpt/akamaidap_segments_example.html +132 -0
- package/modules/.submodules.json +1 -0
- package/modules/adfBidAdapter.js +21 -16
- package/modules/adgenerationBidAdapter.js +28 -4
- package/modules/adkernelBidAdapter.js +2 -1
- package/modules/admixerBidAdapter.js +11 -0
- package/modules/adtelligentBidAdapter.js +2 -1
- package/modules/airgridRtdProvider.js +1 -1
- package/modules/akamaiDapRtdProvider.js +474 -0
- package/modules/akamaiDapRtdProvider.md +47 -0
- package/modules/aolBidAdapter.js +2 -1
- package/modules/appnexusBidAdapter.js +5 -3
- package/modules/atsAnalyticsAdapter.js +67 -46
- package/modules/atsAnalyticsAdapter.md +1 -0
- package/modules/betweenBidAdapter.js +20 -3
- package/modules/bliinkBidAdapter.js +58 -32
- package/modules/bliinkBidAdapter.md +29 -6
- package/modules/browsiRtdProvider.js +106 -18
- package/modules/cleanioRtdProvider.js +192 -0
- package/modules/cleanioRtdProvider.md +59 -0
- package/modules/codefuelBidAdapter.js +183 -0
- package/modules/codefuelBidAdapter.md +111 -0
- package/modules/connectIdSystem.js +104 -0
- package/modules/connectIdSystem.md +33 -0
- package/modules/cwireBidAdapter.js +272 -0
- package/modules/cwireBidAdapter.md +43 -0
- package/modules/deepintentBidAdapter.js +106 -9
- package/modules/deepintentBidAdapter.md +36 -1
- package/modules/deltaprojectsBidAdapter.js +252 -0
- package/modules/deltaprojectsBidAdapter.md +32 -0
- package/modules/dgkeywordRtdProvider.js +0 -1
- package/modules/engageyaBidAdapter.js +157 -0
- package/modules/gridBidAdapter.js +1 -0
- package/modules/gumgumBidAdapter.js +8 -0
- package/modules/inskinBidAdapter.js +7 -3
- package/modules/ixBidAdapter.js +8 -1
- package/modules/jixieBidAdapter.js +8 -2
- package/modules/justpremiumBidAdapter.js +6 -1
- package/modules/limelightDigitalBidAdapter.js +22 -2
- package/modules/livewrappedAnalyticsAdapter.js +53 -3
- package/modules/mediakeysBidAdapter.js +2 -1
- package/modules/multibid/index.js +3 -3
- package/modules/nativoBidAdapter.js +6 -2
- package/modules/nextMillenniumBidAdapter.js +12 -3
- package/modules/oguryBidAdapter.js +36 -7
- package/modules/openxBidAdapter.js +34 -22
- package/modules/operaadsBidAdapter.js +21 -1
- package/modules/otmBidAdapter.js +146 -0
- package/modules/otmBidAdapter.md +27 -26
- package/modules/outbrainBidAdapter.js +5 -0
- package/modules/pixfutureBidAdapter.js +24 -4
- package/modules/pixfutureBidAdapter.md +127 -0
- package/modules/playwireBidAdapter.md +61 -0
- package/modules/prebidServerBidAdapter/index.js +1 -1
- package/modules/proxistoreBidAdapter.js +4 -6
- package/modules/publinkIdSystem.js +11 -6
- package/modules/pubmaticBidAdapter.js +9 -0
- package/modules/pubmaticBidAdapter.md +1 -1
- package/modules/rtdModule/index.js +2 -2
- package/modules/sonobiBidAdapter.js +7 -0
- package/modules/sortableBidAdapter.js +1 -0
- package/modules/talkadsBidAdapter.js +129 -0
- package/modules/talkadsBidAdapter.md +60 -0
- package/modules/teadsBidAdapter.js +3 -0
- package/modules/tripleliftBidAdapter.js +22 -5
- package/modules/trustxBidAdapter.js +8 -6
- package/modules/undertoneBidAdapter.js +9 -5
- package/modules/undertoneBidAdapter.md +5 -1
- package/modules/unicornBidAdapter.js +3 -3
- package/modules/userId/eids.js +18 -0
- package/modules/userId/eids.md +7 -0
- package/modules/userId/userId.md +12 -0
- package/modules/ventesBidAdapter.js +370 -0
- package/modules/ventesBidAdapter.md +94 -0
- package/modules/videobyteBidAdapter.js +13 -6
- package/modules/videobyteBidAdapter.md +49 -0
- package/modules/visxBidAdapter.js +15 -22
- package/modules/yahoosspBidAdapter.js +637 -0
- package/modules/yahoosspBidAdapter.md +795 -0
- package/modules/yieldlabBidAdapter.js +48 -3
- package/modules/yieldlabBidAdapter.md +16 -1
- package/modules/yieldmoSyntheticInventoryModule.js +46 -0
- package/modules/yieldmoSyntheticInventoryModule.md +68 -0
- package/package.json +1 -1
- package/src/adapterManager.js +5 -0
- package/src/adapters/bidderFactory.js +4 -3
- package/src/auction.js +11 -11
- package/src/constants.json +1 -0
- package/src/secureCreatives.js +6 -7
- package/src/targeting.js +11 -9
- package/test/spec/modules/adfBidAdapter_spec.js +83 -29
- package/test/spec/modules/adgenerationBidAdapter_spec.js +121 -50
- package/test/spec/modules/adtelligentBidAdapter_spec.js +1 -0
- package/test/spec/modules/akamaiDapRtdProvider_spec.js +246 -0
- package/test/spec/modules/appnexusBidAdapter_spec.js +2 -1
- package/test/spec/modules/atsAnalyticsAdapter_spec.js +42 -9
- package/test/spec/modules/betweenBidAdapter_spec.js +41 -0
- package/test/spec/modules/bliinkBidAdapter_spec.js +87 -36
- package/test/spec/modules/browsiRtdProvider_spec.js +62 -7
- package/test/spec/modules/cleanioRtdProvider_spec.js +188 -0
- package/test/spec/modules/codefuelBidAdapter_spec.js +316 -0
- package/test/spec/modules/connectIdSystem_spec.js +189 -0
- package/test/spec/modules/cwireBidAdapter_spec.js +246 -0
- package/test/spec/modules/deepintentBidAdapter_spec.js +153 -3
- package/test/spec/modules/deltaprojectsBidAdapter_spec.js +399 -0
- package/test/spec/modules/engageyaBidAdapter_spec.js +286 -0
- package/test/spec/modules/gumgumBidAdapter_spec.js +5 -1
- package/test/spec/modules/ixBidAdapter_spec.js +13 -3
- package/test/spec/modules/jixieBidAdapter_spec.js +13 -11
- package/test/spec/modules/justpremiumBidAdapter_spec.js +9 -2
- package/test/spec/modules/limelightDigitalBidAdapter_spec.js +155 -1
- package/test/spec/modules/livewrappedAnalyticsAdapter_spec.js +67 -12
- package/test/spec/modules/multibid_spec.js +31 -31
- package/test/spec/modules/nextMillenniumBidAdapter_spec.js +13 -1
- package/test/spec/modules/oguryBidAdapter_spec.js +125 -37
- package/test/spec/modules/openxBidAdapter_spec.js +85 -13
- package/test/spec/modules/operaadsBidAdapter_spec.js +38 -6
- package/test/spec/modules/otmBidAdapter_spec.js +67 -0
- package/test/spec/modules/outbrainBidAdapter_spec.js +18 -0
- package/test/spec/modules/publinkIdSystem_spec.js +6 -6
- package/test/spec/modules/pubmaticBidAdapter_spec.js +39 -1
- package/test/spec/modules/sonobiBidAdapter_spec.js +34 -1
- package/test/spec/modules/sortableBidAdapter_spec.js +11 -0
- package/test/spec/modules/talkadsBidAdapter_spec.js +231 -0
- package/test/spec/modules/teadsBidAdapter_spec.js +132 -0
- package/test/spec/modules/tripleliftBidAdapter_spec.js +128 -0
- package/test/spec/modules/trustxBidAdapter_spec.js +3 -3
- package/test/spec/modules/undertoneBidAdapter_spec.js +52 -0
- package/test/spec/modules/unicornBidAdapter_spec.js +4 -4
- package/test/spec/modules/ventesBidAdapter_spec.js +845 -0
- package/test/spec/modules/videobyteBidAdapter_spec.js +2 -2
- package/test/spec/modules/visxBidAdapter_spec.js +48 -4
- package/test/spec/modules/yahoosspBidAdapter_spec.js +1332 -0
- package/test/spec/modules/yieldlabBidAdapter_spec.js +65 -1
- package/test/spec/modules/yieldmoSyntheticInventoryModule_spec.js +89 -0
- package/test/spec/unit/core/adapterManager_spec.js +32 -0
- package/test/spec/unit/core/bidderFactory_spec.js +61 -1
- package/test/spec/unit/pbjs_api_spec.js +37 -2
- package/test/spec/unit/secureCreatives_spec.js +54 -25
- package/wdio.conf.js +1 -1
- package/modules/turktelekomBidAdapter.md +0 -49
- package/yarn.lock +0 -13122
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
import {
|
|
3
|
+
BIDDER_CODE,
|
|
4
|
+
BIDDER_ENDPOINT_URL,
|
|
5
|
+
spec, USERSYNC_URL,
|
|
6
|
+
getBidFloor
|
|
7
|
+
} from 'modules/deltaprojectsBidAdapter.js';
|
|
8
|
+
|
|
9
|
+
const BID_REQ_REFER = 'http://example.com/page?param=val';
|
|
10
|
+
|
|
11
|
+
describe('deltaprojectsBidAdapter', function() {
|
|
12
|
+
describe('isBidRequestValid', function () {
|
|
13
|
+
function makeBid() {
|
|
14
|
+
return {
|
|
15
|
+
bidder: BIDDER_CODE,
|
|
16
|
+
params: {
|
|
17
|
+
publisherId: '12345'
|
|
18
|
+
},
|
|
19
|
+
adUnitCode: 'adunit-code',
|
|
20
|
+
sizes: [
|
|
21
|
+
[300, 250],
|
|
22
|
+
],
|
|
23
|
+
bidId: '30b31c1838de1e',
|
|
24
|
+
bidderRequestId: '22edbae2733bf6',
|
|
25
|
+
auctionId: '1d1a030790a475',
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
it('should return true when bidder set correctly', function () {
|
|
30
|
+
expect(spec.isBidRequestValid(makeBid())).to.equal(true);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('should return false when bid request is null', function () {
|
|
34
|
+
expect(spec.isBidRequestValid(undefined)).to.equal(false);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('should return false when bidder not set correctly', function () {
|
|
38
|
+
let bid = makeBid();
|
|
39
|
+
delete bid.bidder;
|
|
40
|
+
expect(spec.isBidRequestValid(bid)).to.equal(false);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('should return false when publisher id is not set', function () {
|
|
44
|
+
let bid = makeBid();
|
|
45
|
+
delete bid.params.publisherId;
|
|
46
|
+
expect(spec.isBidRequestValid(bid)).to.equal(false);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
describe('buildRequests', function () {
|
|
51
|
+
const BIDREQ = {
|
|
52
|
+
bidder: BIDDER_CODE,
|
|
53
|
+
params: {
|
|
54
|
+
tagId: '403370',
|
|
55
|
+
siteId: 'example.com',
|
|
56
|
+
},
|
|
57
|
+
sizes: [
|
|
58
|
+
[300, 250],
|
|
59
|
+
],
|
|
60
|
+
bidId: '30b31c1838de1e',
|
|
61
|
+
bidderRequestId: '22edbae2733bf6',
|
|
62
|
+
auctionId: '1d1a030790a475',
|
|
63
|
+
}
|
|
64
|
+
const bidRequests = [BIDREQ];
|
|
65
|
+
const bannerRequest = spec.buildRequests(bidRequests, {refererInfo: { referer: BID_REQ_REFER }})[0];
|
|
66
|
+
const bannerRequestBody = bannerRequest.data;
|
|
67
|
+
|
|
68
|
+
it('send bid request with test tag if it is set in the param', function () {
|
|
69
|
+
const TEST_TAG = 1;
|
|
70
|
+
const bidRequest = Object.assign({}, BIDREQ, {
|
|
71
|
+
params: { ...BIDREQ.params, test: TEST_TAG },
|
|
72
|
+
});
|
|
73
|
+
const bidderRequest = { refererInfo: { referer: BID_REQ_REFER } };
|
|
74
|
+
const request = spec.buildRequests([bidRequest], bidderRequest)[0];
|
|
75
|
+
expect(request.data.test).to.equal(TEST_TAG);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('send bid request with correct timeout', function () {
|
|
79
|
+
const TMAX = 10;
|
|
80
|
+
const bidderRequest = { refererInfo: { referer: BID_REQ_REFER }, timeout: TMAX };
|
|
81
|
+
const request = spec.buildRequests(bidRequests, bidderRequest)[0];
|
|
82
|
+
expect(request.data.tmax).to.equal(TMAX);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('send bid request to the correct endpoint URL', function () {
|
|
86
|
+
expect(bannerRequest.url).to.equal(BIDDER_ENDPOINT_URL);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('sends bid request to our endpoint via POST', function () {
|
|
90
|
+
expect(bannerRequest.method).to.equal('POST');
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('sends screen dimensions', function () {
|
|
94
|
+
expect(bannerRequestBody.device.w).to.equal(screen.width);
|
|
95
|
+
expect(bannerRequestBody.device.h).to.equal(screen.height);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('includes the ad size in the bid request', function () {
|
|
99
|
+
expect(bannerRequestBody.imp[0].banner.format[0].w).to.equal(BIDREQ.sizes[0][0]);
|
|
100
|
+
expect(bannerRequestBody.imp[0].banner.format[0].h).to.equal(BIDREQ.sizes[0][1]);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('sets domain and href correctly', function () {
|
|
104
|
+
expect(bannerRequestBody.site.domain).to.equal(BIDREQ.params.siteId);
|
|
105
|
+
expect(bannerRequestBody.site.page).to.equal(BID_REQ_REFER);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const gdprBidRequests = [{
|
|
109
|
+
bidder: BIDDER_CODE,
|
|
110
|
+
params: {
|
|
111
|
+
tagId: '403370',
|
|
112
|
+
siteId: 'example.com'
|
|
113
|
+
},
|
|
114
|
+
sizes: [
|
|
115
|
+
[300, 250]
|
|
116
|
+
],
|
|
117
|
+
bidId: '30b31c1838de1e',
|
|
118
|
+
bidderRequestId: '22edbae2733bf6',
|
|
119
|
+
auctionId: '1d1a030790a475'
|
|
120
|
+
}];
|
|
121
|
+
const consentString = 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==';
|
|
122
|
+
|
|
123
|
+
const GDPR_REQ_REFERER = 'http://localhost:9876/'
|
|
124
|
+
function getGdprRequestBody(gdprApplies, consentString) {
|
|
125
|
+
const gdprRequest = spec.buildRequests(gdprBidRequests, {
|
|
126
|
+
gdprConsent: {
|
|
127
|
+
gdprApplies: gdprApplies,
|
|
128
|
+
consentString: consentString,
|
|
129
|
+
},
|
|
130
|
+
refererInfo: {
|
|
131
|
+
referer: GDPR_REQ_REFERER,
|
|
132
|
+
},
|
|
133
|
+
})[0];
|
|
134
|
+
return gdprRequest.data;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
it('should handle gdpr applies being present and true', function() {
|
|
138
|
+
const gdprRequestBody = getGdprRequestBody(true, consentString);
|
|
139
|
+
expect(gdprRequestBody.regs.ext.gdpr).to.equal(1);
|
|
140
|
+
expect(gdprRequestBody.user.ext.consent).to.equal(consentString);
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
it('should handle gdpr applies being present and false', function() {
|
|
144
|
+
const gdprRequestBody = getGdprRequestBody(false, consentString);
|
|
145
|
+
expect(gdprRequestBody.regs.ext.gdpr).to.equal(0);
|
|
146
|
+
expect(gdprRequestBody.user.ext.consent).to.equal(consentString);
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
it('should handle gdpr applies being undefined', function() {
|
|
150
|
+
const gdprRequestBody = getGdprRequestBody(undefined, consentString);
|
|
151
|
+
expect(gdprRequestBody.regs).to.deep.equal({ext: {}});
|
|
152
|
+
expect(gdprRequestBody.user.ext.consent).to.equal(consentString);
|
|
153
|
+
})
|
|
154
|
+
|
|
155
|
+
it('should handle gdpr consent being undefined', function() {
|
|
156
|
+
const gdprRequest = spec.buildRequests(gdprBidRequests, {refererInfo: { referer: GDPR_REQ_REFERER }})[0];
|
|
157
|
+
const gdprRequestBody = gdprRequest.data;
|
|
158
|
+
expect(gdprRequestBody.regs).to.deep.equal({ ext: {} });
|
|
159
|
+
expect(gdprRequestBody.user).to.deep.equal({ ext: {} });
|
|
160
|
+
})
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
describe('interpretResponse', function () {
|
|
164
|
+
const bidRequests = [
|
|
165
|
+
{
|
|
166
|
+
bidder: BIDDER_CODE,
|
|
167
|
+
params: {
|
|
168
|
+
tagId: '403370',
|
|
169
|
+
siteId: 'example.com',
|
|
170
|
+
currency: 'USD',
|
|
171
|
+
},
|
|
172
|
+
sizes: [
|
|
173
|
+
[300, 250],
|
|
174
|
+
],
|
|
175
|
+
bidId: '30b31c1838de1e',
|
|
176
|
+
bidderRequestId: '22edbae2733bf6',
|
|
177
|
+
auctionId: '1d1a030790a475',
|
|
178
|
+
},
|
|
179
|
+
];
|
|
180
|
+
const request = spec.buildRequests(bidRequests, {refererInfo: { referer: BID_REQ_REFER }})[0];
|
|
181
|
+
function makeResponse() {
|
|
182
|
+
return {
|
|
183
|
+
body: {
|
|
184
|
+
id: '5e5c23a5ba71e78',
|
|
185
|
+
seatbid: [
|
|
186
|
+
{
|
|
187
|
+
bid: [
|
|
188
|
+
{
|
|
189
|
+
id: '6vmb3isptf',
|
|
190
|
+
crid: 'deltaprojectscreative',
|
|
191
|
+
impid: '322add653672f68',
|
|
192
|
+
price: 1.22,
|
|
193
|
+
adm: '<!-- creative -->',
|
|
194
|
+
attr: [5],
|
|
195
|
+
h: 90,
|
|
196
|
+
nurl: 'http://nurl',
|
|
197
|
+
w: 728,
|
|
198
|
+
}
|
|
199
|
+
],
|
|
200
|
+
seat: 'MOCK'
|
|
201
|
+
}
|
|
202
|
+
],
|
|
203
|
+
bidid: '5e5c23a5ba71e78',
|
|
204
|
+
cur: 'USD'
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
const expectedBid = {
|
|
209
|
+
requestId: '322add653672f68',
|
|
210
|
+
cpm: 1.22,
|
|
211
|
+
width: 728,
|
|
212
|
+
height: 90,
|
|
213
|
+
creativeId: 'deltaprojectscreative',
|
|
214
|
+
dealId: null,
|
|
215
|
+
currency: 'USD',
|
|
216
|
+
netRevenue: true,
|
|
217
|
+
mediaType: 'banner',
|
|
218
|
+
ttl: 60,
|
|
219
|
+
ad: '<!-- creative --><div style="position:absolute;left:0px;top:0px;visibility:hidden;"><img src="http://nurl"></div>'
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
it('should get incorrect bid response if response body is missing', function () {
|
|
223
|
+
let response = makeResponse();
|
|
224
|
+
delete response.body;
|
|
225
|
+
let result = spec.interpretResponse(response, request);
|
|
226
|
+
expect(result.length).to.equal(0);
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
it('should get incorrect bid response if id or seat id of response body is missing', function () {
|
|
230
|
+
let response1 = makeResponse();
|
|
231
|
+
delete response1.body.id;
|
|
232
|
+
let result1 = spec.interpretResponse(response1, request);
|
|
233
|
+
expect(result1.length).to.equal(0);
|
|
234
|
+
|
|
235
|
+
let response2 = makeResponse();
|
|
236
|
+
delete response2.body.seatbid;
|
|
237
|
+
let result2 = spec.interpretResponse(response2, request);
|
|
238
|
+
expect(result2.length).to.equal(0);
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
it('should get the correct bid response', function () {
|
|
242
|
+
let result = spec.interpretResponse(makeResponse(), request);
|
|
243
|
+
expect(result.length).to.equal(1);
|
|
244
|
+
expect(result[0]).to.deep.equal(expectedBid);
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
it('should handle a missing crid', function () {
|
|
248
|
+
let noCridResponse = makeResponse();
|
|
249
|
+
delete noCridResponse.body.seatbid[0].bid[0].crid;
|
|
250
|
+
const fallbackCrid = noCridResponse.body.seatbid[0].bid[0].id;
|
|
251
|
+
let noCridResult = Object.assign({}, expectedBid, {'creativeId': fallbackCrid});
|
|
252
|
+
let result = spec.interpretResponse(noCridResponse, request);
|
|
253
|
+
expect(result.length).to.equal(1);
|
|
254
|
+
expect(result[0]).to.deep.equal(noCridResult);
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
it('should handle a missing nurl', function () {
|
|
258
|
+
let noNurlResponse = makeResponse();
|
|
259
|
+
delete noNurlResponse.body.seatbid[0].bid[0].nurl;
|
|
260
|
+
let noNurlResult = Object.assign({}, expectedBid);
|
|
261
|
+
noNurlResult.ad = '<!-- creative -->';
|
|
262
|
+
let result = spec.interpretResponse(noNurlResponse, request);
|
|
263
|
+
expect(result.length).to.equal(1);
|
|
264
|
+
expect(result[0]).to.deep.equal(noNurlResult);
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
it('handles empty bid response', function () {
|
|
268
|
+
let response = {
|
|
269
|
+
body: {
|
|
270
|
+
id: '5e5c23a5ba71e78',
|
|
271
|
+
seatbid: []
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
let result = spec.interpretResponse(response, request);
|
|
275
|
+
expect(result.length).to.equal(0);
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
it('should keep custom properties', () => {
|
|
279
|
+
const customProperties = {test: 'a test message', param: {testParam: 1}};
|
|
280
|
+
const expectedResult = Object.assign({}, expectedBid, {[spec.code]: customProperties});
|
|
281
|
+
const response = makeResponse();
|
|
282
|
+
response.body.seatbid[0].bid[0].ext = customProperties;
|
|
283
|
+
const result = spec.interpretResponse(response, request);
|
|
284
|
+
expect(result.length).to.equal(1);
|
|
285
|
+
expect(result[0]).to.deep.equal(expectedResult);
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
describe('onBidWon', function () {
|
|
290
|
+
const OPEN_RTB_RESP = {
|
|
291
|
+
body: {
|
|
292
|
+
id: 'abc',
|
|
293
|
+
seatbid: [
|
|
294
|
+
{
|
|
295
|
+
bid: [
|
|
296
|
+
{
|
|
297
|
+
'id': 'abc*123*456',
|
|
298
|
+
'impid': 'xxxxxxx',
|
|
299
|
+
'price': 46.657196,
|
|
300
|
+
'adm': '<iframe id="dsp_iframe_228285197" src="https//abc/${AUCTION_PRICE:B64}&creative_id=123"></script>',
|
|
301
|
+
'adomain': ['deltaprojects.com'],
|
|
302
|
+
'h': 600,
|
|
303
|
+
'w': 300,
|
|
304
|
+
'cid': '868253',
|
|
305
|
+
'crid': '732935',
|
|
306
|
+
'cat': [],
|
|
307
|
+
},
|
|
308
|
+
],
|
|
309
|
+
'seat': '2147483647',
|
|
310
|
+
},
|
|
311
|
+
],
|
|
312
|
+
bidid: 'xyz',
|
|
313
|
+
cur: 'USD',
|
|
314
|
+
},
|
|
315
|
+
}
|
|
316
|
+
it('should replace auction price macro', () => {
|
|
317
|
+
const bid = spec.interpretResponse(OPEN_RTB_RESP)[0];
|
|
318
|
+
spec.onBidWon(bid);
|
|
319
|
+
expect(bid.ad).to.contains(`${Math.round(bid.cpm * 1000000)}`);
|
|
320
|
+
});
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
describe('getUserSyncs', function () {
|
|
324
|
+
it('should not do user sync when pixel is disabled', () => {
|
|
325
|
+
const syncOptions = { pixelEnabled: false }
|
|
326
|
+
const result = spec.getUserSyncs(syncOptions)
|
|
327
|
+
expect(result.length).to.equal(0);
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
it('should do user sync without gdpr params when gdprConsent missing', () => {
|
|
331
|
+
const syncOptions = { pixelEnabled: true }
|
|
332
|
+
const gdprConsent = undefined
|
|
333
|
+
const result = spec.getUserSyncs(syncOptions, gdprConsent)
|
|
334
|
+
expect(result[0].url).to.equal(USERSYNC_URL);
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
it('should do user sync with gdpr params when gdprConsent exists', () => {
|
|
338
|
+
const syncOptions = { pixelEnabled: true }
|
|
339
|
+
const gdprConsent = {
|
|
340
|
+
gdprApplies: true,
|
|
341
|
+
consentString: 'ABCABCABC'
|
|
342
|
+
}
|
|
343
|
+
const expectedResult1 = USERSYNC_URL + `?gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`
|
|
344
|
+
const result1 = spec.getUserSyncs(syncOptions, {}, gdprConsent)
|
|
345
|
+
expect(result1[0].url).to.equal(expectedResult1);
|
|
346
|
+
|
|
347
|
+
delete gdprConsent.gdprApplies
|
|
348
|
+
const result2 = spec.getUserSyncs(syncOptions, {}, gdprConsent)
|
|
349
|
+
const expectedResult2 = USERSYNC_URL + `?gdpr_consent=${gdprConsent.consentString}`
|
|
350
|
+
expect(result2[0].url).to.equal(expectedResult2);
|
|
351
|
+
});
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
describe('getBidFloor', () => {
|
|
355
|
+
it('should not get bid floor when getFloor is not defined', () => {
|
|
356
|
+
const bid = {};
|
|
357
|
+
const currency = 'SEK';
|
|
358
|
+
const result = getBidFloor(bid, 'banner', '*', currency);
|
|
359
|
+
expect(result).to.be.undefined;
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
it('should not get bid floor when getFloor is not a function', () => {
|
|
363
|
+
const bid = { getFloor: 1.0 };
|
|
364
|
+
const currency = 'SEK';
|
|
365
|
+
const result = getBidFloor(bid, 'banner', '*', currency);
|
|
366
|
+
expect(result).to.be.undefined;
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
it('should not get bid floor when getFloor return empty', () => {
|
|
370
|
+
const bid = { getFloor: () => ({}) };
|
|
371
|
+
const currency = 'SEK';
|
|
372
|
+
const result = getBidFloor(bid, 'banner', '*', currency);
|
|
373
|
+
expect(result).to.be.undefined;
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
it('should not get bid floor in SEK when floor is not a number', () => {
|
|
377
|
+
const bid = { getFloor: () => ({ currency: 'SEK', floor: '1.0' }) };
|
|
378
|
+
const currency = 'SEK';
|
|
379
|
+
const result = getBidFloor(bid, 'banner', '*', currency);
|
|
380
|
+
expect(result).to.be.undefined;
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
it('should get bid floor in USD when currency is not defined', () => {
|
|
384
|
+
const bid = { getFloor: () => ({ currency: 'USD', floor: 1.0 }) };
|
|
385
|
+
const currency = undefined;
|
|
386
|
+
const result = getBidFloor(bid, 'banner', '*', currency);
|
|
387
|
+
expect(result.floor).to.equal(1.0);
|
|
388
|
+
expect(result.currency).to.equal('USD');
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
it('should get bid floor in SEK when currency is SEK', () => {
|
|
392
|
+
const bid = { getFloor: () => ({ currency: 'SEK', floor: 1.0 }) };
|
|
393
|
+
const currency = 'SEK';
|
|
394
|
+
const result = getBidFloor(bid, 'banner', '*', currency);
|
|
395
|
+
expect(result.floor).to.equal(1.0);
|
|
396
|
+
expect(result.currency).to.equal('SEK');
|
|
397
|
+
});
|
|
398
|
+
});
|
|
399
|
+
});
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
import { spec } from 'modules/engageyaBidAdapter.js';
|
|
3
|
+
import * as utils from 'src/utils.js';
|
|
4
|
+
|
|
5
|
+
const ENDPOINT_URL = 'https://recs.engageya.com/rec-api/getrecs.json';
|
|
6
|
+
|
|
7
|
+
export const _getUrlVars = function (url) {
|
|
8
|
+
var hash;
|
|
9
|
+
var myJson = {};
|
|
10
|
+
var hashes = url.slice(url.indexOf('?') + 1).split('&');
|
|
11
|
+
for (var i = 0; i < hashes.length; i++) {
|
|
12
|
+
hash = hashes[i].split('=');
|
|
13
|
+
myJson[hash[0]] = hash[1];
|
|
14
|
+
}
|
|
15
|
+
return myJson;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
describe('engageya adapter', function () {
|
|
19
|
+
let bidRequests;
|
|
20
|
+
let nativeBidRequests;
|
|
21
|
+
|
|
22
|
+
beforeEach(function () {
|
|
23
|
+
bidRequests = [
|
|
24
|
+
{
|
|
25
|
+
bidder: 'engageya',
|
|
26
|
+
params: {
|
|
27
|
+
widgetId: 85610,
|
|
28
|
+
websiteId: 91140,
|
|
29
|
+
pageUrl: '[PAGE_URL]'
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
nativeBidRequests = [
|
|
35
|
+
{
|
|
36
|
+
bidder: 'engageya',
|
|
37
|
+
params: {
|
|
38
|
+
widgetId: 85610,
|
|
39
|
+
websiteId: 91140,
|
|
40
|
+
pageUrl: '[PAGE_URL]'
|
|
41
|
+
},
|
|
42
|
+
nativeParams: {
|
|
43
|
+
title: {
|
|
44
|
+
required: true,
|
|
45
|
+
len: 80
|
|
46
|
+
},
|
|
47
|
+
image: {
|
|
48
|
+
required: true,
|
|
49
|
+
sizes: [150, 50]
|
|
50
|
+
},
|
|
51
|
+
sponsoredBy: {
|
|
52
|
+
required: true
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
})
|
|
58
|
+
describe('isBidRequestValid', function () {
|
|
59
|
+
it('valid bid case', function () {
|
|
60
|
+
let validBid = {
|
|
61
|
+
bidder: 'engageya',
|
|
62
|
+
params: {
|
|
63
|
+
widgetId: 85610,
|
|
64
|
+
websiteId: 91140,
|
|
65
|
+
pageUrl: '[PAGE_URL]'
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
let isValid = spec.isBidRequestValid(validBid);
|
|
69
|
+
expect(isValid).to.equal(true);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('invalid bid case: widgetId and websiteId is not passed', function () {
|
|
73
|
+
let validBid = {
|
|
74
|
+
bidder: 'engageya',
|
|
75
|
+
params: {}
|
|
76
|
+
}
|
|
77
|
+
let isValid = spec.isBidRequestValid(validBid);
|
|
78
|
+
expect(isValid).to.equal(false);
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
it('invalid bid case: widget id must be number', function () {
|
|
82
|
+
let invalidBid = {
|
|
83
|
+
bidder: 'engageya',
|
|
84
|
+
params: {
|
|
85
|
+
widgetId: '157746a',
|
|
86
|
+
websiteId: 91140,
|
|
87
|
+
pageUrl: '[PAGE_URL]'
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
let isValid = spec.isBidRequestValid(invalidBid);
|
|
91
|
+
expect(isValid).to.equal(false);
|
|
92
|
+
})
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
describe('buildRequests', function () {
|
|
96
|
+
it('sends bid request to ENDPOINT via GET', function () {
|
|
97
|
+
const request = spec.buildRequests(bidRequests)[0];
|
|
98
|
+
expect(request.url).to.include(ENDPOINT_URL);
|
|
99
|
+
expect(request.method).to.equal('GET');
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('buildRequests function should not modify original bidRequests object', function () {
|
|
103
|
+
let originalBidRequests = utils.deepClone(bidRequests);
|
|
104
|
+
let request = spec.buildRequests(bidRequests);
|
|
105
|
+
expect(bidRequests).to.deep.equal(originalBidRequests);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('buildRequests function should not modify original nativeBidRequests object', function () {
|
|
109
|
+
let originalBidRequests = utils.deepClone(nativeBidRequests);
|
|
110
|
+
let request = spec.buildRequests(nativeBidRequests);
|
|
111
|
+
expect(nativeBidRequests).to.deep.equal(originalBidRequests);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it('Request params check', function () {
|
|
115
|
+
let request = spec.buildRequests(bidRequests)[0];
|
|
116
|
+
const data = _getUrlVars(request.url)
|
|
117
|
+
expect(parseInt(data.wid)).to.exist.and.to.equal(bidRequests[0].params.widgetId);
|
|
118
|
+
expect(parseInt(data.webid)).to.exist.and.to.equal(bidRequests[0].params.websiteId);
|
|
119
|
+
})
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
describe('interpretResponse', function () {
|
|
123
|
+
it('should return empty array if no response', function () {
|
|
124
|
+
const result = spec.interpretResponse({}, [])
|
|
125
|
+
expect(result).to.be.an('array').that.is.empty
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it('should return empty array if no valid bids', function () {
|
|
129
|
+
let response = {
|
|
130
|
+
recs: [],
|
|
131
|
+
imageWidth: 300,
|
|
132
|
+
imageHeight: 250,
|
|
133
|
+
ireqId: '1d236f7890b',
|
|
134
|
+
pbtypeId: 2
|
|
135
|
+
};
|
|
136
|
+
let request = spec.buildRequests(bidRequests)[0];
|
|
137
|
+
const result = spec.interpretResponse({ body: response }, request)
|
|
138
|
+
expect(result).to.be.an('array').that.is.empty
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it('should interpret native response', function () {
|
|
142
|
+
let serverResponse = {
|
|
143
|
+
recs: [
|
|
144
|
+
{
|
|
145
|
+
ecpm: 0.0920,
|
|
146
|
+
postId: '<!-- CREATIVE ID -->',
|
|
147
|
+
thumbnail_path: 'https://engageya.live/wp-content/uploads/2019/05/images.png',
|
|
148
|
+
domain: 'domain.test',
|
|
149
|
+
title: 'Test title',
|
|
150
|
+
clickUrl: '//click.test',
|
|
151
|
+
url: '//url.test',
|
|
152
|
+
displayName: 'Test displayName',
|
|
153
|
+
trackers: {
|
|
154
|
+
impressionPixels: ['//impression.test'],
|
|
155
|
+
viewPixels: ['//view.test'],
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
],
|
|
159
|
+
imageWidth: 300,
|
|
160
|
+
imageHeight: 250,
|
|
161
|
+
ireqId: '1d236f7890b',
|
|
162
|
+
pbtypeId: 1
|
|
163
|
+
};
|
|
164
|
+
let expectedResult = [
|
|
165
|
+
{
|
|
166
|
+
requestId: '1d236f7890b',
|
|
167
|
+
cpm: 0.0920,
|
|
168
|
+
width: 300,
|
|
169
|
+
height: 250,
|
|
170
|
+
netRevenue: false,
|
|
171
|
+
currency: 'USD',
|
|
172
|
+
creativeId: '<!-- CREATIVE ID -->',
|
|
173
|
+
ttl: 360,
|
|
174
|
+
meta: {
|
|
175
|
+
advertiserDomains: ['domain.test']
|
|
176
|
+
},
|
|
177
|
+
native: {
|
|
178
|
+
title: 'Test title',
|
|
179
|
+
body: '',
|
|
180
|
+
image: {
|
|
181
|
+
url: 'https://engageya.live/wp-content/uploads/2019/05/images.png',
|
|
182
|
+
width: 300,
|
|
183
|
+
height: 250
|
|
184
|
+
},
|
|
185
|
+
privacyLink: '',
|
|
186
|
+
clickUrl: '//click.test',
|
|
187
|
+
displayUrl: '//url.test',
|
|
188
|
+
cta: '',
|
|
189
|
+
sponsoredBy: 'Test displayName',
|
|
190
|
+
impressionTrackers: ['//impression.test', '//view.test'],
|
|
191
|
+
},
|
|
192
|
+
}
|
|
193
|
+
];
|
|
194
|
+
let request = spec.buildRequests(bidRequests)[0];
|
|
195
|
+
let result = spec.interpretResponse({ body: serverResponse }, request);
|
|
196
|
+
expect(result).to.deep.equal(expectedResult);
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it('should interpret display response', function () {
|
|
200
|
+
let serverResponse = {
|
|
201
|
+
recs: [
|
|
202
|
+
{
|
|
203
|
+
ecpm: 0.0920,
|
|
204
|
+
postId: '<!-- CREATIVE ID -->',
|
|
205
|
+
thumbnail_path: 'https://engageya.live/wp-content/uploads/2019/05/images.png',
|
|
206
|
+
domain: 'domain.test',
|
|
207
|
+
title: 'Test title',
|
|
208
|
+
clickUrl: '//click.test',
|
|
209
|
+
url: '//url.test',
|
|
210
|
+
displayName: 'Test displayName',
|
|
211
|
+
trackers: {
|
|
212
|
+
impressionPixels: ['//impression.test'],
|
|
213
|
+
viewPixels: ['//view.test'],
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
],
|
|
217
|
+
imageWidth: 300,
|
|
218
|
+
imageHeight: 250,
|
|
219
|
+
ireqId: '1d236f7890b',
|
|
220
|
+
pbtypeId: 2,
|
|
221
|
+
widget: {
|
|
222
|
+
additionalData: '{"css":".eng_tag_ttl{display:block!important}"}'
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
let expectedResult = [
|
|
226
|
+
{
|
|
227
|
+
requestId: '1d236f7890b',
|
|
228
|
+
cpm: 0.0920,
|
|
229
|
+
width: 300,
|
|
230
|
+
height: 250,
|
|
231
|
+
netRevenue: false,
|
|
232
|
+
currency: 'USD',
|
|
233
|
+
creativeId: '<!-- CREATIVE ID -->',
|
|
234
|
+
ttl: 360,
|
|
235
|
+
meta: {
|
|
236
|
+
advertiserDomains: ['domain.test']
|
|
237
|
+
},
|
|
238
|
+
ad: `<html><body><style>.eng_tag_ttl{display:block!important}</style><div id="ENG_TAG"><a href="//click.test" target=_blank><img class="eng_tag_img" src="https://engageya.live/wp-content/uploads/2019/05/images.png" style="width:300px;height:250px;" alt="Test title"/><div class="eng_tag_brnd" style="display: none">Test displayName</div><div class="eng_tag_ttl" style="display: none">Test title</div></a><div style="position:absolute;left:0px;top:0px;visibility:hidden;"><img src="//impression.test"></div><div style="position:absolute;left:0px;top:0px;visibility:hidden;"><img src="//view.test"></div></div></body></html>`,
|
|
239
|
+
}
|
|
240
|
+
];
|
|
241
|
+
let request = spec.buildRequests(bidRequests)[0];
|
|
242
|
+
let result = spec.interpretResponse({ body: serverResponse }, request);
|
|
243
|
+
expect(result).to.deep.equal(expectedResult);
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
it('should interpret display response without title', function () {
|
|
247
|
+
let serverResponse = {
|
|
248
|
+
recs: [
|
|
249
|
+
{
|
|
250
|
+
ecpm: 0.0920,
|
|
251
|
+
postId: '<!-- CREATIVE ID -->',
|
|
252
|
+
thumbnail_path: 'https://engageya.live/wp-content/uploads/2019/05/images.png',
|
|
253
|
+
domain: 'domain.test',
|
|
254
|
+
title: ' ',
|
|
255
|
+
clickUrl: '//click.test',
|
|
256
|
+
url: '//url.test',
|
|
257
|
+
displayName: 'Test displayName',
|
|
258
|
+
}
|
|
259
|
+
],
|
|
260
|
+
imageWidth: 300,
|
|
261
|
+
imageHeight: 250,
|
|
262
|
+
ireqId: '1d236f7890b',
|
|
263
|
+
pbtypeId: 2,
|
|
264
|
+
};
|
|
265
|
+
let expectedResult = [
|
|
266
|
+
{
|
|
267
|
+
requestId: '1d236f7890b',
|
|
268
|
+
cpm: 0.0920,
|
|
269
|
+
width: 300,
|
|
270
|
+
height: 250,
|
|
271
|
+
netRevenue: false,
|
|
272
|
+
currency: 'USD',
|
|
273
|
+
creativeId: '<!-- CREATIVE ID -->',
|
|
274
|
+
ttl: 360,
|
|
275
|
+
meta: {
|
|
276
|
+
advertiserDomains: ['domain.test']
|
|
277
|
+
},
|
|
278
|
+
ad: `<html><body><div id="ENG_TAG"><a href="//click.test" target=_blank><img class="eng_tag_img" src="https://engageya.live/wp-content/uploads/2019/05/images.png" style="width:300px;height:250px;" alt=" "/></a></div></body></html>`,
|
|
279
|
+
}
|
|
280
|
+
];
|
|
281
|
+
let request = spec.buildRequests(bidRequests)[0];
|
|
282
|
+
let result = spec.interpretResponse({ body: serverResponse }, request);
|
|
283
|
+
expect(result).to.deep.equal(expectedResult);
|
|
284
|
+
});
|
|
285
|
+
})
|
|
286
|
+
})
|
|
@@ -531,9 +531,13 @@ describe('gumgumAdapter', function () {
|
|
|
531
531
|
const jcsi = JSON.stringify(JCSI);
|
|
532
532
|
const bidRequest = spec.buildRequests(bidRequests)[0];
|
|
533
533
|
const actualKeys = Object.keys(JSON.parse(bidRequest.data.jcsi)).sort();
|
|
534
|
-
expect(actualKeys).to.
|
|
534
|
+
expect(actualKeys).to.eql(expectedKeys);
|
|
535
535
|
expect(bidRequest.data.jcsi).to.eq(jcsi);
|
|
536
536
|
});
|
|
537
|
+
it('should include the local time and timezone offset', function () {
|
|
538
|
+
const bidRequest = spec.buildRequests(bidRequests)[0];
|
|
539
|
+
expect(!!bidRequest.data.lt).to.be.true;
|
|
540
|
+
});
|
|
537
541
|
})
|
|
538
542
|
|
|
539
543
|
describe('interpretResponse', function () {
|