prebid.js 6.0.0 → 6.1.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 (61) hide show
  1. package/.babelrc.js +1 -7
  2. package/gulpfile.js +1 -0
  3. package/modules/adheseBidAdapter.js +7 -2
  4. package/modules/adkernelBidAdapter.js +1 -0
  5. package/modules/adlivetechBidAdapter.md +61 -0
  6. package/modules/adomikAnalyticsAdapter.js +10 -4
  7. package/modules/appnexusBidAdapter.js +4 -0
  8. package/modules/codefuelBidAdapter.js +1 -3
  9. package/modules/codefuelBidAdapter.md +3 -3
  10. package/modules/datablocksBidAdapter.js +3 -3
  11. package/modules/deepintentBidAdapter.js +1 -1
  12. package/modules/engageyaBidAdapter.js +68 -54
  13. package/modules/glimpseBidAdapter.js +31 -16
  14. package/modules/gptPreAuction.js +11 -5
  15. package/modules/gridBidAdapter.js +1 -1
  16. package/modules/id5IdSystem.md +6 -6
  17. package/modules/imRtdProvider.js +31 -0
  18. package/modules/ixBidAdapter.js +166 -21
  19. package/modules/merkleIdSystem.js +5 -0
  20. package/modules/nativoBidAdapter.js +27 -1
  21. package/modules/oguryBidAdapter.js +2 -1
  22. package/modules/openxBidAdapter.js +6 -1
  23. package/modules/prebidServerBidAdapter/index.js +3 -3
  24. package/modules/pubmaticBidAdapter.js +2 -0
  25. package/modules/saambaaBidAdapter.js +420 -0
  26. package/modules/saambaaBidAdapter.md +65 -68
  27. package/modules/seedtagBidAdapter.js +6 -0
  28. package/modules/smaatoBidAdapter.js +6 -1
  29. package/modules/sspBCBidAdapter.js +34 -3
  30. package/modules/trustxBidAdapter.js +10 -1
  31. package/modules/vidoomyBidAdapter.js +51 -100
  32. package/modules/visxBidAdapter.js +1 -1
  33. package/modules/yieldlabBidAdapter.js +41 -10
  34. package/modules/yieldlabBidAdapter.md +91 -48
  35. package/package.json +6 -1
  36. package/src/adapterManager.js +14 -8
  37. package/test/spec/modules/adheseBidAdapter_spec.js +27 -1
  38. package/test/spec/modules/adomikAnalyticsAdapter_spec.js +3 -1
  39. package/test/spec/modules/appnexusBidAdapter_spec.js +14 -0
  40. package/test/spec/modules/codefuelBidAdapter_spec.js +1 -1
  41. package/test/spec/modules/datablocksBidAdapter_spec.js +3 -3
  42. package/test/spec/modules/engageyaBidAdapter_spec.js +231 -95
  43. package/test/spec/modules/eplanningBidAdapter_spec.js +8 -8
  44. package/test/spec/modules/glimpseBidAdapter_spec.js +33 -0
  45. package/test/spec/modules/gptPreAuction_spec.js +58 -4
  46. package/test/spec/modules/imRtdProvider_spec.js +25 -0
  47. package/test/spec/modules/ixBidAdapter_spec.js +285 -2
  48. package/test/spec/modules/konduitWrapper_spec.js +0 -1
  49. package/test/spec/modules/merkleIdSystem_spec.js +18 -0
  50. package/test/spec/modules/nativoBidAdapter_spec.js +35 -18
  51. package/test/spec/modules/oguryBidAdapter_spec.js +13 -11
  52. package/test/spec/modules/openxBidAdapter_spec.js +5 -0
  53. package/test/spec/modules/prebidServerBidAdapter_spec.js +19 -2
  54. package/test/spec/modules/seedtagBidAdapter_spec.js +3 -0
  55. package/test/spec/modules/smaatoBidAdapter_spec.js +30 -0
  56. package/test/spec/modules/sspBCBidAdapter_spec.js +33 -3
  57. package/test/spec/modules/trustxBidAdapter_spec.js +42 -0
  58. package/test/spec/modules/vidoomyBidAdapter_spec.js +32 -13
  59. package/test/spec/modules/visxBidAdapter_spec.js +1 -1
  60. package/test/spec/modules/yieldlabBidAdapter_spec.js +81 -0
  61. package/test/spec/unit/core/adapterManager_spec.js +24 -6
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  imRtdSubmodule,
3
3
  storage,
4
+ getBidderFunction,
4
5
  getCustomBidderFunction,
5
6
  setRealTimeData,
6
7
  getRealTimeData,
