Skip to content

Commit

Permalink
Prebid 8: do not keep previous floor data on subsequent setConfigs (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
dgirardi authored Jun 5, 2023
1 parent 09062b3 commit dd6c174
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 22 deletions.
2 changes: 1 addition & 1 deletion modules/priceFloors.js
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ export function handleSetFloorsConfig(config) {
'bidAdjustment', bidAdjustment => bidAdjustment !== false, // defaults to true
]),
'additionalSchemaFields', additionalSchemaFields => typeof additionalSchemaFields === 'object' && Object.keys(additionalSchemaFields).length > 0 ? addFieldOverrides(additionalSchemaFields) : undefined,
'data', data => (data && parseFloorData(data, 'setConfig')) || _floorsConfig.data // do not overwrite if passed in data not valid
'data', data => (data && parseFloorData(data, 'setConfig')) || undefined
]);

// if enabled then do some stuff
Expand Down
24 changes: 3 additions & 21 deletions test/spec/modules/priceFloors_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ describe('the price floors module', function () {
const validateBidRequests = (getFloorExpected, FloorDataExpected) => {
exposedAdUnits.forEach(adUnit => adUnit.bids.forEach(bid => {
expect(bid.hasOwnProperty('getFloor')).to.equal(getFloorExpected);
expect(bid.floorData).to.deep.equal(FloorDataExpected);
sinon.assert.match(bid.floorData, FloorDataExpected);
}));
};
const runStandardAuction = (adUnits = [getAdUnitMock('test_div_1')]) => {
Expand Down Expand Up @@ -918,16 +918,8 @@ describe('the price floors module', function () {
floorProvider: 'floorprovider'
});
});
it('should not overwrite previous data object if the new one is bad', function () {
it('should ignore and reset floor data when provided with invalid data', function () {
handleSetFloorsConfig({...basicFloorConfig});
handleSetFloorsConfig({
...basicFloorConfig,
data: undefined
});
handleSetFloorsConfig({
...basicFloorConfig,
data: 5
});
handleSetFloorsConfig({
...basicFloorConfig,
data: {
Expand All @@ -937,17 +929,7 @@ describe('the price floors module', function () {
}
});
runStandardAuction();
validateBidRequests(true, {
skipped: false,
floorMin: undefined,
modelVersion: 'basic model',
modelWeight: 10,
modelTimestamp: 1606772895,
location: 'setConfig',
skipRate: 0,
fetchStatus: undefined,
floorProvider: undefined
});
validateBidRequests(false, sinon.match({location: 'noData', skipped: true}));
});
it('should dynamically add new schema fileds and functions if added via setConfig', function () {
let deviceSpoof;
Expand Down

0 comments on commit dd6c174

Please sign in to comment.