Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.

Commit

Permalink
Don't set BCD to false if BCD has version number greater than our data (
Browse files Browse the repository at this point in the history
#1904)

* Don't set BCD to false if BCD has version number greater than our data

* Add unittest

* Use a variable rather than return (fix bug where updates just stop)
  • Loading branch information
queengooborg authored Apr 14, 2022
1 parent 06b6f65 commit 6e3482f
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 4 deletions.
3 changes: 3 additions & 0 deletions unittest/unit/bcd.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ export default {
},
RemovedInterface: {
__compat: {support: {chrome: {version_added: null}}}
},
SuperNewInterface: {
__compat: {support: {chrome: {version_added: '100'}}}
}
},
browsers: {
Expand Down
13 changes: 9 additions & 4 deletions unittest/unit/find-missing-features.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ describe('find-missing-features', () => {
'api.ExperimentalInterface',
'api.NullAPI',
'api.RemovedInterface',
'api.SuperNewInterface',
'css.properties.font-family',
'css.properties.font-face',
'javascript.builtins.Array',
Expand All @@ -64,6 +65,7 @@ describe('find-missing-features', () => {
'api.TryingOutInterface',
'api.NullAPI',
'api.RemovedInterface',
'api.SuperNewInterface',
'css.properties.font-family',
'css.properties.font-face',
'javascript.builtins.Array',
Expand Down Expand Up @@ -91,10 +93,11 @@ describe('find-missing-features', () => {
'api.ExperimentalInterface',
'api.NullAPI',
'api.RemovedInterface',
'api.SuperNewInterface',
'css.properties.font-face',
'javascript.builtins.Date'
],
total: 17
total: 18
});
});

Expand All @@ -118,9 +121,10 @@ describe('find-missing-features', () => {
'api.DummyAPI.dummy',
'api.ExperimentalInterface',
'api.NullAPI',
'api.RemovedInterface'
'api.RemovedInterface',
'api.SuperNewInterface'
],
total: 13
total: 14
});
});

Expand All @@ -138,10 +142,11 @@ describe('find-missing-features', () => {
'api.ExperimentalInterface',
'api.NullAPI',
'api.RemovedInterface',
'api.SuperNewInterface',
'css.properties.font-face',
'javascript.builtins.Date'
],
total: 17
total: 18
});

assert.isTrue(
Expand Down
37 changes: 37 additions & 0 deletions unittest/unit/update-bcd.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ const reports = [
info: {exposure: 'Window'},
result: true
},
{
name: 'api.SuperNewInterface',
info: {exposure: 'Window'},
result: false
},
{
name: 'css.properties.font-family',
info: {exposure: 'Window'},
Expand Down Expand Up @@ -158,6 +163,11 @@ const reports = [
info: {exposure: 'Window'},
result: false
},
{
name: 'api.SuperNewInterface',
info: {exposure: 'Window'},
result: false
},
{
name: 'css.properties.font-family',
info: {exposure: 'Window'},
Expand Down Expand Up @@ -227,6 +237,11 @@ const reports = [
info: {exposure: 'Window'},
result: true
},
{
name: 'api.SuperNewInterface',
info: {exposure: 'Window'},
result: false
},
{
name: 'css.properties.font-family',
info: {exposure: 'Window'},
Expand Down Expand Up @@ -331,6 +346,7 @@ describe('BCD updater', () => {
['api.ExperimentalInterface', true],
['api.NullAPI', null],
['api.RemovedInterface', true],
['api.SuperNewInterface', false],
['css.properties.font-family', true],
['css.properties.font-face', true]
])
Expand All @@ -351,6 +367,7 @@ describe('BCD updater', () => {
['api.NewInterfaceNotInBCD', false],
['api.NullAPI', null],
['api.RemovedInterface', false],
['api.SuperNewInterface', false],
['css.properties.font-family', true],
['css.properties.font-face', true]
])
Expand Down Expand Up @@ -521,6 +538,20 @@ describe('BCD updater', () => {
]
])
],
[
'api.SuperNewInterface',
new Map([
[
'chrome',
new Map([
['82', null],
['83', false],
['84', false],
['85', false]
])
]
])
],
[
'css.properties.font-family',
new Map([
Expand Down Expand Up @@ -596,6 +627,9 @@ describe('BCD updater', () => {
{version_added: '85'}
]
},
'api.SuperNewInterface': {
chrome: [{version_added: false}]
},
'css.properties.font-family': {chrome: [{version_added: '84'}]},
'css.properties.font-face': {chrome: []}
};
Expand Down Expand Up @@ -739,6 +773,9 @@ describe('BCD updater', () => {
// {version_added: '≤83', version_removed: '84'}
// ]}}
__compat: {support: {chrome: {version_added: null}}}
},
SuperNewInterface: {
__compat: {support: {chrome: {version_added: '100'}}}
}
},
browsers: {
Expand Down
27 changes: 27 additions & 0 deletions update-bcd.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,34 @@ const update = (bcd, supportMatrix, filter) => {
continue;
}

let dataIsOlder = false;
if (
inferredStatement.version_added === false &&
typeof simpleStatement.version_added === 'string'
) {
// Make sure not to update BCD if it is set to a version newer than we have in our data

for (const [version, result] of Array.from(
versionMap.entries()
).reverse()) {
if (
result !== null &&
compareVersions.compare(
version,
simpleStatement.version_added.replace('≤', ''),
'<='
)
) {
// A version we have data for is the same or newer than the version in BCD
dataIsOlder = true;
break;
}
}
}

if (dataIsOlder) {
continue;
} else if (
typeof simpleStatement.version_added === 'string' &&
typeof inferredStatement.version_added === 'string' &&
inferredStatement.version_added.includes('≤')
Expand Down

0 comments on commit 6e3482f

Please sign in to comment.