Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prebid 8: do not keep previous floor data on subsequent setConfigs #10051

Merged
merged 1 commit into from
Jun 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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