From c90f9b3cd75b9cfa4b5701ef8d4dd0d2fedee4c8 Mon Sep 17 00:00:00 2001 From: Doceree-techStack <143162581+Doceree-techStack@users.noreply.github.com> Date: Tue, 22 Oct 2024 18:16:34 +0530 Subject: [PATCH] docereeAdManager Bid Adapter : updated bid adapter (#12333) * Updated docereeAdManager bid adapter * Updated docereeAdManager bid adapter * Updated docereeAdManager bid adapter * Updated docereeAdManager bid adapter * Updated docereeAdManager bid adapter * Updated docereeAdManager bid adapter * Update docereeAdManagerBidAdapter.js * added test cases for payload formation in DocereeAdManager * Added support for publisherUrl * added some parameters * Added support for TCF 2.2 * Update docereeAdManagerBidAdapter.js * Update docereeAdManagerBidAdapter.js * Update docereeAdManagerBidAdapter.js * Written test cases for new method implemented. * indentation issues resolved * Update docereeAdManagerBidAdapter_spec.js * Update docereeAdManagerBidAdapter_spec.js * Update docereeAdManagerBidAdapter_spec.js --------- Co-authored-by: lokesh-doceree Co-authored-by: Patrick McCann --- modules/docereeAdManagerBidAdapter.js | 12 +++++++++++- .../modules/docereeAdManagerBidAdapter_spec.js | 17 +++++++++++++---- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/modules/docereeAdManagerBidAdapter.js b/modules/docereeAdManagerBidAdapter.js index d7a28d6b788..e26045c8f1f 100644 --- a/modules/docereeAdManagerBidAdapter.js +++ b/modules/docereeAdManagerBidAdapter.js @@ -70,10 +70,20 @@ export const spec = { }, }; +export function getPageUrl() { + let url = ''; + try { + url = window.location.href; + } catch (error) { + } + return url; +} + export function getPayload(bid, userData, bidderRequest) { if (!userData || !bid) { return false; } + const { bidId, params } = bid; const { placementId, publisherUrl } = params; const { @@ -121,7 +131,7 @@ export function getPayload(bid, userData, bidderRequest) { dob: dob || '', userconsent: 1, mobile: mobile || '', - pageurl: publisherUrl || '' + pageurl: publisherUrl || getPageUrl() || '' }; try { diff --git a/test/spec/modules/docereeAdManagerBidAdapter_spec.js b/test/spec/modules/docereeAdManagerBidAdapter_spec.js index 268e30f542d..704b9c48d3a 100644 --- a/test/spec/modules/docereeAdManagerBidAdapter_spec.js +++ b/test/spec/modules/docereeAdManagerBidAdapter_spec.js @@ -1,6 +1,7 @@ import { expect } from 'chai'; -import { spec, getPayload } from '../../../modules/docereeAdManagerBidAdapter.js'; +import { spec, getPayload, getPageUrl } from '../../../modules/docereeAdManagerBidAdapter.js'; import { config } from '../../../src/config.js'; +import * as utils from '../../../src/utils.js'; describe('docereeadmanager', function () { config.setConfig({ @@ -125,8 +126,15 @@ describe('docereeadmanager', function () { }); }); - describe('payload', function() { - it('should return payload with the correct data', function() { + describe('getPageUrl', function () { + it('should return an url string', function () { + const result = getPageUrl(); + expect(result).to.equal(utils.getWindowSelf().location.href); + }); + }); + + describe('payload', function () { + it('should return payload with the correct data', function () { const data = { userId: 'xxxxx', email: 'xxxx@mail.com', @@ -148,7 +156,7 @@ describe('docereeadmanager', function () { platformUid: 'Xx.xxx.xxxxxx', mobile: 'XXXXXXXXXX', } - bid = {...bid, params: {...bid.params, placementId: 'DOC-19-1'}} + bid = { ...bid, params: { ...bid.params, placementId: 'DOC-19-1' } } const buildRequests = { gdprConsent: { consentString: 'COwK6gaOwK6gaFmAAAENAPCAAAAAAAAAAAAAAAAAAAAA.IFoEUQQgAIQwgIwQABAEAAAAOIAACAIAAAAQAIAgEAACEAAAAAgAQBAAAAAAAGBAAgAAAAAAAFAAECAAAgAAQARAEQAAAAAJAAIAAgAAAYQEAAAQmAgBC3ZAYzUw', @@ -156,6 +164,7 @@ describe('docereeadmanager', function () { } } const payload = getPayload(bid, data, buildRequests); + const payloadData = payload.data; expect(payloadData).to.have.all.keys( 'userid',