@@ -47,6 +48,30 @@ describe('imRtdProvider', function () {
47
48
  })
48
49
  })
49
50
 
51
+ describe('getBidderFunction', function () {
52
+ const assumedBidder = [
53
+ 'ix',
54
+ 'pubmatic'
55
+ ];
56
+ assumedBidder.forEach(bidderName => {
57
+ it(`should return bidderFunction with assumed bidder: ${bidderName}`, function () {
58
+ expect(getBidderFunction(bidderName)).to.exist.and.to.be.a('function');
59
+ });
60
+
61
+ it(`should return bid with correct key data: ${bidderName}`, function () {
62
+ const bid = {bidder: bidderName};
63
+ expect(getBidderFunction(bidderName)(bid, {'im_segments': ['12345', '67890']})).to.equal(bid);
64
+ });
65
+ it(`should return bid without data: ${bidderName}`, function () {
66
+ const bid = {bidder: bidderName};
67
+ expect(getBidderFunction(bidderName)(bid, '')).to.equal(bid);
68
+ });
69
+ });
70
+ it(`should return null with unexpected bidder`, function () {
71
+ expect(getBidderFunction('test')).to.equal(null);
72
+ });
73
+ })
74
+
50
75
  describe('getCustomBidderFunction', function () {
51
76
  it('should return config function', function () {
52
77
  const config = {
@@ -2,7 +2,7 @@ import * as utils from 'src/utils.js';
2
2
  import { config } from 'src/config.js';
3
3
  import { expect } from 'chai';
4
4
  import { newBidder } from 'src/adapters/bidderFactory.js';
5
- import { spec } from 'modules/ixBidAdapter.js';
5
+ import { spec, storage, ERROR_CODES } from '../../../modules/ixBidAdapter.js';
6
6
  import { createEidsArray } from 'modules/userId/eids.js';
7
7
 
8
8
  describe('IndexexchangeAdapter', function () {
@@ -353,6 +353,37 @@ describe('IndexexchangeAdapter', function () {
353
353
  ]
354
354
  };
355
355
 
356
+ const DEFAULT_VIDEO_BID_RESPONSE_WITH_MTYPE_SET = {
357
+ cur: 'USD',
358
+ id: '1aa2bb3cc4de',
359
+ seatbid: [
360
+ {
361
+ bid: [
362
+ {
363
+ crid: '12346',
364
+ adomain: ['www.abcd.com'],
365
+ adid: '14851456',
366
+ impid: '1a2b3c4e',
367
+ cid: '3051267',
368
+ price: 110,
369
+ id: '2',
370
+ mtype: 2,
371
+ adm: '<?xml version=\"1.0\" encoding=\"UTF-8\"?><VAST xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"vast.xsd\" version=\"3.0\"> <Ad id=\"488427365\"> <InLine> <AdSystem>Test</AdSystem> <AdTitle>In-Stream Video</AdTitle> </InLine> </Ad></VAST',
372
+ ext: {
373
+ vasturl: 'www.abcd.com/vast',
374
+ errorurl: 'www.abcd.com/error',
375
+ dspid: 51,
376
+ pricelevel: '_110',
377
+ advbrandid: 303326,
378
+ advbrand: 'OECTB'
379
+ }
380
+ }
381
+ ],
382
+ seat: '3971'
383
+ }
384
+ ]
385
+ };
386
+
356
387
  const DEFAULT_OPTION = {
357
388
  gdprConsent: {
358
389
  gdprApplies: true,
@@ -1236,7 +1267,7 @@ describe('IndexexchangeAdapter', function () {
1236
1267
  afterEach(function () {
1237
1268
  config.setConfig({
1238
1269
  ortb2: {}
1239
- })
1270
+ });
1240
1271
  });
1241
1272
 
1242
1273
  it('should not set ixdiag.fpd value if not defined', function () {
@@ -2343,6 +2374,45 @@ describe('IndexexchangeAdapter', function () {
2343
2374
  expect(result[0]).to.deep.equal(expectedParse[0]);
2344
2375
  });
2345
2376
 
2377
+ it('should get correct bid response for video ad and set bid.vastXml when mtype is 2 (video)', function () {
2378
+ const expectedParse = [
2379
+ {
2380
+ requestId: '1a2b3c4e',
2381
+ cpm: 1.1,
2382
+ creativeId: '12346',
2383
+ mediaType: 'video',
2384
+ mediaTypes: {
2385
+ video: {
2386
+ context: 'instream',
2387
+ playerSize: [
2388
+ [
2389
+ 400,
2390
+ 100
2391
+ ]
2392
+ ]
2393
+ }
2394
+ },
2395
+ width: 640,
2396
+ height: 480,
2397
+ currency: 'USD',
2398
+ ttl: 3600,
2399
+ netRevenue: true,
2400
+ vastXml: '<?xml version=\"1.0\" encoding=\"UTF-8\"?><VAST xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"vast.xsd\" version=\"3.0\"> <Ad id=\"488427365\"> <InLine> <AdSystem>Test</AdSystem> <AdTitle>In-Stream Video</AdTitle> </InLine> </Ad></VAST',
2401
+ meta: {
2402
+ networkId: 51,
2403
+ brandId: 303326,
2404
+ brandName: 'OECTB',
2405
+ advertiserDomains: ['www.abcd.com']
2406
+ }
2407
+ }
2408
+ ];
2409
+ const result = spec.interpretResponse({ body: DEFAULT_VIDEO_BID_RESPONSE_WITH_MTYPE_SET }, {
2410
+ data: DEFAULT_BIDDER_REQUEST_DATA, validBidRequests: ONE_VIDEO
2411
+ });
2412
+
2413
+ expect(result[0]).to.deep.equal(expectedParse[0]);
2414
+ });
2415
+
2346
2416
  it('bidrequest should not have page if options is undefined', function () {
2347
2417
  const options = {};
2348
2418
  const validBidWithoutreferInfo = spec.buildRequests(DEFAULT_BANNER_VALID_BID, options);
@@ -2524,4 +2594,217 @@ describe('IndexexchangeAdapter', function () {
2524
2594
  expect(r.regs.coppa).to.be.undefined;
2525
2595
  });
2526
2596
  });
2597
+
2598
+ describe('LocalStorage ixdiag', () => {
2599
+ let TODAY = new Date().toISOString().slice(0, 10);
2600
+ const key = 'ixdiag';
2601
+
2602
+ let sandbox;
2603
+ let setDataInLocalStorageStub;
2604
+ let getDataFromLocalStorageStub;
2605
+ let removeDataFromLocalStorageStub;
2606
+ let localStorageValues = {};
2607
+
2608
+ beforeEach(() => {
2609
+ sandbox = sinon.sandbox.create();
2610
+ setDataInLocalStorageStub = sandbox.stub(storage, 'setDataInLocalStorage').callsFake((key, value) => localStorageValues[key] = value)
2611
+ getDataFromLocalStorageStub = sandbox.stub(storage, 'getDataFromLocalStorage').callsFake((key) => localStorageValues[key])
2612
+ removeDataFromLocalStorageStub = sandbox.stub(storage, 'removeDataFromLocalStorage').callsFake((key) => delete localStorageValues[key])
2613
+ sandbox.stub(storage, 'localStorageIsEnabled').returns(true);
2614
+ });
2615
+
2616
+ afterEach(() => {
2617
+ setDataInLocalStorageStub.restore();
2618
+ getDataFromLocalStorageStub.restore();
2619
+ removeDataFromLocalStorageStub.restore();
2620
+ localStorageValues = {};
2621
+ sandbox.restore();
2622
+
2623
+ config.setConfig({
2624
+ fpd: {},
2625
+ ix: {},
2626
+ })
2627
+ });
2628
+
2629
+ it('should not log error in LocalStorage when there is no logError called.', () => {
2630
+ const bid = DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0];
2631
+ expect(spec.isBidRequestValid(bid)).to.be.true;
2632
+ expect(localStorageValues[key]).to.be.undefined;
2633
+ });
2634
+
2635
+ it('should log ERROR_CODES.BID_SIZE_INVALID_FORMAT in LocalStorage when there is logError called.', () => {
2636
+ const bid = utils.deepClone(DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0]);
2637
+ bid.params.size = ['400', 100];
2638
+
2639
+ expect(spec.isBidRequestValid(bid)).to.be.false;
2640
+ expect(JSON.parse(localStorageValues[key])).to.deep.equal({ [TODAY]: { [ERROR_CODES.BID_SIZE_INVALID_FORMAT]: 1 } });
2641
+ });
2642
+
2643
+ it('should log ERROR_CODES.BID_SIZE_NOT_INCLUDED in LocalStorage when there is logError called.', () => {
2644
+ const bid = utils.deepClone(DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0]);
2645
+ bid.params.size = [407, 100];
2646
+
2647
+ expect(spec.isBidRequestValid(bid)).to.be.false;
2648
+ expect(JSON.parse(localStorageValues[key])).to.deep.equal({ [TODAY]: { [ERROR_CODES.BID_SIZE_NOT_INCLUDED]: 1 } });
2649
+ });
2650
+
2651
+ it('should log ERROR_CODES.PROPERTY_NOT_INCLUDED in LocalStorage when there is logError called.', () => {
2652
+ const bid = utils.deepClone(DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0]);
2653
+ bid.params.video = {};
2654
+
2655
+ expect(spec.isBidRequestValid(bid)).to.be.false;
2656
+ expect(JSON.parse(localStorageValues[key])).to.deep.equal({ [TODAY]: { [ERROR_CODES.PROPERTY_NOT_INCLUDED]: 4 } });
2657
+ });
2658
+
2659
+ it('should log ERROR_CODES.SITE_ID_INVALID_VALUE in LocalStorage when there is logError called.', () => {
2660
+ const bid = utils.deepClone(DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0]);
2661
+ bid.params.siteId = false;
2662
+
2663
+ expect(spec.isBidRequestValid(bid)).to.be.false;
2664
+ expect(JSON.parse(localStorageValues[key])).to.deep.equal({ [TODAY]: { [ERROR_CODES.SITE_ID_INVALID_VALUE]: 1 } });
2665
+ });
2666
+
2667
+ it('should log ERROR_CODES.BID_FLOOR_INVALID_FORMAT in LocalStorage when there is logError called.', () => {
2668
+ const bid = utils.deepClone(DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0]);
2669
+ bid.params.bidFloor = true;
2670
+
2671
+ expect(spec.isBidRequestValid(bid)).to.be.false;
2672
+ expect(JSON.parse(localStorageValues[key])).to.deep.equal({ [TODAY]: { [ERROR_CODES.BID_FLOOR_INVALID_FORMAT]: 1 } });
2673
+ });
2674
+
2675
+ it('should log ERROR_CODES.IX_FPD_EXCEEDS_MAX_SIZE in LocalStorage when there is logError called.', () => {
2676
+ const bid = utils.deepClone(DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0]);
2677
+
2678
+ config.setConfig({
2679
+ ix: {
2680
+ firstPartyData: {
2681
+ cd: Array(1700).join('#')
2682
+ }
2683
+ }
2684
+ });
2685
+
2686
+ expect(spec.isBidRequestValid(bid)).to.be.true;
2687
+ spec.buildRequests([bid]);
2688
+ expect(JSON.parse(localStorageValues[key])).to.deep.equal({ [TODAY]: { [ERROR_CODES.IX_FPD_EXCEEDS_MAX_SIZE]: 2 } });
2689
+ });
2690
+
2691
+ it('should log ERROR_CODES.EXCEEDS_MAX_SIZE in LocalStorage when there is logError called.', () => {
2692
+ const bid = utils.deepClone(DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0]);
2693
+ bid.bidderRequestId = Array(8000).join('#');
2694
+
2695
+ expect(spec.isBidRequestValid(bid)).to.be.true;
2696
+ spec.buildRequests([bid]);
2697
+ expect(JSON.parse(localStorageValues[key])).to.deep.equal({ [TODAY]: { [ERROR_CODES.EXCEEDS_MAX_SIZE]: 2 } });
2698
+ });
2699
+
2700
+ it('should log ERROR_CODES.PB_FPD_EXCEEDS_MAX_SIZE in LocalStorage when there is logError called.', () => {
2701
+ const bid = utils.deepClone(DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0]);
2702
+
2703
+ config.setConfig({
2704
+ fpd: {
2705
+ site: {
2706
+ data: {
2707
+ pageType: Array(5700).join('#')
2708
+ }
2709
+ }
2710
+ }
2711
+ });
2712
+
2713
+ expect(spec.isBidRequestValid(bid)).to.be.true;
2714
+ spec.buildRequests([bid]);
2715
+ expect(JSON.parse(localStorageValues[key])).to.deep.equal({ [TODAY]: { [ERROR_CODES.PB_FPD_EXCEEDS_MAX_SIZE]: 2 } });
2716
+ });
2717
+
2718
+ it('should log ERROR_CODES.VIDEO_DURATION_INVALID in LocalStorage when there is logError called.', () => {
2719
+ const bid = utils.deepClone(DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0]);
2720
+ bid.params.video.minduration = 1;
2721
+ bid.params.video.maxduration = 0;
2722
+
2723
+ expect(spec.isBidRequestValid(bid)).to.be.true;
2724
+ spec.buildRequests([bid]);
2725
+ expect(JSON.parse(localStorageValues[key])).to.deep.equal({ [TODAY]: { [ERROR_CODES.VIDEO_DURATION_INVALID]: 2 } });
2726
+ });
2727
+
2728
+ it('should increment errors for errorCode', () => {
2729
+ const bid = utils.deepClone(DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0]);
2730
+ bid.params.video = {};
2731
+
2732
+ expect(spec.isBidRequestValid(bid)).to.be.false;
2733
+ expect(JSON.parse(localStorageValues[key])).to.deep.equal({ [TODAY]: { [ERROR_CODES.PROPERTY_NOT_INCLUDED]: 4 } });
2734
+
2735
+ expect(spec.isBidRequestValid(bid)).to.be.false;
2736
+ expect(JSON.parse(localStorageValues[key])).to.deep.equal({ [TODAY]: { [ERROR_CODES.PROPERTY_NOT_INCLUDED]: 8 } });
2737
+ });
2738
+
2739
+ it('should add new errorCode to ixdiag.', () => {
2740
+ let bid = utils.deepClone(DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0]);
2741
+ bid.params.size = ['400', 100];
2742
+
2743
+ expect(spec.isBidRequestValid(bid)).to.be.false;
2744
+ expect(JSON.parse(localStorageValues[key])).to.deep.equal({ [TODAY]: { [ERROR_CODES.BID_SIZE_INVALID_FORMAT]: 1 } });
2745
+
2746
+ bid = utils.deepClone(DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0]);
2747
+ bid.params.siteId = false;
2748
+
2749
+ expect(spec.isBidRequestValid(bid)).to.be.false;
2750
+ expect(JSON.parse(localStorageValues[key])).to.deep.equal({
2751
+ [TODAY]: {
2752
+ [ERROR_CODES.BID_SIZE_INVALID_FORMAT]: 1,
2753
+ [ERROR_CODES.SITE_ID_INVALID_VALUE]: 1
2754
+ }
2755
+ });
2756
+ });
2757
+
2758
+ it('should clear errors with successful response', () => {
2759
+ const ixdiag = { [TODAY]: { '1': 1, '3': 8, '4': 1 } };
2760
+ setDataInLocalStorageStub(key, JSON.stringify(ixdiag));
2761
+
2762
+ expect(JSON.parse(localStorageValues[key])).to.deep.equal(ixdiag);
2763
+
2764
+ const request = DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0];
2765
+ expect(spec.isBidRequestValid(request)).to.be.true;
2766
+
2767
+ const data = {
2768
+ ...utils.deepClone(DEFAULT_BIDDER_REQUEST_DATA[0]),
2769
+ r: JSON.stringify({
2770
+ id: '345',
2771
+ imp: [
2772
+ {
2773
+ id: '1a2b3c4e',
2774
+ }
2775
+ ],
2776
+ ext: {
2777
+ ixdiag: {
2778
+ err: {
2779
+ '4': 8
2780
+ }
2781
+ }
2782
+ }
2783
+ }),
2784
+ };
2785
+
2786
+ const validBidRequests = [
2787
+ DEFAULT_MULTIFORMAT_BANNER_VALID_BID[0],
2788
+ DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0]
2789
+ ];
2790
+
2791
+ spec.interpretResponse({ body: DEFAULT_BANNER_BID_RESPONSE }, { data, validBidRequests });
2792
+
2793
+ expect(localStorageValues[key]).to.be.undefined;
2794
+ });
2795
+
2796
+ it('should clear errors after 7 day expiry errorCode', () => {
2797
+ const EXPIRED_DATE = '2019-12-12';
2798
+
2799
+ const ixdiag = { [EXPIRED_DATE]: { '1': 1, '3': 8, '4': 1 }, [TODAY]: { '3': 8, '4': 1 } };
2800
+ setDataInLocalStorageStub(key, JSON.stringify(ixdiag));
2801
+
2802
+ const bid = utils.deepClone(DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0]);
2803
+ bid.params.size = ['400', 100];
2804
+
2805
+ expect(spec.isBidRequestValid(bid)).to.be.false;
2806
+ expect(JSON.parse(localStorageValues[key])[EXPIRED_DATE]).to.be.undefined;
2807
+ expect(JSON.parse(localStorageValues[key])).to.deep.equal({ [TODAY]: { '1': 1, '3': 8, '4': 1 } })
2808
+ });
2809
+ });
2527
2810
  });
