Skip to content

Commit

Permalink
Ssp_geniee Bid Adapter : fix imuid module and spec.js (#12428)
Browse files Browse the repository at this point in the history
* modify adUnit infomation

* fix imuid module

* fix spec.js

* fix import

* fix deep.equal

---------

Co-authored-by: Murano Takamasa <[email protected]>
Co-authored-by: daikichiteranishi <[email protected]>
  • Loading branch information
3 people authored Nov 8, 2024
1 parent 05a1065 commit e348fc8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 61 deletions.
18 changes: 3 additions & 15 deletions modules/ssp_genieeBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ function makeCommonRequestData(bid, geparameter, refererInfo) {
}

// imuid
const imuidQuery = getImuidAsQueryParameter();
const imuidQuery = getImuidAsQueryParameter(bid);
if (imuidQuery) data.extuid = imuidQuery;

// makeUAQuery
Expand Down Expand Up @@ -308,21 +308,11 @@ function makeBidResponseAd(innerHTML) {
return '<body marginwidth="0" marginheight="0">' + innerHTML + '</body>';
}

/**
* add imuid script tag
*/
function appendImuidScript() {
const scriptEl = document.createElement('script');
scriptEl.src = '//dmp.im-apps.net/scripts/im-uid-hook.js?cid=3929';
scriptEl.async = true;
document.body.appendChild(scriptEl);
}

/**
* return imuid strings as query parameters
*/
function getImuidAsQueryParameter() {
const imuid = storage.getCookie('_im_uid.3929');
function getImuidAsQueryParameter(bid) {
const imuid = utils.deepAccess(bid, 'userId.imuid');
return imuid ? 'im:' + imuid : ''; // To avoid double encoding, not using encodeURIComponent here
}

Expand Down Expand Up @@ -404,8 +394,6 @@ export const spec = {
return bidResponses;
}

appendImuidScript();

const zoneId = bidderRequest.bid.params.zoneId;
let successBid;
successBid = serverResponse.body || {};
Expand Down
72 changes: 26 additions & 46 deletions test/spec/modules/ssp_genieeBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
spec,
BANNER_ENDPOINT,
} from 'modules/ssp_genieeBidAdapter.js';
import { config } from '../../../src/config.js';
import { config } from 'src/config.js';

describe('ssp_genieeBidAdapter', function () {
const ZONE_ID = 1234567;
Expand Down Expand Up @@ -128,22 +128,16 @@ describe('ssp_genieeBidAdapter', function () {
describe('QueryStringParameters', function () {
it('should sets the value of the zoneid query to bid.params.zoneId', function () {
const request = spec.buildRequests([BANNER_BID]);
expect(String(request[0].data.zoneid)).to.have.string(
`${BANNER_BID.params.zoneId}`
);
expect(request[0].data.zoneid).to.deep.equal(BANNER_BID.params.zoneId);
});

it('should sets the values for loc and referer queries when bidderRequest.refererInfo.referer has a value', function () {
const referer = 'https://example.com/';
const request = spec.buildRequests([BANNER_BID], {
refererInfo: { legacy: { referer: referer }, ref: referer },
});
expect(String(request[0].data.loc)).to.have.string(
`${referer}`
);
expect(String(request[0].data.referer)).to.have.string(
`${referer}`
);
expect(request[0].data.loc).to.deep.equal(referer);
expect(request[0].data.referer).to.deep.equal(referer);
});

it('should makes the values of loc query and referer query geparams value when bidderRequest.refererInfo.referer is a falsy value', function () {
Expand All @@ -156,12 +150,8 @@ describe('ssp_genieeBidAdapter', function () {
const request = spec.buildRequests([
getGeparamsDefinedBid(BANNER_BID, { loc: loc, ref: referer }),
]);
expect(String(request[0].data.loc)).to.have.string(
`${encodeURIComponent(loc)}`
);
expect(String(request[0].data.referer)).to.have.string(
`${encodeURIComponent(referer)}`
);
expect(request[0].data.loc).to.deep.equal(encodeURIComponent(loc));
expect(request[0].data.referer).to.deep.equal(encodeURIComponent(referer));
});

it('should sets the value of the ct0 query to geparams.ct0', function () {
Expand All @@ -172,12 +162,12 @@ describe('ssp_genieeBidAdapter', function () {
const request = spec.buildRequests([
getGeparamsDefinedBid(BANNER_BID, { ct0: ct0 }),
]);
expect(String(request[0].data.ct0)).to.have.string(`${ct0}`);
expect(request[0].data.ct0).to.deep.equal(ct0);
});

it('should replaces currency with JPY if there is no currency provided', function () {
const request = spec.buildRequests([BANNER_BID]);
expect(String(request[0].data.cur)).to.have.string('JPY');
expect(request[0].data.cur).to.deep.equal('JPY');
});

it('should makes currency the value of params.currency when params.currency exists', function () {
Expand All @@ -191,8 +181,8 @@ describe('ssp_genieeBidAdapter', function () {
params: { ...BANNER_BID.params, currency: 'USD' },
},
]);
expect(String(request[0].data.cur)).to.have.string('JPY');
expect(String(request[1].data.cur)).to.have.string('USD');
expect(request[0].data.cur).to.deep.equal('JPY');
expect(request[1].data.cur).to.deep.equal('USD');
});

it('should makes invalidImpBeacon the value of params.invalidImpBeacon when params.invalidImpBeacon exists (in current version, this parameter is not necessary and ib is always `0`)', function () {
Expand All @@ -210,9 +200,9 @@ describe('ssp_genieeBidAdapter', function () {
params: { ...BANNER_BID.params },
},
]);
expect(String(request[0].data.ib)).to.have.string('0');
expect(String(request[1].data.ib)).to.have.string('0');
expect(String(request[2].data.ib)).to.have.string('0');
expect(request[0].data.ib).to.deep.equal(0);
expect(request[1].data.ib).to.deep.equal(0);
expect(request[2].data.ib).to.deep.equal(0);
});

it('should not sets the value of the adtk query when geparams.lat does not exist', function () {
Expand All @@ -227,7 +217,7 @@ describe('ssp_genieeBidAdapter', function () {
const request = spec.buildRequests([
getGeparamsDefinedBid(BANNER_BID, { lat: 1 }),
]);
expect(String(request[0].data.adtk)).to.have.string('0');
expect(request[0].data.adtk).to.deep.equal('0');
});

it('should sets the value of the adtk query to 1 when geparams.lat is falsy value', function () {
Expand All @@ -237,7 +227,7 @@ describe('ssp_genieeBidAdapter', function () {
const request = spec.buildRequests([
getGeparamsDefinedBid(BANNER_BID, { lat: 0 }),
]);
expect(String(request[0].data.adtk)).to.have.string('1');
expect(request[0].data.adtk).to.deep.equal('1');
});

it('should sets the value of the idfa query to geparams.idfa', function () {
Expand All @@ -248,7 +238,7 @@ describe('ssp_genieeBidAdapter', function () {
const request = spec.buildRequests([
getGeparamsDefinedBid(BANNER_BID, { idfa: idfa }),
]);
expect(String(request[0].data.idfa)).to.have.string(`${idfa}`);
expect(request[0].data.idfa).to.deep.equal(idfa);
});

it('should set the sw query to screen.height and the sh query to screen.width when screen.width is greater than screen.height', function () {
Expand All @@ -258,8 +248,8 @@ describe('ssp_genieeBidAdapter', function () {
return { width: width, height: height };
});
const request = spec.buildRequests([BANNER_BID]);
expect(String(request[0].data.sw)).to.have.string(`${height}`);
expect(String(request[0].data.sh)).to.have.string(`${width}`);
expect(request[0].data.sw).to.deep.equal(height);
expect(request[0].data.sh).to.deep.equal(width);
stub.restore();
});

Expand All @@ -270,8 +260,8 @@ describe('ssp_genieeBidAdapter', function () {
return { width: width, height: height };
});
const request = spec.buildRequests([BANNER_BID]);
expect(String(request[0].data.sw)).to.have.string(`${width}`);
expect(String(request[0].data.sh)).to.have.string(`${height}`);
expect(request[0].data.sw).to.deep.equal(width);
expect(request[0].data.sh).to.deep.equal(height);
stub.restore();
});

Expand Down Expand Up @@ -354,28 +344,18 @@ describe('ssp_genieeBidAdapter', function () {
const request = spec.buildRequests([
getGeparamsDefinedBid(BANNER_BID, { bundle: bundle }),
]);
expect(String(request[0].data.apid)).to.have.string(`${bundle}`);
expect(request[0].data.apid).to.deep.equal(bundle);
});

it('should not include the extuid query when it does not contain the imuid cookie', function () {
const stub = sinon.stub(document, 'cookie').get(function () {
return '';
});
it('should not include the extuid query when bid.userId.imuid does not exist', function () {
const request = spec.buildRequests([BANNER_BID]);
expect(request[0].data).to.not.have.property('extuid');
stub.restore();
});

it('should include an extuid query when it contains an imuid cookie', function () {
it('should include an extuid query when bid.userId.imuid exists', function () {
const imuid = 'b.a4ad1d3eeb51e600';
const stub = sinon.stub(document, 'cookie').get(function () {
return `_im_uid.3929=${imuid}`;
});
const request = spec.buildRequests([BANNER_BID]);
expect(String(request[0].data.extuid)).to.have.string(
`${`im:${imuid}`}`
);
stub.restore();
const request = spec.buildRequests([{...BANNER_BID, userId: {imuid}}]);
expect(request[0].data.extuid).to.deep.equal(`im:${imuid}`);
});
});
});
Expand Down Expand Up @@ -415,7 +395,7 @@ describe('ssp_genieeBidAdapter', function () {
};
const request = spec.buildRequests([BANNER_BID])[0];
const result = spec.interpretResponse({ body: response }, request);
expect(result[0]).to.have.deep.equal(expectedBanner);
expect(result[0]).to.deep.equal(expectedBanner);
});
});
});

0 comments on commit e348fc8

Please sign in to comment.