Skip to content

Commit

Permalink
Beachfront Bid Adapter: add schain support (#6751)
Browse files Browse the repository at this point in the history
* add schain support to beachfront adapter

* remove unnecessary mock tests for outstream player

Co-authored-by: John Salis <[email protected]>
  • Loading branch information
2 people authored and idettman committed May 21, 2021
1 parent 174f0ea commit 855bff0
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 59 deletions.
11 changes: 11 additions & 0 deletions modules/beachfrontBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,9 @@ function createVideoRequestData(bid, bidderRequest) {
regs: {
ext: {}
},
source: {
ext: {}
},
user: {
ext: {}
},
Expand All @@ -367,6 +370,10 @@ function createVideoRequestData(bid, bidderRequest) {
payload.user.ext.consent = consentString;
}

if (bid.schain) {
payload.source.ext.schain = bid.schain;
}

if (eids.length > 0) {
payload.user.ext.eids = eids;
}
Expand Down Expand Up @@ -416,6 +423,10 @@ function createBannerRequestData(bids, bidderRequest) {
payload.gdprConsent = consentString;
}

if (bids[0] && bids[0].schain) {
payload.schain = bids[0].schain;
}

SUPPORTED_USER_IDS.forEach(({ key, queryParam }) => {
let id = bids[0] && bids[0].userId && bids[0].userId[key];
if (id) {
Expand Down
2 changes: 1 addition & 1 deletion modules/beachfrontBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Module Name: Beachfront Bid Adapter

Module Type: Bidder Adapter

Maintainer: john@beachfront.com
Maintainer: prebid@beachfront.com

# Description

Expand Down
101 changes: 43 additions & 58 deletions test/spec/modules/beachfrontBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { expect } from 'chai';
import sinon from 'sinon';
import { spec, VIDEO_ENDPOINT, BANNER_ENDPOINT, OUTSTREAM_SRC, DEFAULT_MIMES } from 'modules/beachfrontBidAdapter.js';
import { parseUrl } from 'src/utils.js';

Expand Down Expand Up @@ -278,6 +277,27 @@ describe('BeachfrontAdapter', function () {
expect(data.user.ext.consent).to.equal(consentString);
});

it('must add schain data to the request', () => {
const schain = {
ver: '1.0',
complete: 1,
nodes: [
{
asi: 'directseller.com',
sid: '00001',
rid: 'BidRequest1',
hp: 1
}
]
};
const bidRequest = bidRequests[0];
bidRequest.mediaTypes = { video: {} };
bidRequest.schain = schain;
const requests = spec.buildRequests([ bidRequest ]);
const data = requests[0].data;
expect(data.source.ext.schain).to.deep.equal(schain);
});

it('must add the Trade Desk User ID to the request', () => {
const tdid = '4321';
const bidRequest = bidRequests[0];
Expand Down Expand Up @@ -446,6 +466,27 @@ describe('BeachfrontAdapter', function () {
expect(data.gdprConsent).to.equal(consentString);
});

it('must add schain data to the request', () => {
const schain = {
ver: '1.0',
complete: 1,
nodes: [
{
asi: 'directseller.com',
sid: '00001',
rid: 'BidRequest1',
hp: 1
}
]
};
const bidRequest = bidRequests[0];
bidRequest.mediaTypes = { banner: {} };
bidRequest.schain = schain;
const requests = spec.buildRequests([ bidRequest ]);
const data = requests[0].data;
expect(data.schain).to.deep.equal(schain);
});

it('must add the Trade Desk User ID to the request', () => {
const tdid = '4321';
const bidRequest = bidRequests[0];
Expand Down Expand Up @@ -654,63 +695,7 @@ describe('BeachfrontAdapter', function () {
id: bidRequest.bidId,
url: OUTSTREAM_SRC
});
});

it('should initialize a player for outstream bids', () => {
const width = 640;
const height = 480;
const bidRequest = bidRequests[0];
bidRequest.mediaTypes = {
video: {
context: 'outstream',
playerSize: [ width, height ]
}
};
const serverResponse = {
bidPrice: 5.00,
url: 'http://reachms.bfmio.com/getmu?aid=bid:19c4a196-fb21-4c81-9a1a-ecc5437a39da',
crid: '123abc'
};
const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest });
window.Beachfront = { Player: sinon.spy() };
bidResponse.adUnitCode = bidRequest.adUnitCode;
bidResponse.renderer.render(bidResponse);
sinon.assert.calledWith(window.Beachfront.Player, bidResponse.adUnitCode, sinon.match({
adTagUrl: bidResponse.vastUrl,
width: bidResponse.width,
height: bidResponse.height,
expandInView: false,
collapseOnComplete: true
}));
delete window.Beachfront;
});

it('should configure outstream player settings from the bidder params', () => {
const width = 640;
const height = 480;
const bidRequest = bidRequests[0];
bidRequest.mediaTypes = {
video: {
context: 'outstream',
playerSize: [ width, height ]
}
};
bidRequest.params.player = {
expandInView: true,
collapseOnComplete: false,
progressColor: 'green'
};
const serverResponse = {
bidPrice: 5.00,
url: 'http://reachms.bfmio.com/getmu?aid=bid:19c4a196-fb21-4c81-9a1a-ecc5437a39da',
crid: '123abc'
};
const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest });
window.Beachfront = { Player: sinon.spy() };
bidResponse.adUnitCode = bidRequest.adUnitCode;
bidResponse.renderer.render(bidResponse);
sinon.assert.calledWith(window.Beachfront.Player, bidResponse.adUnitCode, sinon.match(bidRequest.params.player));
delete window.Beachfront;
expect(bidResponse.renderer.render).to.be.a('function');
});
});

Expand Down

0 comments on commit 855bff0

Please sign in to comment.