@@ -53,7 +53,6 @@ describe('The Konduit vast wrapper module', function () {
53
53
  const callback = sinon.spy();
54
54
  processBids({ bid, callback });
55
55
  server.respond();
56
-
57
56
  expect(server.requests.length).to.equal(1);
58
57
 
59
58
  const requestBody = JSON.parse(server.requests[0].requestBody);
@@ -192,6 +192,24 @@ describe('Merkle System', function () {
192
192
 
193
193
  expect(id.id).to.exist.and.to.equal(storedId);
194
194
  });
195
+ it('extendId() should warn on missing endpoint', function () {
196
+ let config = {
197
+ params: {
198
+ ...CONFIG_PARAMS,
199
+ endpoint: undefined
200
+ },
201
+ storage: STORAGE_PARAMS
202
+ };
203
+
204
+ let yesterday = new Date(Date.now() - 86400000).toUTCString();
205
+ let storedId = {value: 'Merkle_Stored_ID', date: yesterday};
206
+
207
+ let submoduleCallback = merkleIdSubmodule.extendId(config, undefined,
208
+ storedId).callback;
209
+ submoduleCallback(callbackSpy);
210
+ expect(callbackSpy.calledOnce).to.be.true;
211
+ expect(utils.logWarn.args[0][0]).to.exist.and.to.equal('User ID - merkleId submodule endpoint string is not defined');
212
+ });
195
213
 
196
214
  it('extendId() callback on configured storageParam.refreshInSeconds', function () {
197
215
  let config = {
@@ -8,29 +8,46 @@ import { spec } from 'modules/nativoBidAdapter.js'
8
8
  describe('nativoBidAdapterTests', function () {
9
9
  describe('isBidRequestValid', function () {
10
10
  let bid = {
11
- bidder: 'nativo',
12
- params: {
13
- placementId: '10433394',
14
- },
15
- adUnitCode: 'adunit-code',
16
- sizes: [
17
- [300, 250],
18
- [300, 600],
19
- ],
20
- bidId: '27b02036ccfa6e',
21
- bidderRequestId: '1372cd8bd8d6a8',
22
- auctionId: 'cfc467e4-2707-48da-becb-bcaab0b2c114',
11
+ bidder: 'nativo'
23
12
  }
24
13
 
25
- it('should return true when required params found', function () {
14
+ it('should return true if no params found', function () {
15
+ expect(spec.isBidRequestValid(bid)).to.equal(true)
16
+ })
17
+
18
+ it('should return true for valid placementId value', function () {
19
+ bid.params = {
20
+ placementId: '10433394',
21
+ }
22
+ expect(spec.isBidRequestValid(bid)).to.equal(true)
23
+ })
24
+
25
+ it('should return true for valid placementId value', function () {
26
+ bid.params = {
27
+ placementId: 10433394,
28
+ }
29
+ expect(spec.isBidRequestValid(bid)).to.equal(true)
30
+ })
31
+
32
+ it('should return false for invalid placementId value', function () {
33
+ bid.params = {
34
+ placementId: true,
35
+ }
36
+ expect(spec.isBidRequestValid(bid)).to.equal(false)
37
+ })
38
+
39
+ it('should return true for valid placementId value', function () {
40
+ bid.params = {
41
+ url: 'www.test.com',
42
+ }
26
43
  expect(spec.isBidRequestValid(bid)).to.equal(true)
27
44
  })
28
45
 
29
- it('should return true when params are not passed', function () {
30
- let bid2 = Object.assign({}, bid)
31
- delete bid2.params
32
- bid2.params = {}
33
- expect(spec.isBidRequestValid(bid2)).to.equal(true)
46
+ it('should return false for invalid placementId value', function () {
47
+ bid.params = {
48
+ url: 4567890,
49
+ }
50
+ expect(spec.isBidRequestValid(bid)).to.equal(false)
34
51
  })
35
52
  })
36
53
 
@@ -119,7 +119,7 @@ describe('OguryBidAdapter', function () {
119
119
  };
120
120
  });
121
121
 
122
- it('should return sync array with two elements of type image', () => {
122
+ it('should return syncs array with two elements of type image', () => {
123
123
  const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent);
124
124
 
125
125
  expect(userSyncs).to.have.lengthOf(2);
@@ -129,7 +129,7 @@ describe('OguryBidAdapter', function () {
129
129
  expect(userSyncs[1].url).to.contain('https://ms-cookie-sync.presage.io/ttd/init-sync');
130
130
  });
131
131
 
132
- it('should set the same source as query param', () => {
132
+ it('should set the source as query param', () => {
133
133
  const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent);
134
134
  expect(userSyncs[0].url).to.contain('source=prebid');
135
135
  expect(userSyncs[1].url).to.contain('source=prebid');
@@ -146,7 +146,7 @@ describe('OguryBidAdapter', function () {
146
146
  expect(spec.getUserSyncs(syncOptions, [], gdprConsent)).to.have.lengthOf(0);
147
147
  });
148
148
 
149
- it('should return sync array with two elements of type image when consentString is undefined', () => {
149
+ it('should return syncs array with two elements of type image when consentString is undefined', () => {
150
150
  gdprConsent = {
151
151
  gdprApplies: true,
152
152
  consentString: undefined
@@ -160,7 +160,7 @@ describe('OguryBidAdapter', function () {
160
160
  expect(userSyncs[1].url).to.equal('https://ms-cookie-sync.presage.io/ttd/init-sync?iab_string=&source=prebid')
161
161
  });
162
162
 
163
- it('should return sync array with two elements of type image when consentString is null', () => {
163
+ it('should return syncs array with two elements of type image when consentString is null', () => {
164
164
  gdprConsent = {
165
165
  gdprApplies: true,
166
166
  consentString: null
@@ -174,7 +174,7 @@ describe('OguryBidAdapter', function () {
174
174
  expect(userSyncs[1].url).to.equal('https://ms-cookie-sync.presage.io/ttd/init-sync?iab_string=&source=prebid')
175
175
  });
176
176
 
177
- it('should return sync array with two elements of type image when gdprConsent is undefined', () => {
177
+ it('should return syncs array with two elements of type image when gdprConsent is undefined', () => {
178
178
  gdprConsent = undefined;
179
179
 
180
180
  const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent);
@@ -185,7 +185,7 @@ describe('OguryBidAdapter', function () {
185
185
  expect(userSyncs[1].url).to.equal('https://ms-cookie-sync.presage.io/ttd/init-sync?iab_string=&source=prebid')
186
186
  });
187
187
 
188
- it('should return sync array with two elements of type image when gdprConsent is null', () => {
188
+ it('should return syncs array with two elements of type image when gdprConsent is null', () => {
189
189
  gdprConsent = null;
190
190
 
191
191
  const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent);
@@ -196,7 +196,7 @@ describe('OguryBidAdapter', function () {
196
196
  expect(userSyncs[1].url).to.equal('https://ms-cookie-sync.presage.io/ttd/init-sync?iab_string=&source=prebid')
197
197
  });
198
198
 
199
- it('should return sync array with two elements of type image when gdprConsent is null and gdprApplies is false', () => {
199
+ it('should return syncs array with two elements of type image when gdprConsent is null and gdprApplies is false', () => {
200
200
  gdprConsent = {
201
201
  gdprApplies: false,
202
202
  consentString: null
@@ -210,7 +210,7 @@ describe('OguryBidAdapter', function () {
210
210
  expect(userSyncs[1].url).to.equal('https://ms-cookie-sync.presage.io/ttd/init-sync?iab_string=&source=prebid')
211
211
  });
212
212
 
213
- it('should return sync array with two elements of type image when gdprConsent is empty string and gdprApplies is false', () => {
213
+ it('should return syncs array with two elements of type image when gdprConsent is empty string and gdprApplies is false', () => {
214
214
  gdprConsent = {
215
215
  gdprApplies: false,
216
216
  consentString: ''
@@ -240,7 +240,8 @@ describe('OguryBidAdapter', function () {
240
240
  w: 300,
241
241
  h: 250
242
242
  }]
243
- }
243
+ },
244
+ ext: bidRequests[0].params
244
245
  }, {
245
246
  id: bidRequests[1].bidId,
246
247
  tagid: bidRequests[1].params.adUnitId,
@@ -250,7 +251,8 @@ describe('OguryBidAdapter', function () {
250
251
  w: 600,
251
252
  h: 500
252
253
  }]
253
- }
254
+ },
255
+ ext: bidRequests[1].params
254
256
  }],
255
257
  regs: {
256
258
  ext: {
@@ -549,7 +551,7 @@ describe('OguryBidAdapter', function () {
549
551
  xhr.restore()
550
552
  })
551
553
 
552
- it('should send notification on bid timeout', function() {
554
+ it('should send on bid timeout notification', function() {
553
555
  const bid = {
554
556
  ad: '<img style="width: 300px; height: 250px;" src="https://assets.afcdn.com/recipe/20190529/93153_w1024h768c1cx2220cy1728cxt0cyt0cxb4441cyb3456.jpg" alt="cookies" />',
555
557
  cpm: 3
@@ -1102,6 +1102,11 @@ describe('OpenxAdapter', function () {
1102
1102
  mwOpenLinkId: '1111-mwopenlinkid',
1103
1103
  dapId: '1111-dapId',
1104
1104
  amxId: '1111-amxid',
1105
+ kpuid: '1111-kpuid',
1106
+ publinkId: '1111-publinkid',
1107
+ naveggId: '1111-naveggid',
1108
+ imuid: '1111-imuid',
1109
+ adtelligentId: '1111-adtelligentid'
1105
1110
  };
1106
1111
 
1107
1112
  // generates the same set of tests for each id provider
@@ -507,6 +507,17 @@ describe('S2S Adapter', function () {
507
507
  resetSyncedStatus();
508
508
  });
509
509
 
510
+ it('should set id to auction ID and source.tid to tid', function () {
511
+ config.setConfig({ s2sConfig: CONFIG });
512
+
513
+ adapter.callBids(OUTSTREAM_VIDEO_REQUEST, BID_REQUESTS, addBidResponse, done, ajax);
514
+
515
+ const requestBid = JSON.parse(server.requests[0].requestBody);
516
+ expect(requestBid.id).to.equal('173afb6d132ba3');
517
+ expect(requestBid.source).to.be.an('object');
518
+ expect(requestBid.source.tid).to.equal('437fbbf5-33f5-487a-8e16-a7112903cfe5');
519
+ });
520
+
510
521
  it('should block request if config did not define p1Consent URL in endpoint object config', function() {
511
522
  let badConfig = utils.deepClone(CONFIG);
512
523
  badConfig.endpoint = { noP1Consent: 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction' };
@@ -1705,7 +1716,7 @@ describe('S2S Adapter', function () {
1705
1716
  expect(parsedRequestBody.ext.prebid.channel).to.deep.equal({name: 'pbjs', version: 'v$prebid.version$'});
1706
1717
  });
1707
1718
 
1708
- it('does not set pbjs version in request if channel does exist in s2sConfig', () => {
1719
+ it('extPrebid is now mergedDeep -> should include default channel as well', () => {
1709
1720
  const s2sBidRequest = utils.deepClone(REQUEST);
1710
1721
  const bidRequests = utils.deepClone(BID_REQUESTS);
1711
1722
 
@@ -1714,7 +1725,13 @@ describe('S2S Adapter', function () {
1714
1725
  adapter.callBids(s2sBidRequest, bidRequests, addBidResponse, done, ajax);
1715
1726
 
1716
1727
  const parsedRequestBody = JSON.parse(server.requests[0].requestBody);
1717
- expect(parsedRequestBody.ext.prebid.channel).to.deep.equal({test: 1});
1728
+
1729
+ // extPrebid is now deep merged with
1730
+ expect(parsedRequestBody.ext.prebid.channel).to.deep.equal({
1731
+ name: 'pbjs',
1732
+ test: 1,
1733
+ version: 'v$prebid.version$'
1734
+ });
1718
1735
  });
1719
1736
 
1720
1737
  it('passes first party data in request', () => {
@@ -274,6 +274,9 @@ describe('Seedtag Adapter', function() {
274
274
  expect(data.ga).to.equal(true)
275
275
  expect(data.cd).to.equal('consentString')
276
276
  })
277
+ it('should expose gvlid', function() {
278
+ expect(spec.gvlid).to.equal(157)
279
+ })
277
280
  })
278
281
  })
279
282
 
@@ -287,6 +287,13 @@ describe('smaatoBidAdapterTest', () => {
287
287
  expect(req.regs.ext.us_privacy).to.equal('uspConsentString');
288
288
  });
289
289
 
290
+ it('sends no schain if no schain exists', () => {
291
+ const reqs = spec.buildRequests([singleBannerBidRequest], defaultBidderRequest);
292
+
293
+ const req = extractPayloadOfFirstAndOnlyRequest(reqs);
294
+ expect(req.source.ext.schain).to.not.exist;
295
+ });
296
+
290
297
  it('sends tmax', () => {
291
298
  const reqs = spec.buildRequests([singleBannerBidRequest], defaultBidderRequest);
292
299
 
@@ -854,6 +861,29 @@ describe('smaatoBidAdapterTest', () => {
854
861
  expect(req.user.ext.eids).to.have.length(2);
855
862
  });
856
863
  });
864
+
865
+ describe('schain in request', () => {
866
+ it('schain is added to source.ext.schain', () => {
867
+ const schain = {
868
+ ver: '1.0',
869
+ complete: 1,
870
+ nodes: [
871
+ {
872
+ 'asi': 'asi',
873
+ 'sid': 'sid',
874
+ 'rid': 'rid',
875
+ 'hp': 1
876
+ }
877
+ ]
878
+ };
879
+ const bidRequestWithSchain = Object.assign({}, singleBannerBidRequest, {schain: schain});
880
+
881
+ const reqs = spec.buildRequests([bidRequestWithSchain], defaultBidderRequest);
882
+
883
+ const req = extractPayloadOfFirstAndOnlyRequest(reqs);
884
+ expect(req.source.ext.schain).to.deep.equal(schain);
885
+ });
886
+ });
857
887
  });
858
888
 
859
889
  describe('interpretResponse', () => {