Skip to content

Commit

Permalink
allow video outstream on any placement except instream (#12491)
Browse files Browse the repository at this point in the history
  • Loading branch information
ybootin authored Nov 22, 2024
1 parent 5401652 commit 337c0aa
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 158 deletions.
43 changes: 19 additions & 24 deletions modules/seedtagBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ const BIDDER_CODE = 'seedtag';
const SEEDTAG_ALIAS = 'st';
const SEEDTAG_SSP_ENDPOINT = 'https://s.seedtag.com/c/hb/bid';
const SEEDTAG_SSP_ONTIMEOUT_ENDPOINT = 'https://s.seedtag.com/se/hb/timeout';
const ALLOWED_DISPLAY_PLACEMENTS = [
'inScreen',
'inImage',
'inArticle',
'inBanner',
];

// Global Vendor List Id
// https://iabeurope.eu/vendor-list-tcf-v2-0/
Expand Down Expand Up @@ -95,8 +89,7 @@ function hasMandatoryDisplayParams(bid) {
const p = bid.params;
return (
!!p.publisherId &&
!!p.adUnitId &&
ALLOWED_DISPLAY_PLACEMENTS.indexOf(p.placement) > -1
!!p.adUnitId
);
}

Expand All @@ -111,19 +104,7 @@ function hasMandatoryVideoParams(bid) {
isArray(videoParams.playerSize) &&
videoParams.playerSize.length > 0;

switch (bid.params.placement) {
// instream accept only video format
case 'inStream':
return isValid && (videoParams.context === 'instream' || videoParams.context === 'outstream');
// outstream accept banner/native/video format
default:
return (
isValid &&
videoParams.context === 'outstream' &&
hasBannerMediaType(bid) &&
hasMandatoryDisplayParams(bid)
);
}
return isValid
}

function buildBidRequest(validBidRequest) {
Expand Down Expand Up @@ -172,6 +153,10 @@ function getVideoParams(validBidRequest) {
return videoParams;
}

function isVideoOutstream(validBidRequest) {
return getVideoParams(validBidRequest).context === 'outstream';
}

function buildBidResponse(seedtagBid) {
const mediaType = mapMediaType(seedtagBid.mediaType);
const bid = {
Expand Down Expand Up @@ -286,9 +271,19 @@ export const spec = {
* @return boolean True if this is a valid bid, and false otherwise.
*/
isBidRequestValid(bid) {
return hasVideoMediaType(bid)
? hasMandatoryVideoParams(bid)
: hasMandatoryDisplayParams(bid);
const hasVideo = hasVideoMediaType(bid);
const hasBanner = hasBannerMediaType(bid);

// when accept both mediatype but it must be outstream
if (hasVideo && hasBanner) {
return hasMandatoryVideoParams(bid) && isVideoOutstream(bid) && hasMandatoryDisplayParams(bid);
} else if (hasVideo) {
return hasMandatoryVideoParams(bid);
} else if (hasBanner) {
return hasMandatoryDisplayParams(bid);
} else {
return false;
}
},

/**
Expand Down
195 changes: 61 additions & 134 deletions test/spec/modules/seedtagBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,13 @@ function createInStreamSlotConfig(mediaType) {
return getSlotConfigs(mediaType, {
publisherId: PUBLISHER_ID,
adUnitId: ADUNIT_ID,
placement: 'inStream',
});
}

const createBannerSlotConfig = (placement, mediatypes) => {
const createBannerSlotConfig = (mediatypes) => {
return getSlotConfigs(mediatypes || { banner: {} }, {
publisherId: PUBLISHER_ID,
adUnitId: ADUNIT_ID,
placement,
});
};

Expand All @@ -72,64 +70,69 @@ describe('Seedtag Adapter', function () {
describe('isBidRequestValid method', function () {
describe('returns true', function () {
describe('when banner slot config has all mandatory params', () => {
const placements = ['inBanner', 'inImage', 'inScreen', 'inArticle'];
placements.forEach((placement) => {
it(placement + 'should be valid', function () {
it('should be valid', function () {
const isBidRequestValid = spec.isBidRequestValid(
createBannerSlotConfig()
);
expect(isBidRequestValid).to.equal(true);
});

it('should be valid when has display and video mediatypes, and video context is outstream',
function () {
const isBidRequestValid = spec.isBidRequestValid(
createBannerSlotConfig(placement)
createBannerSlotConfig({
banner: {},
video: {
context: 'outstream',
playerSize: [[600, 200]],
},
})
);
expect(isBidRequestValid).to.equal(true);
});

it(
placement +
' should be valid when has display and video mediatypes, and video context is outstream',
function () {
const isBidRequestValid = spec.isBidRequestValid(
createBannerSlotConfig(placement, {
banner: {},
video: {
context: 'outstream',
playerSize: [[600, 200]],
},
})
);
expect(isBidRequestValid).to.equal(true);
}
);
}
);

it(
placement +
' shouldn\'t be valid when has only video mediatypes, and video context is outstream',
function () {
const isBidRequestValid = spec.isBidRequestValid(
createBannerSlotConfig(placement, {
video: {
context: 'outstream',
playerSize: [[600, 200]],
},
})
);
expect(isBidRequestValid).to.equal(false);
}
);
it(
placement +
" shouldn't be valid when has display and video mediatypes, and video context is instream",
function () {
const isBidRequestValid = spec.isBidRequestValid(
createBannerSlotConfig(placement, {
banner: {},
video: {
context: 'instream',
playerSize: [[600, 200]],
},
})
);
expect(isBidRequestValid).to.equal(false);
}
);
});
it('should be valid when has only video mediatypes, and video context is outstream',
function () {
const isBidRequestValid = spec.isBidRequestValid(
createBannerSlotConfig({
video: {
context: 'outstream',
playerSize: [[600, 200]],
},
})
);
expect(isBidRequestValid).to.equal(true);
}
);
it('should be valid when has display and video mediatypes, and video context is instream',
function () {
const isBidRequestValid = spec.isBidRequestValid(
createBannerSlotConfig({
banner: {},
video: {
context: 'instream',
playerSize: [[600, 200]],
},
})
);
expect(isBidRequestValid).to.equal(false);
}
);
it("shouldn't be valid when has display and video mediatypes, and video context is instream",
function () {
const isBidRequestValid = spec.isBidRequestValid(
createBannerSlotConfig({
banner: {},
video: {
context: 'instream',
playerSize: [[600, 200]],
},
})
);
expect(isBidRequestValid).to.equal(false);
}
);
});
describe('when video slot has all mandatory params', function () {
it('should return true, when video context is instream', function () {
Expand All @@ -142,7 +145,7 @@ describe('Seedtag Adapter', function () {
const isBidRequestValid = spec.isBidRequestValid(slotConfig);
expect(isBidRequestValid).to.equal(true);
});
it('should return true, when video context is instream and mediatype is video and banner', function () {
it('should return false, when video context is instream and mediatype is video and banner', function () {
const slotConfig = createInStreamSlotConfig({
video: {
context: 'instream',
Expand All @@ -151,61 +154,8 @@ describe('Seedtag Adapter', function () {
banner: {},
});
const isBidRequestValid = spec.isBidRequestValid(slotConfig);
expect(isBidRequestValid).to.equal(true);
});
it('should return false, when video context is instream, but placement is not inStream', function () {
const slotConfig = getSlotConfigs(
{
video: {
context: 'instream',
playerSize: [[600, 200]],
},
},
{
publisherId: PUBLISHER_ID,
adUnitId: ADUNIT_ID,
placement: 'inBanner',
}
);
const isBidRequestValid = spec.isBidRequestValid(slotConfig);
expect(isBidRequestValid).to.equal(false);
});

it('should return true when placement is inStream and video context is outstream', function () {
const slotConfig = getSlotConfigs(
{
video: {
context: 'instream',
playerSize: [[600, 200]],
},
},
{
publisherId: PUBLISHER_ID,
adUnitId: ADUNIT_ID,
placement: 'inStream',
}
);
const isBidRequestValid = spec.isBidRequestValid(slotConfig);
expect(isBidRequestValid).to.equal(true);
});

it('should return true when placement is inStream and video context is instream', function () {
const slotConfig = getSlotConfigs(
{
video: {
context: 'outstream',
playerSize: [[600, 200]],
},
},
{
publisherId: PUBLISHER_ID,
adUnitId: ADUNIT_ID,
placement: 'inStream',
}
);
const isBidRequestValid = spec.isBidRequestValid(slotConfig);
expect(isBidRequestValid).to.equal(true);
});
});
});
describe('returns false', function () {
Expand All @@ -217,7 +167,6 @@ describe('Seedtag Adapter', function () {
const isBidRequestValid = spec.isBidRequestValid(
createSlotConfig({
adUnitId: ADUNIT_ID,
placement: 'inBanner',
})
);
expect(isBidRequestValid).to.equal(false);
Expand All @@ -226,26 +175,6 @@ describe('Seedtag Adapter', function () {
const isBidRequestValid = spec.isBidRequestValid(
createSlotConfig({
publisherId: PUBLISHER_ID,
placement: 'inBanner',
})
);
expect(isBidRequestValid).to.equal(false);
});
it('does not have the placement.', function () {
const isBidRequestValid = spec.isBidRequestValid(
createSlotConfig({
publisherId: PUBLISHER_ID,
adUnitId: ADUNIT_ID,
})
);
expect(isBidRequestValid).to.equal(false);
});
it('does not have a the correct placement.', function () {
const isBidRequestValid = spec.isBidRequestValid(
createSlotConfig({
publisherId: PUBLISHER_ID,
adUnitId: ADUNIT_ID,
placement: 'another_thing',
})
);
expect(isBidRequestValid).to.equal(false);
Expand Down Expand Up @@ -293,12 +222,10 @@ describe('Seedtag Adapter', function () {
const mandatoryDisplayParams = {
publisherId: PUBLISHER_ID,
adUnitId: ADUNIT_ID,
placement: 'inBanner',
};
const mandatoryVideoParams = {
publisherId: PUBLISHER_ID,
adUnitId: ADUNIT_ID,
placement: 'inStream',
};
const validBidRequests = [
getSlotConfigs({ banner: {} }, mandatoryDisplayParams),
Expand Down

0 comments on commit 337c0aa

Please sign in to comment.