From 74e38ca0adc4da66713e01f58a919869de0f660b Mon Sep 17 00:00:00 2001 From: Gabriel Chicoye Date: Wed, 2 Apr 2025 13:05:11 +0200 Subject: [PATCH] placement support added --- modules/nexx360BidAdapter.js | 58 +- modules/nexx360BidAdapter.md | 2 +- test/spec/modules/nexx360BidAdapter_spec.js | 806 +++++++++++--------- 3 files changed, 467 insertions(+), 399 deletions(-) diff --git a/modules/nexx360BidAdapter.js b/modules/nexx360BidAdapter.js index 4d63e739cba..a2c1d57ffae 100644 --- a/modules/nexx360BidAdapter.js +++ b/modules/nexx360BidAdapter.js @@ -22,7 +22,7 @@ const OUTSTREAM_RENDERER_URL = 'https://acdn.adnxs.com/video/outstream/ANOutstre const BIDDER_CODE = 'nexx360'; const REQUEST_URL = 'https://fast.nexx360.io/booster'; const PAGE_VIEW_ID = generateUUID(); -const BIDDER_VERSION = '4.3'; +const BIDDER_VERSION = '5.0'; const GVLID = 965; const NEXXID_KEY = 'nexx360_storage'; @@ -35,7 +35,7 @@ const ALIASES = [ { code: 'pubtech' }, { code: '1accord', gvlid: 965 }, { code: 'easybid', gvlid: 1068 }, - { code: 'prismassp', gvlid: 965 }, + { code: 'prismassp', gvlid: 965 } ]; export const storage = getStorageManager({ @@ -66,15 +66,9 @@ export function getNexx360LocalStorage() { } } -function getAdContainer(container) { - if (document.getElementById(container)) { - return document.getElementById(container); - } -} - /** * Get the AMX ID - * @return {string | false } false if localstorageNotEnabled + * @return { string | false } false if localstorageNotEnabled */ export function getAmxId() { if (!storage.localStorageIsEnabled()) { @@ -91,40 +85,36 @@ const converter = ortbConverter({ ttl: 90, // default bidResponse.ttl (when not specified in ORTB response.seatbid[].bid[].exp) }, imp(buildImp, bidRequest, context) { - // console.log(bidRequest, context); const imp = buildImp(bidRequest, context); - const tagid = bidRequest.params.adUnitName ? bidRequest.params.adUnitName : bidRequest.adUnitCode; - deepSetValue(imp, 'tagid', tagid); + deepSetValue(imp, 'tagid', bidRequest.adUnitCode); deepSetValue(imp, 'ext.adUnitCode', bidRequest.adUnitCode); - const divId = bidRequest.params.divId ? bidRequest.params.divId : bidRequest.adUnitCode; + if (bidRequest.params.adUnitPath) deepSetValue(imp, 'ext.adUnitPath', bidRequest.params.adUnitPath); + if (bidRequest.params.adUnitName) deepSetValue(imp, 'ext.adUnitName', bidRequest.params.adUnitName); + const divId = bidRequest.params.divId || bidRequest.adUnitCode; deepSetValue(imp, 'ext.divId', divId); - const slotEl = getAdContainer(divId); + const slotEl = document.getElementById(divId); if (slotEl) { deepSetValue(imp, 'ext.dimensions.slotW', slotEl.offsetWidth); deepSetValue(imp, 'ext.dimensions.slotH', slotEl.offsetHeight); deepSetValue(imp, 'ext.dimensions.cssMaxW', slotEl.style?.maxWidth); deepSetValue(imp, 'ext.dimensions.cssMaxH', slotEl.style?.maxHeight); } - deepSetValue(imp, 'ext.nexx360', bidRequest.params.tagId); - deepSetValue(imp, 'ext.nexx360.tagId', bidRequest.params.tagId); - deepSetValue(imp, 'ext.nexx360.videoTagId', bidRequest.params.videoTagId); - deepSetValue(imp, 'ext.nexx360.allBids', bidRequest.params.allBids); + if (bidRequest.params.tagId) deepSetValue(imp, 'ext.nexx360.tagId', bidRequest.params.tagId); + if (bidRequest.params.placement) deepSetValue(imp, 'ext.nexx360.placement', bidRequest.params.placement); + if (bidRequest.params.videoTagId) deepSetValue(imp, 'ext.nexx360.videoTagId', bidRequest.params.videoTagId); + if (bidRequest.params.allBids) deepSetValue(imp, 'ext.nexx360.allBids', bidRequest.params.allBids); if (imp.video) { const playerSize = deepAccess(bidRequest, 'mediaTypes.video.playerSize'); const videoContext = deepAccess(bidRequest, 'mediaTypes.video.context'); deepSetValue(imp, 'video.ext.playerSize', playerSize); deepSetValue(imp, 'video.ext.context', videoContext); } - - if (bidRequest.params.adUnitName) deepSetValue(imp, 'ext.adUnitName', bidRequest.params.adUnitName); - if (bidRequest.params.adUnitPath) deepSetValue(imp, 'ext.adUnitPath', bidRequest.params.adUnitPath); return imp; }, request(buildRequest, imps, bidderRequest, context) { const request = buildRequest(imps, bidderRequest, context); const nexx360LocalStorage = getNexx360LocalStorage(); if (nexx360LocalStorage) { - deepSetValue(request, 'ext.nexx360Id', nexx360LocalStorage.nexx360Id); deepSetValue(request, 'ext.localStorage.nexx360Id', nexx360LocalStorage.nexx360Id); } const amxId = getAmxId(); @@ -174,8 +164,8 @@ function isBidRequestValid(bid) { logError('bid.params.allBids needs to be a boolean'); return false; } - if (!bid.params.tagId && !bid.params.videoTagId && !bid.params.nativeTagId) { - logError('bid.params.tagId or bid.params.videoTagId or bid.params.nativeTagId must be defined'); + if (!bid.params.tagId && !bid.params.videoTagId && !bid.params.nativeTagId && !bid.params.placement) { + logError('bid.params.tagId or bid.params.videoTagId or bid.params.nativeTagId or bid.params.placement must be defined'); return false; } return true; @@ -212,16 +202,17 @@ function interpretResponse(serverResponse) { const { bidderSettings } = getGlobal(); const allowAlternateBidderCodes = bidderSettings && bidderSettings.standard ? bidderSettings.standard.allowAlternateBidderCodes : false; - let bids = []; - respBody.seatbid.forEach(seatbid => { - bids = [...bids, ...seatbid.bid.map(bid => { + let responses = []; + for (let i = 0; i < respBody.seatbid.length; i++) { + const seatbid = respBody.seatbid[i]; + for (let j = 0; j < seatbid.bid.length; j++) { + const bid = seatbid.bid[j]; const response = { requestId: bid.impid, cpm: bid.price, width: bid.w, height: bid.h, creativeId: bid.crid, - dealId: bid.dealid, currency: respBody.cur, netRevenue: true, ttl: 120, @@ -231,6 +222,7 @@ function interpretResponse(serverResponse) { demandSource: bid.ext.ssp, }, }; + if (bid.dealid) response.dealid = bid.dealid; if (allowAlternateBidderCodes) response.bidderCode = `n360_${bid.ext.ssp}`; if (bid.ext.mediaType === BANNER) { @@ -244,7 +236,7 @@ function interpretResponse(serverResponse) { if (bid.ext.mediaType === OUTSTREAM) { response.renderer = createRenderer(bid, OUTSTREAM_RENDERER_URL); - response.divId = bid.ext.divId + if (bid.ext.divId) response.divId = bid.ext.divId }; if (bid.ext.mediaType === NATIVE) { try { @@ -253,10 +245,10 @@ function interpretResponse(serverResponse) { } } catch (e) {} } - return response; - })]; - }); - return bids; + responses.push(response); + } + } + return responses; } /** diff --git a/modules/nexx360BidAdapter.md b/modules/nexx360BidAdapter.md index 5935b568a13..d9038bfc0b1 100644 --- a/modules/nexx360BidAdapter.md +++ b/modules/nexx360BidAdapter.md @@ -10,7 +10,7 @@ Maintainer: gabriel@nexx360.io Connects to Nexx360 network for bids. -To use us as a bidder you must have an account and an active "tagId" on our Nexx360 platform. +To use us as a bidder you must have an account and an active "tagId" or "placement" on our Nexx360 platform. # Test Parameters diff --git a/test/spec/modules/nexx360BidAdapter_spec.js b/test/spec/modules/nexx360BidAdapter_spec.js index 07d5313a788..b8bed5f01de 100644 --- a/test/spec/modules/nexx360BidAdapter_spec.js +++ b/test/spec/modules/nexx360BidAdapter_spec.js @@ -5,271 +5,180 @@ import { import { sandbox } from 'sinon'; import { getAmxId } from '../../../modules/nexx360BidAdapter'; -const instreamResponse = { - 'id': '2be64380-ba0c-405a-ab53-51f51c7bde51', - 'cur': 'USD', - 'seatbid': [ - { - 'bid': [ - { - 'id': '8275140264321181514', - 'impid': '263cba3b8bfb72', - 'price': 5, - 'adomain': [ - 'appnexus.com' - ], - 'crid': '97517771', - 'h': 1, - 'w': 1, - 'adm': '\n \n \n Nexx360 Wrapper\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ', - 'ext': { - 'mediaType': 'instream', - 'ssp': 'appnexus', - 'divId': 'video1', - 'adUnitCode': 'video1', - } - } - ], - 'seat': 'appnexus' - } - ], - 'ext': { - 'cookies': [] - } -}; - -describe('Nexx360 bid adapter tests', function () { - const DISPLAY_BID_REQUEST = { - 'id': '77b3f21a-e0df-4495-8bce-4e8a1d2309c1', - 'imp': [ - {'id': '2b4d8fc1c1c7ea', - 'tagid': 'div-1', - 'ext': {'divId': 'div-1', 'nexx360': {'account': '1067', 'tag_id': 'luvxjvgn'}}, - 'banner': {'format': [{'w': 300, 'h': 250}, {'w': 300, 'h': 600}], 'topframe': 1}}, {'id': '38fc428ab96638', 'tagid': 'div-2', 'ext': {'divId': 'div-2', 'nexx360': {'account': '1067', 'tag_id': 'luvxjvgn'}}, 'banner': {'format': [{'w': 728, 'h': 90}, {'w': 970, 'h': 250}], 'topframe': 1}}], - 'cur': ['USD'], - 'at': 1, - 'tmax': 3000, - 'site': {'page': 'https://test.nexx360.io/adapter/index.html?nexx360_test=1', 'domain': 'test.nexx360.io'}, - 'regs': {'coppa': 0, 'ext': {'gdpr': 1}}, - 'device': { - 'dnt': 0, - 'h': 844, - 'w': 390, - 'ua': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1', - 'language': 'fr' - }, - 'user': { - 'ext': { - 'consent': 'CPgocUAPgocUAAKAsAENCkCsAP_AAH_AAAqIJDtd_H__bW9r-f5_aft0eY1P9_r37uQzDhfNk-8F3L_W_LwX52E7NF36tq4KmR4ku1LBIUNlHMHUDUmwaokVryHsak2cpzNKJ7BEknMZOydYGF9vmxtj-QKY7_5_d3bx2D-t_9v239z3z81Xn3d53-_03LCdV5_9Dfn9fR_bc9KPt_58v8v8_____3_e__3_7994JEAEmGrcQBdmWODNoGEUCIEYVhIVQKACCgGFogMAHBwU7KwCfWECABAKAIwIgQ4AowIBAAAJAEhEAEgRYIAAARAIAAQAIhEIAGBgEFgBYGAQAAgGgYohQACBIQZEBEUpgQFQJBAa2VCCUF0hphAHWWAFBIjYqABEEgIrAAEBYOAYIkBKxYIEmKN8gBGCFAKJUK1EAAAA.YAAAAAAAAAAA', - 'ConsentedProvidersSettings': {'consented_providers': '1~39.43.46.55.61.70.83.89.93.108.117.122.124.131.135.136.143.144.147.149.159.162.167.171.192.196.202.211.218.228.230.239.241.259.266.272.286.291.311.317.322.323.326.327.338.367.371.385.389.394.397.407.413.415.424.430.436.445.449.453.482.486.491.494.495.501.503.505.522.523.540.550.559.560.568.574.576.584.587.591.733.737.745.787.802.803.817.820.821.829.839.864.867.874.899.904.922.931.938.979.981.985.1003.1024.1027.1031.1033.1040.1046.1051.1053.1067.1085.1092.1095.1097.1099.1107.1127.1135.1143.1149.1152.1162.1166.1186.1188.1201.1205.1211.1215.1226.1227.1230.1252.1268.1270.1276.1284.1286.1290.1301.1307.1312.1345.1356.1364.1365.1375.1403.1415.1416.1419.1440.1442.1449.1455.1456.1465.1495.1512.1516.1525.1540.1548.1555.1558.1564.1570.1577.1579.1583.1584.1591.1603.1616.1638.1651.1653.1665.1667.1677.1678.1682.1697.1699.1703.1712.1716.1721.1725.1732.1745.1750.1765.1769.1782.1786.1800.1808.1810.1825.1827.1832.1838.1840.1842.1843.1845.1859.1866.1870.1878.1880.1889.1899.1917.1929.1942.1944.1962.1963.1964.1967.1968.1969.1978.2003.2007.2008.2027.2035.2039.2044.2047.2052.2056.2064.2068.2070.2072.2074.2088.2090.2103.2107.2109.2115.2124.2130.2133.2137.2140.2145.2147.2150.2156.2166.2177.2183.2186.2202.2205.2216.2219.2220.2222.2225.2234.2253.2264.2279.2282.2292.2299.2305.2309.2312.2316.2322.2325.2328.2331.2334.2335.2336.2337.2343.2354.2357.2358.2359.2370.2376.2377.2387.2392.2394.2400.2403.2405.2407.2411.2414.2416.2418.2425.2440.2447.2459.2461.2462.2465.2468.2472.2477.2481.2484.2486.2488.2493.2496.2497.2498.2499.2501.2510.2511.2517.2526.2527.2532.2534.2535.2542.2552.2563.2564.2567.2568.2569.2571.2572.2575.2577.2583.2584.2596.2601.2604.2605.2608.2609.2610.2612.2614.2621.2628.2629.2633.2634.2636.2642.2643.2645.2646.2647.2650.2651.2652.2656.2657.2658.2660.2661.2669.2670.2677.2681.2684.2686.2687.2690.2695.2698.2707.2713.2714.2729.2739.2767.2768.2770.2772.2784.2787.2791.2792.2798.2801.2805.2812.2813.2816.2817.2818.2821.2822.2827.2830.2831.2834.2838.2839.2840.2844.2846.2847.2849.2850.2852.2854.2856.2860.2862.2863.2865.2867.2869.2873.2874.2875.2876.2878.2880.2881.2882.2883.2884.2886.2887.2888.2889.2891.2893.2894.2895.2897.2898.2900.2901.2908.2909.2911.2912.2913.2914.2916.2917.2918.2919.2920.2922.2923.2924.2927.2929.2930.2931.2939.2940.2941.2947.2949.2950.2956.2961.2962.2963.2964.2965.2966.2968.2970.2973.2974.2975.2979.2980.2981.2983.2985.2986.2987.2991.2994.2995.2997.2999.3000.3002.3003.3005.3008.3009.3010.3012.3016.3017.3018.3019.3024.3025.3028.3034.3037.3038.3043.3045.3048.3052.3053.3055.3058.3059.3063.3065.3066.3068.3070.3072.3073.3074.3075.3076.3077.3078.3089.3090.3093.3094.3095.3097.3099.3104.3106.3109.3112.3117.3118.3119.3120.3124.3126.3127.3128.3130.3135.3136.3145.3149.3150.3151.3154.3155.3162.3163.3167.3172.3173.3180.3182.3183.3184.3185.3187.3188.3189.3190.3194.3196.3197.3209.3210.3211.3214.3215.3217.3219.3222.3223.3225.3226.3227.3228.3230.3231.3232.3234.3235.3236.3237.3238.3240.3241.3244.3245.3250.3251.3253.3257.3260.3268.3270.3272.3281.3288.3290.3292.3293.3295.3296.3300.3306.3307.3308.3314.3315.3316.3318.3324.3327.3328.3330'}, - 'eids': [{'source': 'id5-sync.com', - 'uids': [{'id': 'ID5*tdrSpYbccONIbxmulXFRLEil1aozZGGVMo9eEZgydgYoYFZQRYoae3wJyY0YtmXGKGJ7uXIQByQ6f7uzcpy9Oyhj1jGRzCf0BCoI4VkkKZIoZBubolUKUXXxOIdQOz7ZKGV0E3sqi9Zut0BbOuoJAihpLbgfNgDJ0xRmQw04rDooaxn7_TIPzEX5_L5ohNkUKG01Gnh2djvcrcPigKlk7ChwnauCwHIetHYI32yYAnAocYyqoM9XkoVOHtyOTC_UKHIR0qVBVIzJ1Nn_g7kLqyhzfosadKVvf7RQCsE6QrYodtpOJKg7i72-tnMXkzgmKHjh98aEDfTQrZOkKebmAyh6GlOHtYn_sZBFjJwtWp4oe9j2QTNbzK3G0jp1PlJqKHxiu4LawFEKJ3yi5-NFUyh-YkEalJUWyl1cDlWo5NQogAy2HM8N_w0qrVQgNbrTKIHK3KzTXztH7WzBgYrk8g', - 'atype': 1, - 'ext': {'linkType': 2}}]}, - {'source': 'domain.com', 'uids': [{'id': 'value read from cookie or local storage', 'atype': 1, 'ext': {'stype': 'ppuid'}}]}]}}, - 'ext': { - 'source': 'prebid.js', - 'version': '7.20.0-pre', - 'pageViewId': '5b970aba-51e9-4e0a-8299-f3f5618c695e' - }} - - const VIDEO_BID_REQUEST = [ - { - 'bidder': 'nexx360', - 'params': { - 'account': '1067', - 'tagId': 'yqsc1tfj' - }, - 'mediaTypes': { - 'video': { - 'context': 'instream', - 'playerSize': [[640, 480]], - 'mimes': ['video/mp4'], - 'protocols': [1, 2, 3, 4, 5, 6], - 'playbackmethod': [2], - 'skip': 1 - } - }, - 'adUnitCode': 'video1', - 'transactionId': '5434c81c-7210-44ae-9014-67c75dee48d0', - 'sizes': [[640, 480]], - 'bidId': '22f90541e576a3', - 'bidderRequestId': '1d4549243f3bfd', - 'auctionId': 'ed21b528-bcab-47e2-8605-ec9b71000c89', - 'src': 'client', - 'bidRequestsCount': 1, - 'bidderRequestsCount': 1, - 'bidderWinsCount': 0 - } - ] - +describe('Nexx360 bid adapter tests', () => { const DEFAULT_OPTIONS = { gdprConsent: { gdprApplies: true, consentString: 'BOzZdA0OzZdA0AGABBENDJ-AAAAvh7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__79__3z3_9pxP78k89r7337Mw_v-_v-b7JCPN_Y3v-8Kg', - vendorData: {} + vendorData: {}, }, refererInfo: { referer: 'https://www.prebid.org', - canonicalUrl: 'https://www.prebid.org/the/link/to/the/page' + canonicalUrl: 'https://www.prebid.org/the/link/to/the/page', }, uspConsent: '111222333', - userId: { 'id5id': { uid: '1111' } }, + userId: { id5id: { uid: '1111' } }, schain: { - 'ver': '1.0', - 'complete': 1, - 'nodes': [{ - 'asi': 'exchange1.com', - 'sid': '1234', - 'hp': 1, - 'rid': 'bid-request-1', - 'name': 'publisher', - 'domain': 'publisher.com' - }] + ver: '1.0', + complete: 1, + nodes: [{ + asi: 'exchange1.com', + sid: '1234', + hp: 1, + rid: 'bid-request-1', + name: 'publisher', + domain: 'publisher.com', + }], }, }; + - describe('isBidRequestValid()', function() { + describe('isBidRequestValid()', () => { let bannerBid; - beforeEach(function () { + beforeEach(() => { bannerBid = { - 'bidder': 'nexx360', - 'mediaTypes': {'banner': {'sizes': [[300, 250], [300, 600]]}}, - 'adUnitCode': 'div-1', - 'transactionId': '70bdc37e-9475-4b27-8c74-4634bdc2ee66', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '4906582fc87d0c', - 'bidderRequestId': '332fda16002dbe', - 'auctionId': '98932591-c822-42e3-850e-4b3cf748d063', + bidder: 'nexx360', + mediaTypes: { banner: { sizes: [[300, 250], [300, 600]] } }, + adUnitCode: 'div-1', + transactionId: '70bdc37e-9475-4b27-8c74-4634bdc2ee66', + sizes: [[300, 250], [300, 600]], + bidId: '4906582fc87d0c', + bidderRequestId: '332fda16002dbe', + auctionId: '98932591-c822-42e3-850e-4b3cf748d063', } }); - it('We verify isBidRequestValid with unvalid adUnitName', function() { + it('We verify isBidRequestValid with unvalid adUnitName', () => { bannerBid.params = { adUnitName: 1 }; expect(spec.isBidRequestValid(bannerBid)).to.be.equal(false); }); - it('We verify isBidRequestValid with empty adUnitName', function() { + it('We verify isBidRequestValid with empty adUnitName', () => { bannerBid.params = { adUnitName: '' }; expect(spec.isBidRequestValid(bannerBid)).to.be.equal(false); }); - it('We verify isBidRequestValid with unvalid adUnitPath', function() { + it('We verify isBidRequestValid with unvalid adUnitPath', () => { bannerBid.params = { adUnitPath: 1 }; expect(spec.isBidRequestValid(bannerBid)).to.be.equal(false); }); - it('We verify isBidRequestValid with unvalid divId', function() { + it('We verify isBidRequestValid with unvalid divId', () => { bannerBid.params = { divId: 1 }; expect(spec.isBidRequestValid(bannerBid)).to.be.equal(false); }); - it('We verify isBidRequestValid unvalid allBids', function() { + it('We verify isBidRequestValid unvalid allBids', () => { bannerBid.params = { allBids: 1 }; expect(spec.isBidRequestValid(bannerBid)).to.be.equal(false); }); - it('We verify isBidRequestValid with uncorrect tagid', function() { + it('We verify isBidRequestValid with uncorrect tagid', () => { bannerBid.params = { 'tagid': 'luvxjvgn' }; expect(spec.isBidRequestValid(bannerBid)).to.be.equal(false); }); - it('We verify isBidRequestValid with correct tagId', function() { + it('We verify isBidRequestValid with correct tagId', () => { bannerBid.params = { 'tagId': 'luvxjvgn' }; expect(spec.isBidRequestValid(bannerBid)).to.be.equal(true); }); + + it('We verify isBidRequestValid with correct placement', () => { + bannerBid.params = { 'placement': 'testad' }; + expect(spec.isBidRequestValid(bannerBid)).to.be.equal(true); + }); }); - describe('getNexx360LocalStorage disabled', function () { - before(function () { + describe('getNexx360LocalStorage disabled', () => { + before(() => { sandbox.stub(storage, 'localStorageIsEnabled').callsFake(() => false); }); - it('We test if we get the nexx360Id', function() { + it('We test if we get the nexx360Id', () => { const output = getNexx360LocalStorage(); expect(output).to.be.eql(false); }); - after(function () { + after(() => { sandbox.restore() }); }) - describe('getNexx360LocalStorage enabled but nothing', function () { - before(function () { + describe('getNexx360LocalStorage enabled but nothing', () => { + before(() => { sandbox.stub(storage, 'localStorageIsEnabled').callsFake(() => true); sandbox.stub(storage, 'setDataInLocalStorage'); sandbox.stub(storage, 'getDataFromLocalStorage').callsFake((key) => null); }); - it('We test if we get the nexx360Id', function() { + it('We test if we get the nexx360Id', () => { const output = getNexx360LocalStorage(); expect(typeof output.nexx360Id).to.be.eql('string'); }); - after(function () { + after(() => { sandbox.restore() }); }) - describe('getNexx360LocalStorage enabled but wrong payload', function () { - before(function () { + describe('getNexx360LocalStorage enabled but wrong payload', () => { + before(() => { sandbox.stub(storage, 'localStorageIsEnabled').callsFake(() => true); sandbox.stub(storage, 'setDataInLocalStorage'); sandbox.stub(storage, 'getDataFromLocalStorage').callsFake((key) => '{"nexx360Id":"5ad89a6e-7801-48e7-97bb-fe6f251f6cb4",}'); }); - it('We test if we get the nexx360Id', function() { + it('We test if we get the nexx360Id', () => { const output = getNexx360LocalStorage(); expect(output).to.be.eql(false); }); - after(function () { + after(() => { sandbox.restore() }); }); - describe('getNexx360LocalStorage enabled', function () { - before(function () { + describe('getNexx360LocalStorage enabled', () => { + before(() => { sandbox.stub(storage, 'localStorageIsEnabled').callsFake(() => true); sandbox.stub(storage, 'setDataInLocalStorage'); sandbox.stub(storage, 'getDataFromLocalStorage').callsFake((key) => '{"nexx360Id":"5ad89a6e-7801-48e7-97bb-fe6f251f6cb4"}'); }); - it('We test if we get the nexx360Id', function() { + it('We test if we get the nexx360Id', () => { const output = getNexx360LocalStorage(); expect(output.nexx360Id).to.be.eql('5ad89a6e-7801-48e7-97bb-fe6f251f6cb4'); }); - after(function () { + after(() => { sandbox.restore() }); }); - describe('getAmxId() with localStorage enabled and data not set', function() { - before(function () { + describe('getAmxId() with localStorage enabled and data not set', () => { + before(() => { sandbox.stub(storage, 'localStorageIsEnabled').callsFake(() => true); sandbox.stub(storage, 'setDataInLocalStorage'); sandbox.stub(storage, 'getDataFromLocalStorage').callsFake((key) => null); }); - it('We test if we get the amxId', function() { + it('We test if we get the amxId', () => { const output = getAmxId(); expect(output).to.be.eql(false); }); - after(function () { + after(() => { sandbox.restore() }); }); - describe('getAmxId() with localStorage enabled and data set', function() { - before(function () { + describe('getAmxId() with localStorage enabled and data set', () => { + before(() => { sandbox.stub(storage, 'localStorageIsEnabled').callsFake(() => true); sandbox.stub(storage, 'setDataInLocalStorage'); sandbox.stub(storage, 'getDataFromLocalStorage').callsFake((key) => 'abcdef'); }); - it('We test if we get the amxId', function() { + it('We test if we get the amxId', () => { const output = getAmxId(); expect(output).to.be.eql('abcdef'); }); - after(function () { + after(() => { sandbox.restore() }); }); - describe('buildRequests()', function() { - before(function () { + describe('buildRequests()', () => { + before(() => { const documentStub = sandbox.stub(document, 'getElementById'); documentStub.withArgs('div-1').returns({ offsetWidth: 200, @@ -280,7 +189,7 @@ describe('Nexx360 bid adapter tests', function () { } }); }); - describe('We test with a multiple display bids', function() { + describe('We test with a multiple display bids', () => { const sampleBids = [ { bidder: 'nexx360', @@ -290,6 +199,11 @@ describe('Nexx360 bid adapter tests', function () { adUnitName: 'header-ad', adUnitPath: '/12345/nexx360/Homepage/HP/Header-Ad', }, + ortb2Imp: { + ext: { + gpid: '/12345/nexx360/Homepage/HP/Header-Ad', + } + }, adUnitCode: 'header-ad-1234', transactionId: '469a570d-f187-488d-b1cb-48c1a2009be9', sizes: [[300, 250], [300, 600]], @@ -326,7 +240,7 @@ describe('Nexx360 bid adapter tests', function () { { bidder: 'nexx360', params: { - tagId: 'luvxjvgn', + placement: 'testPlacement', allBids: true, }, mediaTypes: { @@ -334,6 +248,7 @@ describe('Nexx360 bid adapter tests', function () { sizes: [[728, 90], [970, 250]] } }, + adUnitCode: 'div-2-abcd', transactionId: '6196885d-4e76-40dc-a09c-906ed232626b', sizes: [[728, 90], [970, 250]], @@ -375,8 +290,8 @@ describe('Nexx360 bid adapter tests', function () { consentString: 'CPhdLUAPhdLUAAKAsAENCmCsAP_AAE7AAAqIJFNd_H__bW9r-f5_aft0eY1P9_r37uQzDhfNk-8F3L_W_LwX52E7NF36tq4KmR4ku1LBIUNlHMHUDUmwaokVryHsak2cpzNKJ7BEknMZOydYGF9vmxtj-QKY7_5_d3bx2D-t_9v239z3z81Xn3d53-_03LCdV5_9Dfn9fR_bc9KPt_58v8v8_____3_e__3_7997BIiAaADgAJYBnwEeAJXAXmAwQBj4DtgHcgPBAeKBIgAA.YAAAAAAAAAAA', } }; - it('We perform a test with 2 display adunits', function() { - const displayBids = [...sampleBids]; + it('We perform a test with 2 display adunits', () => { + const displayBids = structuredClone(sampleBids); displayBids[0].mediaTypes = { banner: { sizes: [[300, 250], [300, 600]] @@ -385,33 +300,76 @@ describe('Nexx360 bid adapter tests', function () { const request = spec.buildRequests(displayBids, bidderRequest); const requestContent = request.data; expect(request).to.have.property('method').and.to.equal('POST'); - expect(requestContent.cur[0]).to.be.eql('USD'); - expect(requestContent.imp.length).to.be.eql(2); - expect(requestContent.imp[0].id).to.be.eql('44a2706ac3574'); - expect(requestContent.imp[0].tagid).to.be.eql('header-ad'); - expect(requestContent.imp[0].ext.divId).to.be.eql('div-1'); - expect(requestContent.imp[0].ext.adUnitCode).to.be.eql('header-ad-1234'); - expect(requestContent.imp[0].ext.adUnitName).to.be.eql('header-ad'); - expect(requestContent.imp[0].ext.adUnitPath).to.be.eql('/12345/nexx360/Homepage/HP/Header-Ad'); - expect(requestContent.imp[0].ext.dimensions.slotW).to.be.eql(200); - expect(requestContent.imp[0].ext.dimensions.slotH).to.be.eql(250); - expect(requestContent.imp[0].ext.dimensions.cssMaxW).to.be.eql('400px'); - expect(requestContent.imp[0].ext.dimensions.cssMaxH).to.be.eql('350px'); - expect(requestContent.imp[0].ext.nexx360.tagId).to.be.eql('luvxjvgn'); - expect(requestContent.imp[0].banner.format.length).to.be.eql(2); - expect(requestContent.imp[0].banner.format[0].w).to.be.eql(300); - expect(requestContent.imp[0].banner.format[0].h).to.be.eql(250); - expect(requestContent.imp[1].ext.nexx360.allBids).to.be.eql(true); - expect(requestContent.imp[1].tagid).to.be.eql('div-2-abcd'); - expect(requestContent.imp[1].ext.adUnitCode).to.be.eql('div-2-abcd'); - expect(requestContent.imp[1].ext.divId).to.be.eql('div-2-abcd'); - expect(requestContent.ext.bidderVersion).to.be.eql('4.3'); - expect(requestContent.ext.source).to.be.eql('prebid.js'); + const expectedRequest = { + imp: [ + { + id: '44a2706ac3574', + banner: { + topframe: 0, + format: [ + { w: 300, h: 250 }, + { w: 300, h: 600 }, + ], + }, + secure: 1, + tagid: 'header-ad-1234', + ext: { + adUnitCode: 'header-ad-1234', + gpid: '/12345/nexx360/Homepage/HP/Header-Ad', + divId: 'div-1', + dimensions: { + slotW: 200, + slotH: 250, + cssMaxW: '400px', + cssMaxH: '350px', + }, + nexx360: { + tagId: 'luvxjvgn', + }, + adUnitName: 'header-ad', + adUnitPath: '/12345/nexx360/Homepage/HP/Header-Ad', + }, + }, + { + id: '5ba94555219a03', + banner: { + topframe: 0, + format: [ + { w: 728, h: 90 }, + { w: 970, h: 250 }, + ], + }, + secure: 1, + tagid: 'div-2-abcd', + ext: { + adUnitCode: 'div-2-abcd', + divId: 'div-2-abcd', + nexx360: { + placement: 'testPlacement', + allBids: true, + }, + }, + }, + ], + id: requestContent.id, + test: 0, + ext: { + version: requestContent.ext.version, + source: 'prebid.js', + pageViewId: requestContent.ext.pageViewId, + bidderVersion: '5.0', + }, + cur: [ + 'USD', + ], + user: {}, + }; + expect(requestContent).to.be.eql(expectedRequest); }); if (FEATURES.VIDEO) { - it('We perform a test with a multiformat adunit', function() { - const multiformatBids = [...sampleBids]; + it('We perform a test with a multiformat adunit', () => { + const multiformatBids = structuredClone(sampleBids); multiformatBids[0].mediaTypes = { banner: { sizes: [[300, 250], [300, 600]] @@ -427,13 +385,24 @@ describe('Nexx360 bid adapter tests', function () { } }; const request = spec.buildRequests(multiformatBids, bidderRequest); - const requestContent = request.data; - expect(requestContent.imp[0].video.ext.context).to.be.eql('outstream'); - expect(requestContent.imp[0].video.playbackmethod[0]).to.be.eql(2); + const video = request.data.imp[0].video; + const expectedVideo = { + mimes: ['video/mp4'], + protocols: [1, 2, 3, 4, 5, 6, 7, 8], + playbackmethod: [2], + skip: 1, + w: 640, + h: 480, + ext: { + playerSize: [640, 480], + context: 'outstream', + }, + }; + expect(video).to.eql(expectedVideo); }); - it('We perform a test with a instream adunit', function() { - const videoBids = [sampleBids[0]]; + it('We perform a test with a instream adunit', () => { + const videoBids = structuredClone(sampleBids); videoBids[0].mediaTypes = { video: { context: 'instream', @@ -449,265 +418,372 @@ describe('Nexx360 bid adapter tests', function () { expect(request).to.have.property('method').and.to.equal('POST'); expect(requestContent.imp[0].video.ext.context).to.be.eql('instream'); expect(requestContent.imp[0].video.playbackmethod[0]).to.be.eql(2); - }) + }); } }); - after(function () { + after(() => { sandbox.restore() }); }); - describe('interpretResponse()', function() { - it('empty response', function() { + describe('We test intepretResponse', () => { + it('empty response', () => { const response = { body: '' }; const output = spec.interpretResponse(response); expect(output.length).to.be.eql(0); }); - it('banner responses with adUrl only', function() { + it('banner responses with adUrl only', () => { const response = { body: { - 'id': 'a8d3a675-a4ba-4d26-807f-c8f2fad821e0', - 'cur': 'USD', - 'seatbid': [ + id: 'a8d3a675-a4ba-4d26-807f-c8f2fad821e0', + cur: 'USD', + seatbid: [ { - 'bid': [ + bid: [ { - 'id': '4427551302944024629', - 'impid': '226175918ebeda', - 'price': 1.5, - 'adomain': [ - 'http://prebid.org' + id: '4427551302944024629', + impid: '226175918ebeda', + price: 1.5, + adomain: [ + 'http://prebid.org', ], - 'crid': '98493581', - 'ssp': 'appnexus', - 'h': 600, - 'w': 300, - 'cat': [ - 'IAB3-1' + crid: '98493581', + ssp: 'appnexus', + h: 600, + w: 300, + dealid: 'testdeal', + cat: [ + 'IAB3-1', ], - 'ext': { - 'adUnitCode': 'div-1', - 'mediaType': 'banner', - 'adUrl': 'https://fast.nexx360.io/cache?uuid=fdddcebc-1edf-489d-880d-1418d8bdc493', - 'ssp': 'appnexus', - } - } + ext: { + adUnitCode: 'div-1', + mediaType: 'banner', + adUrl: 'https://fast.nexx360.io/cache?uuid=fdddcebc-1edf-489d-880d-1418d8bdc493', + ssp: 'appnexus', + }, + }, ], - 'seat': 'appnexus' - } + seat: 'appnexus', + }, ], - 'ext': { - 'id': 'de3de7c7-e1cf-4712-80a9-94eb26bfc718', - 'cookies': [] + ext: { + id: 'de3de7c7-e1cf-4712-80a9-94eb26bfc718', + cookies: [], }, - } + }, }; + const output = spec.interpretResponse(response); - expect(output[0].adUrl).to.be.eql(response.body.seatbid[0].bid[0].ext.adUrl); - expect(output[0].mediaType).to.be.eql(response.body.seatbid[0].bid[0].ext.mediaType); - expect(output[0].currency).to.be.eql(response.body.cur); - expect(output[0].cpm).to.be.eql(response.body.seatbid[0].bid[0].price); - }); - it('banner responses with adm', function() { + const expectedOutput = [{ + requestId: '226175918ebeda', + cpm: 1.5, + width: 300, + height: 600, + creativeId: '98493581', + currency: 'USD', + netRevenue: true, + dealid: 'testdeal', + ttl: 120, + mediaType: 'banner', + meta: { advertiserDomains: ['http://prebid.org'], demandSource: 'appnexus' }, + adUrl: 'https://fast.nexx360.io/cache?uuid=fdddcebc-1edf-489d-880d-1418d8bdc493', + }]; + expect(output).to.eql(expectedOutput); + }); + it('banner responses with adm', () => { const response = { body: { - 'id': 'a8d3a675-a4ba-4d26-807f-c8f2fad821e0', - 'cur': 'USD', - 'seatbid': [ + id: 'a8d3a675-a4ba-4d26-807f-c8f2fad821e0', + cur: 'USD', + seatbid: [ { - 'bid': [ + bid: [ { - 'id': '4427551302944024629', - 'impid': '226175918ebeda', - 'price': 1.5, - 'adomain': [ - 'http://prebid.org' + id: '4427551302944024629', + impid: '226175918ebeda', + price: 1.5, + adomain: [ + 'http://prebid.org', ], - 'crid': '98493581', - 'ssp': 'appnexus', - 'h': 600, - 'w': 300, - 'adm': '
TestAd
', - 'cat': [ - 'IAB3-1' + crid: '98493581', + ssp: 'appnexus', + h: 600, + w: 300, + adm: '
TestAd
', + cat: [ + 'IAB3-1', ], - 'ext': { - 'adUnitCode': 'div-1', - 'mediaType': 'banner', - 'adUrl': 'https://fast.nexx360.io/cache?uuid=fdddcebc-1edf-489d-880d-1418d8bdc493', - 'ssp': 'appnexus', - } - } + ext: { + adUnitCode: 'div-1', + mediaType: 'banner', + adUrl: 'https://fast.nexx360.io/cache?uuid=fdddcebc-1edf-489d-880d-1418d8bdc493', + ssp: 'appnexus', + }, + }, ], - 'seat': 'appnexus' - } + seat: 'appnexus', + }, ], - 'ext': { - 'id': 'de3de7c7-e1cf-4712-80a9-94eb26bfc718', - 'cookies': [] + ext: { + id: 'de3de7c7-e1cf-4712-80a9-94eb26bfc718', + cookies: [], }, - } + }, }; const output = spec.interpretResponse(response); - expect(output[0].ad).to.be.eql(response.body.seatbid[0].bid[0].adm); - expect(output[0].adUrl).to.be.eql(undefined); - expect(output[0].mediaType).to.be.eql(response.body.seatbid[0].bid[0].ext.mediaType); - expect(output[0].currency).to.be.eql(response.body.cur); - expect(output[0].cpm).to.be.eql(response.body.seatbid[0].bid[0].price); + const expectedOutput = [{ + requestId: '226175918ebeda', + cpm: 1.5, + width: 300, + height: 600, + creativeId: '98493581', + currency: 'USD', + netRevenue: true, + ttl: 120, + mediaType: 'banner', + meta: { + advertiserDomains: [ + 'http://prebid.org', + ], + demandSource: 'appnexus', + }, + ad: '
TestAd
', + }]; + expect(output).to.eql(expectedOutput); }); - it('instream responses', function() { + + it('instream responses', () => { const response = { body: { - 'id': '2be64380-ba0c-405a-ab53-51f51c7bde51', - 'cur': 'USD', - 'seatbid': [ + id: '2be64380-ba0c-405a-ab53-51f51c7bde51', + cur: 'USD', + seatbid: [ { - 'bid': [ + bid: [ { - 'id': '8275140264321181514', - 'impid': '263cba3b8bfb72', - 'price': 5, - 'adomain': [ - 'appnexus.com' + id: '8275140264321181514', + impid: '263cba3b8bfb72', + price: 5, + adomain: [ + 'appnexus.com', ], - 'crid': '97517771', - 'h': 1, - 'w': 1, - 'ext': { - 'mediaType': 'instream', - 'ssp': 'appnexus', - 'adUnitCode': 'video1', - 'vastXml': '\n \n \n Nexx360 Wrapper\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ' - } - } + crid: '97517771', + h: 1, + w: 1, + adm: 'vast', + ext: { + mediaType: 'instream', + ssp: 'appnexus', + adUnitCode: 'video1', + }, + }, ], - 'seat': 'appnexus' - } + seat: 'appnexus', + }, ], - 'ext': { - 'cookies': [] - } - } + ext: { + cookies: [], + }, + }, }; + const output = spec.interpretResponse(response); - expect(output[0].vastXml).to.be.eql(response.body.seatbid[0].bid[0].adm); - expect(output[0].mediaType).to.be.eql('video'); - expect(output[0].currency).to.be.eql(response.body.cur); - expect(output[0].cpm).to.be.eql(response.body.seatbid[0].bid[0].price); + const expectedOutput = [{ + requestId: '263cba3b8bfb72', + cpm: 5, + width: 1, + height: 1, + creativeId: '97517771', + currency: 'USD', + netRevenue: true, + ttl: 120, + mediaType: 'video', + meta: { advertiserDomains: ['appnexus.com'], demandSource: 'appnexus' }, + vastXml: 'vast', + }]; + expect(output).to.eql(expectedOutput); }); - it('outstream responses', function() { + it('outstream responses', () => { const response = { body: { - 'id': '40c23932-135e-4602-9701-ca36f8d80c07', - 'cur': 'USD', - 'seatbid': [ + id: '40c23932-135e-4602-9701-ca36f8d80c07', + cur: 'USD', + seatbid: [ { - 'bid': [ + bid: [ { - 'id': '1186971142548769361', - 'impid': '4ce809b61a3928', - 'price': 5, - 'adomain': [ - 'appnexus.com' + id: '1186971142548769361', + impid: '4ce809b61a3928', + price: 5, + adomain: [ + 'appnexus.com', ], - 'crid': '97517771', - 'h': 1, - 'w': 1, - 'adm': '\n \n \n Nexx360 Wrapper\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ', - 'ext': { - 'mediaType': 'outstream', - 'ssp': 'appnexus', - 'adUnitCode': 'div-1', - } - } + crid: '97517771', + h: 1, + w: 1, + adm: 'vast', + ext: { + mediaType: 'outstream', + ssp: 'appnexus', + adUnitCode: 'div-1', + }, + }, ], - 'seat': 'appnexus' - } + seat: 'appnexus', + }, ], - 'ext': { - 'cookies': [] - } - } + ext: { + cookies: [], + }, + }, }; + const output = spec.interpretResponse(response); - expect(output[0].vastXml).to.be.eql(response.body.seatbid[0].bid[0].adm); - expect(output[0].mediaType).to.be.eql('video'); - expect(output[0].currency).to.be.eql(response.body.cur); - expect(typeof output[0].renderer).to.be.eql('object'); - expect(output[0].cpm).to.be.eql(response.body.seatbid[0].bid[0].price); + const expectedOutut = [{ + requestId: '4ce809b61a3928', + cpm: 5, + width: 1, + height: 1, + creativeId: '97517771', + currency: 'USD', + netRevenue: true, + ttl: 120, + mediaType: 'video', + meta: { advertiserDomains: ['appnexus.com'], demandSource: 'appnexus' }, + vastXml: 'vast', + renderer: output[0].renderer, + }]; + expect(output).to.eql(expectedOutut); }); - it('native responses', function() { + it('native responses', () => { const response = { body: { - 'id': '3c0290c1-6e75-4ef7-9e37-17f5ebf3bfa3', - 'cur': 'USD', - 'seatbid': [ + id: '3c0290c1-6e75-4ef7-9e37-17f5ebf3bfa3', + cur: 'USD', + seatbid: [ { - 'bid': [ + bid: [ { - 'id': '6624930625245272225', - 'impid': '23e11d845514bb', - 'price': 10, - 'adomain': [ - 'prebid.org' + id: '6624930625245272225', + impid: '23e11d845514bb', + price: 10, + adomain: [ + 'prebid.org', ], - 'crid': '97494204', - 'h': 1, - 'w': 1, - 'cat': [ - 'IAB3-1' + crid: '97494204', + h: 1, + w: 1, + cat: [ + 'IAB3-1', ], - 'ext': { - 'mediaType': 'native', - 'ssp': 'appnexus', - 'adUnitCode': '/19968336/prebid_native_example_1' + ext: { + mediaType: 'native', + ssp: 'appnexus', + adUnitCode: '/19968336/prebid_native_example_1', }, - 'adm': '{"ver":"1.2","assets":[{"id":1,"img":{"url":"https:\\/\\/vcdn.adnxs.com\\/p\\/creative-image\\/f8\\/7f\\/0f\\/13\\/f87f0f13-230c-4f05-8087-db9216e393de.jpg","w":989,"h":742,"ext":{"appnexus":{"prevent_crop":0}}}},{"id":0,"title":{"text":"This is a Prebid Native Creative"}},{"id":2,"data":{"value":"Prebid.org"}}],"link":{"url":"https:\\/\\/ams3-ib.adnxs.com\\/click?AAAAAAAAJEAAAAAAAAAkQAAAAAAAACRAAAAAAAAAJEAAAAAAAAAkQKZS4ZZl5vVbR6p-A-MwnyTZ7QVkAAAAAOLoyQBtJAAAbSQAAAIAAAC8pM8FnPgWAAAAAABVU0QAVVNEAAEAAQBNXQAAAAABAgMCAAAAALoAURe69gAAAAA.\\/bcr=AAAAAAAA8D8=\\/pp=${AUCTION_PRICE}\\/cnd=%21JBC72Aj8-LwKELzJvi4YnPFbIAQoADEAAAAAAAAkQDoJQU1TMzo2MTM1QNAwSQAAAAAAAPA_UQAAAAAAAAAAWQAAAAAAAAAAYQAAAAAAAAAAaQAAAAAAAAAAcQAAAAAAAAAAeACJAQAAAAAAAAAA\\/cca=OTMyNSNBTVMzOjYxMzU=\\/bn=97062\\/clickenc=http%3A%2F%2Fprebid.org%2Fdev-docs%2Fshow-native-ads.html"},"eventtrackers":[{"event":1,"method":1,"url":"https:\\/\\/ams3-ib.adnxs.com\\/it?an_audit=0&referrer=https%3A%2F%2Ftest.nexx360.io%2Fadapter%2Fnative%2Ftest.html&e=wqT_3QKJCqAJBQAAAwDWAAUBCNnbl6AGEKalhbfZzPn6WxjH1PqbsJzMzyQqNgkAAAECCCRAEQEHEAAAJEAZEQkAIREJACkRCQAxEQmoMOLRpwY47UhA7UhIAlC8yb4uWJzxW2AAaM26dXim9gWAAQGKAQNVU0SSAQEG9F4BmAEBoAEBqAEBsAEAuAECwAEDyAEC0AEJ2AEA4AEA8AEAigIpdWYoJ2EnLCAyNTI5ODg1LCAwKTt1ZigncicsIDk3NDk0MjA0LCAwKTuSAvEDIS0xRDNJQWo4LUx3S0VMekp2aTRZQUNDYzhWc3dBRGdBUUFSSTdVaFE0dEduQmxnQVlQX19fXzhQYUFCd0FYZ0JnQUVCaUFFQmtBRUJtQUVCb0FFQnFBRURzQUVBdVFIenJXcWtBQUFrUU1FQjg2MXFwQUFBSkVESkFYSUtWbWViSmZJXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFNQUNBY2dDQWRBQ0FkZ0NBZUFDQU9nQ0FQZ0NBSUFEQVpnREFib0RDVUZOVXpNNk5qRXpOZUFEMERDSUJBQ1FCQUNZQkFIQkJBQUFBQUFBQUFBQXlRUUFBCQscQUFOZ0VBUEURlSxBQUFDSUJmY3ZxUVUBDQRBQQGoCDdFRgEKCQEMREJCUQkKAQEAeRUoAUwyKAAAWi4oALg0QVhBaEQzd0JhTEQzd0w0QmQyMG1nR0NCZ05WVTBTSUJnQ1FCZ0dZQmdDaEJnQQFONEFBQ1JBcUFZQnNnWWtDHXQARR0MAEcdDABJHQw8dUFZS5oClQEhSkJDNzJBajL1ASRuUEZiSUFRb0FEFfhUa1FEb0pRVTFUTXpvMk1UTTFRTkF3UxFRDFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQwQZUFDSkEdEMjYAvfpA-ACrZhI6gIwaHR0cHM6Ly90ZXN0Lm5leHgzNjAuaW8vYWRhcHRlci9uYXRpdmUJH_CaaHRtbIADAIgDAZADAJgDFKADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMDgAQAkgQJL29wZW5ydGIymAQAqAQAsgQMCAAQABgAIAAwADgAuAQAwASA2rgiyAQA0gQOOTMyNSNBTVMzOjYxMzXaBAIIAeAEAPAEvMm-LvoEEgkAAABAPG1IQBEAAACgV8oCQIgFAZgFAKAF______8BBbABqgUkM2MwMjkwYzEtNmU3NS00ZWY3LTllMzctMTdmNWViZjNiZmEzwAUAyQWJFxTwP9IFCQkJDHgAANgFAeAFAfAFmfQh-gUECAAQAJAGAZgGALgGAMEGCSUo8D_QBvUv2gYWChAJERkBAdpg4AYM8gYCCACABwGIBwCgB0HIB6b2BdIHDRVkASYI2gcGAV1oGADgBwDqBwIIAPAHAIoIAhAAlQgAAIA_mAgB&s=ccf63f2e483a37091d2475d895e7cf7c911d1a78&pp=${AUCTION_PRICE}"}]}' - } + adm: '{"ver":"1.2","assets":[{"id":1,"img":{"url":"https:\\/\\/vcdn.adnxs.com\\/p\\/creative-image\\/f8\\/7f\\/0f\\/13\\/f87f0f13-230c-4f05-8087-db9216e393de.jpg","w":989,"h":742,"ext":{"appnexus":{"prevent_crop":0}}}},{"id":0,"title":{"text":"This is a Prebid Native Creative"}},{"id":2,"data":{"value":"Prebid.org"}}],"link":{"url":"https:\\/\\/ams3-ib.adnxs.com\\/click?AAAAAAAAJEAAAAAAAAAkQAAAAAAAACRAAAAAAAAAJEAAAAAAAAAkQKZS4ZZl5vVbR6p-A-MwnyTZ7QVkAAAAAOLoyQBtJAAAbSQAAAIAAAC8pM8FnPgWAAAAAABVU0QAVVNEAAEAAQBNXQAAAAABAgMCAAAAALoAURe69gAAAAA.\\/bcr=AAAAAAAA8D8=\\/pp=${AUCTION_PRICE}\\/cnd=%21JBC72Aj8-LwKELzJvi4YnPFbIAQoADEAAAAAAAAkQDoJQU1TMzo2MTM1QNAwSQAAAAAAAPA_UQAAAAAAAAAAWQAAAAAAAAAAYQAAAAAAAAAAaQAAAAAAAAAAcQAAAAAAAAAAeACJAQAAAAAAAAAA\\/cca=OTMyNSNBTVMzOjYxMzU=\\/bn=97062\\/clickenc=http%3A%2F%2Fprebid.org%2Fdev-docs%2Fshow-native-ads.html"},"eventtrackers":[{"event":1,"method":1,"url":"https:\\/\\/ams3-ib.adnxs.com\\/it?an_audit=0&referrer=https%3A%2F%2Ftest.nexx360.io%2Fadapter%2Fnative%2Ftest.html&e=wqT_3QKJCqAJBQAAAwDWAAUBCNnbl6AGEKalhbfZzPn6WxjH1PqbsJzMzyQqNgkAAAECCCRAEQEHEAAAJEAZEQkAIREJACkRCQAxEQmoMOLRpwY47UhA7UhIAlC8yb4uWJzxW2AAaM26dXim9gWAAQGKAQNVU0SSAQEG9F4BmAEBoAEBqAEBsAEAuAECwAEDyAEC0AEJ2AEA4AEA8AEAigIpdWYoJ2EnLCAyNTI5ODg1LCAwKTt1ZigncicsIDk3NDk0MjA0LCAwKTuSAvEDIS0xRDNJQWo4LUx3S0VMekp2aTRZQUNDYzhWc3dBRGdBUUFSSTdVaFE0dEduQmxnQVlQX19fXzhQYUFCd0FYZ0JnQUVCaUFFQmtBRUJtQUVCb0FFQnFBRURzQUVBdVFIenJXcWtBQUFrUU1FQjg2MXFwQUFBSkVESkFYSUtWbWViSmZJXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFNQUNBY2dDQWRBQ0FkZ0NBZUFDQU9nQ0FQZ0NBSUFEQVpnREFib0RDVUZOVXpNNk5qRXpOZUFEMERDSUJBQ1FCQUNZQkFIQkJBQUFBQUFBQUFBQXlRUUFBCQscQUFOZ0VBUEURlSxBQUFDSUJmY3ZxUVUBDQRBQQGoCDdFRgEKCQEMREJCUQkKAQEAeRUoAUwyKAAAWi4oALg0QVhBaEQzd0JhTEQzd0w0QmQyMG1nR0NCZ05WVTBTSUJnQ1FCZ0dZQmdDaEJnQQFONEFBQ1JBcUFZQnNnWWtDHXQARR0MAEcdDABJHQw8dUFZS5oClQEhSkJDNzJBajL1ASRuUEZiSUFRb0FEFfhUa1FEb0pRVTFUTXpvMk1UTTFRTkF3UxFRDFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQwQZUFDSkEdEMjYAvfpA-ACrZhI6gIwaHR0cHM6Ly90ZXN0Lm5leHgzNjAuaW8vYWRhcHRlci9uYXRpdmUJH_CaaHRtbIADAIgDAZADAJgDFKADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMDgAQAkgQJL29wZW5ydGIymAQAqAQAsgQMCAAQABgAIAAwADgAuAQAwASA2rgiyAQA0gQOOTMyNSNBTVMzOjYxMzXaBAIIAeAEAPAEvMm-LvoEEgkAAABAPG1IQBEAAACgV8oCQIgFAZgFAKAF______8BBbABqgUkM2MwMjkwYzEtNmU3NS00ZWY3LTllMzctMTdmNWViZjNiZmEzwAUAyQWJFxTwP9IFCQkJDHgAANgFAeAFAfAFmfQh-gUECAAQAJAGAZgGALgGAMEGCSUo8D_QBvUv2gYWChAJERkBAdpg4AYM8gYCCACABwGIBwCgB0HIB6b2BdIHDRVkASYI2gcGAV1oGADgBwDqBwIIAPAHAIoIAhAAlQgAAIA_mAgB&s=ccf63f2e483a37091d2475d895e7cf7c911d1a78&pp=${AUCTION_PRICE}"}]}', + }, ], - 'seat': 'appnexus' - } + seat: 'appnexus', + }, ], - 'ext': { - 'cookies': [], - } - } + ext: { + cookies: [], + }, + }, }; + const output = spec.interpretResponse(response); - expect(output[0].native.ortb.ver).to.be.eql('1.2'); - expect(output[0].native.ortb.assets[0].id).to.be.eql(1); - expect(output[0].mediaType).to.be.eql('native'); + const expectOutput = [{ + requestId: '23e11d845514bb', + cpm: 10, + width: 1, + height: 1, + creativeId: '97494204', + currency: 'USD', + netRevenue: true, + ttl: 120, + mediaType: 'native', + meta: { + advertiserDomains: [ + 'prebid.org', + ], + demandSource: 'appnexus', + }, + native: { + ortb: { + ver: '1.2', + assets: [ + { + id: 1, + img: { + url: 'https://vcdn.adnxs.com/p/creative-image/f8/7f/0f/13/f87f0f13-230c-4f05-8087-db9216e393de.jpg', + w: 989, + h: 742, + ext: { + appnexus: { + prevent_crop: 0, + }, + }, + }, + }, + { + id: 0, + title: { + text: 'This is a Prebid Native Creative', + }, + }, + { + id: 2, + data: { + value: 'Prebid.org', + }, + }, + ], + link: { + url: 'https://ams3-ib.adnxs.com/click?AAAAAAAAJEAAAAAAAAAkQAAAAAAAACRAAAAAAAAAJEAAAAAAAAAkQKZS4ZZl5vVbR6p-A-MwnyTZ7QVkAAAAAOLoyQBtJAAAbSQAAAIAAAC8pM8FnPgWAAAAAABVU0QAVVNEAAEAAQBNXQAAAAABAgMCAAAAALoAURe69gAAAAA./bcr=AAAAAAAA8D8=/pp=${AUCTION_PRICE}/cnd=%21JBC72Aj8-LwKELzJvi4YnPFbIAQoADEAAAAAAAAkQDoJQU1TMzo2MTM1QNAwSQAAAAAAAPA_UQAAAAAAAAAAWQAAAAAAAAAAYQAAAAAAAAAAaQAAAAAAAAAAcQAAAAAAAAAAeACJAQAAAAAAAAAA/cca=OTMyNSNBTVMzOjYxMzU=/bn=97062/clickenc=http%3A%2F%2Fprebid.org%2Fdev-docs%2Fshow-native-ads.html', + }, + eventtrackers: [ + { + event: 1, + method: 1, + url: 'https://ams3-ib.adnxs.com/it?an_audit=0&referrer=https%3A%2F%2Ftest.nexx360.io%2Fadapter%2Fnative%2Ftest.html&e=wqT_3QKJCqAJBQAAAwDWAAUBCNnbl6AGEKalhbfZzPn6WxjH1PqbsJzMzyQqNgkAAAECCCRAEQEHEAAAJEAZEQkAIREJACkRCQAxEQmoMOLRpwY47UhA7UhIAlC8yb4uWJzxW2AAaM26dXim9gWAAQGKAQNVU0SSAQEG9F4BmAEBoAEBqAEBsAEAuAECwAEDyAEC0AEJ2AEA4AEA8AEAigIpdWYoJ2EnLCAyNTI5ODg1LCAwKTt1ZigncicsIDk3NDk0MjA0LCAwKTuSAvEDIS0xRDNJQWo4LUx3S0VMekp2aTRZQUNDYzhWc3dBRGdBUUFSSTdVaFE0dEduQmxnQVlQX19fXzhQYUFCd0FYZ0JnQUVCaUFFQmtBRUJtQUVCb0FFQnFBRURzQUVBdVFIenJXcWtBQUFrUU1FQjg2MXFwQUFBSkVESkFYSUtWbWViSmZJXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFNQUNBY2dDQWRBQ0FkZ0NBZUFDQU9nQ0FQZ0NBSUFEQVpnREFib0RDVUZOVXpNNk5qRXpOZUFEMERDSUJBQ1FCQUNZQkFIQkJBQUFBQUFBQUFBQXlRUUFBCQscQUFOZ0VBUEURlSxBQUFDSUJmY3ZxUVUBDQRBQQGoCDdFRgEKCQEMREJCUQkKAQEAeRUoAUwyKAAAWi4oALg0QVhBaEQzd0JhTEQzd0w0QmQyMG1nR0NCZ05WVTBTSUJnQ1FCZ0dZQmdDaEJnQQFONEFBQ1JBcUFZQnNnWWtDHXQARR0MAEcdDABJHQw8dUFZS5oClQEhSkJDNzJBajL1ASRuUEZiSUFRb0FEFfhUa1FEb0pRVTFUTXpvMk1UTTFRTkF3UxFRDFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQwQZUFDSkEdEMjYAvfpA-ACrZhI6gIwaHR0cHM6Ly90ZXN0Lm5leHgzNjAuaW8vYWRhcHRlci9uYXRpdmUJH_CaaHRtbIADAIgDAZADAJgDFKADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMDgAQAkgQJL29wZW5ydGIymAQAqAQAsgQMCAAQABgAIAAwADgAuAQAwASA2rgiyAQA0gQOOTMyNSNBTVMzOjYxMzXaBAIIAeAEAPAEvMm-LvoEEgkAAABAPG1IQBEAAACgV8oCQIgFAZgFAKAF______8BBbABqgUkM2MwMjkwYzEtNmU3NS00ZWY3LTllMzctMTdmNWViZjNiZmEzwAUAyQWJFxTwP9IFCQkJDHgAANgFAeAFAfAFmfQh-gUECAAQAJAGAZgGALgGAMEGCSUo8D_QBvUv2gYWChAJERkBAdpg4AYM8gYCCACABwGIBwCgB0HIB6b2BdIHDRVkASYI2gcGAV1oGADgBwDqBwIIAPAHAIoIAhAAlQgAAIA_mAgB&s=ccf63f2e483a37091d2475d895e7cf7c911d1a78&pp=${AUCTION_PRICE}', + }, + ], + }, + }, + }]; + expect(output).to.eql(expectOutput); }); }); - describe('getUserSyncs()', function() { + describe('getUserSyncs()', () => { const response = { body: { cookies: [] } }; - it('Verifies user sync without cookie in bid response', function () { - var syncs = spec.getUserSyncs({}, [response], DEFAULT_OPTIONS.gdprConsent, DEFAULT_OPTIONS.uspConsent); - expect(syncs).to.have.lengthOf(0); + it('Verifies user sync without cookie in bid response', () => { + const syncs = spec.getUserSyncs({}, [response], DEFAULT_OPTIONS.gdprConsent, DEFAULT_OPTIONS.uspConsent); + expect(syncs).to.eql([]); }); - it('Verifies user sync with cookies in bid response', function () { + it('Verifies user sync with cookies in bid response', () => { response.body.ext = { cookies: [{'type': 'image', 'url': 'http://www.cookie.sync.org/'}] }; - var syncs = spec.getUserSyncs({}, [response], DEFAULT_OPTIONS.gdprConsent); - expect(syncs).to.have.lengthOf(1); - expect(syncs[0]).to.have.property('type').and.to.equal('image'); - expect(syncs[0]).to.have.property('url').and.to.equal('http://www.cookie.sync.org/'); + const syncs = spec.getUserSyncs({}, [response], DEFAULT_OPTIONS.gdprConsent); + const expectedSyncs = [{ type: 'image', url: 'http://www.cookie.sync.org/' }]; + expect(syncs).to.eql(expectedSyncs); }); - it('Verifies user sync with no bid response', function() { + it('Verifies user sync with no bid response', () => { var syncs = spec.getUserSyncs({}, null, DEFAULT_OPTIONS.gdprConsent, DEFAULT_OPTIONS.uspConsent); - expect(syncs).to.have.lengthOf(0); + expect(syncs).to.eql([]); }); - it('Verifies user sync with no bid body response', function() { + it('Verifies user sync with no bid body response', () => { var syncs = spec.getUserSyncs({}, [], DEFAULT_OPTIONS.gdprConsent, DEFAULT_OPTIONS.uspConsent); - expect(syncs).to.have.lengthOf(0); + expect(syncs).to.eql([]); var syncs = spec.getUserSyncs({}, [{}], DEFAULT_OPTIONS.gdprConsent, DEFAULT_OPTIONS.uspConsent); - expect(syncs).to.have.lengthOf(0); + expect(syncs).to.eql([]); }); }); });