From 4c0b581a7b996a2166085c02ce28ade688dfba0b Mon Sep 17 00:00:00 2001 From: tej656 Date: Tue, 30 Jul 2024 23:11:46 +0530 Subject: [PATCH] fix tests --- modules/pubxaiAnalyticsAdapter.js | 7 +++---- .../spec/modules/pubxaiAnalyticsAdapter_spec.js | 17 +++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/modules/pubxaiAnalyticsAdapter.js b/modules/pubxaiAnalyticsAdapter.js index c967578a919..e831526be5e 100644 --- a/modules/pubxaiAnalyticsAdapter.js +++ b/modules/pubxaiAnalyticsAdapter.js @@ -20,8 +20,6 @@ const analyticsType = 'endpoint'; const adapterCode = 'pubxai'; const pubxaiAnalyticsVersion = 'v2.0.0'; const defaultHost = 'api.pbxai.com'; -const auctionPath = '/analytics/auction'; -const winningBidPath = '/analytics/bidwon'; const storage = getStorageManager({ moduleType: MODULE_TYPE_ANALYTICS, moduleName: adapterCode }) /** @@ -236,9 +234,10 @@ const prepareSend = (auctionId) => { if (!shouldFireEventRequest(auctionId, initOptions.samplingRate)) { return; } + const pubxID = initOptions.pubxId; [ { - path: winningBidPath, + path: `/analytics/${pubxID}/bidwon`, requiredKeys: [ 'winningBid', 'pageDetail', @@ -253,7 +252,7 @@ const prepareSend = (auctionId) => { eventType: 'win', }, { - path: auctionPath, + path: `/analytics/${pubxID}/auction`, requiredKeys: [ 'bids', 'pageDetail', diff --git a/test/spec/modules/pubxaiAnalyticsAdapter_spec.js b/test/spec/modules/pubxaiAnalyticsAdapter_spec.js index 237a2d32d54..a27400af46f 100644 --- a/test/spec/modules/pubxaiAnalyticsAdapter_spec.js +++ b/test/spec/modules/pubxaiAnalyticsAdapter_spec.js @@ -31,9 +31,10 @@ describe('pubxai analytics adapter', () => { }); describe('track', () => { + const pubxId = '6c415fc0-8b0e-4cf5-be73-01526a4db625' let initOptions = { samplingRate: '1', - pubxId: '6c415fc0-8b0e-4cf5-be73-01526a4db625', + pubxId: pubxId, }; let originalVS; @@ -148,7 +149,7 @@ describe('pubxai analytics adapter', () => { timeout: 1000, config: { samplingRate: '1', - pubxId: '6c415fc0-8b0e-4cf5-be73-01526a4db625', + pubxId: pubxId, }, }, bidRequested: { @@ -529,7 +530,7 @@ describe('pubxai analytics adapter', () => { null, auctionId: 'bc3806e4-873e-453c-8ae5-204f35e923b4', sizes: '300x250', - renderStatus: 2, + bidType: 2, requestTimestamp: 1616654312804, creativeId: 96846035, currency: 'USD', @@ -651,7 +652,7 @@ describe('pubxai analytics adapter', () => { placementId: 13144370, renderedSize: '300x250', sizes: '300x250', - renderStatus: 4, + bidType: 4, responseTimestamp: 1616654313071, requestTimestamp: 1616654312804, status: 'rendered', @@ -758,7 +759,7 @@ describe('pubxai analytics adapter', () => { const [expectedUrl, expectedData] = arg; const parsedUrl = new URL(expectedUrl); expect(parsedUrl.pathname).to.equal( - ['/analytics/bidwon', '/analytics/auction'][index] + [`/analytics/${pubxId}/bidwon`, `/analytics/${pubxId}/auction`][index] ); expect(Object.fromEntries(parsedUrl.searchParams)).to.deep.equal({ auctionTimestamp: '1616654312804', @@ -800,7 +801,7 @@ describe('pubxai analytics adapter', () => { // Step 7: check the pathname of the calls is correct (sent only to the auction endpoint) const [expectedUrl, expectedData] = navigator.sendBeacon.args[0]; const parsedUrl = new URL(expectedUrl); - expect(parsedUrl.pathname).to.equal('/analytics/auction'); + expect(parsedUrl.pathname).to.equal(`/analytics/${pubxId}/auction`); // Step 8: check that the meta information in the call is correct expect(Object.fromEntries(parsedUrl.searchParams)).to.deep.equal({ @@ -926,7 +927,7 @@ describe('pubxai analytics adapter', () => { const parsedUrl = new URL(expectedUrl); const auctionIdMapFn = index < 2 ? (i, _) => i : replaceProperty; expect(parsedUrl.pathname).to.equal( - ['/analytics/bidwon', '/analytics/auction'][index % 2] + [`/analytics/${pubxId}/bidwon`, `/analytics/${pubxId}/auction`][index % 2] ); expect(Object.fromEntries(parsedUrl.searchParams)).to.deep.equal({ auctionTimestamp: '1616654312804', @@ -1042,7 +1043,7 @@ describe('pubxai analytics adapter', () => { const [expectedUrl, expectedData] = arg; const parsedUrl = new URL(expectedUrl); expect(parsedUrl.pathname).to.equal( - ['/analytics/bidwon', '/analytics/auction'][index] + [`/analytics/${pubxId}/bidwon`, `/analytics/${pubxId}/auction`][index] ); expect(Object.fromEntries(parsedUrl.searchParams)).to.deep.equal({ auctionTimestamp: '1616654312804',