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

bcd-update: do not spuriously report modifications #2326

Merged
merged 1 commit into from
Sep 14, 2022
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
40 changes: 40 additions & 0 deletions unittest/unit/update-bcd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {Report} from '../../types/types.js';
import {assert} from 'chai';
import sinon from 'sinon';
import fs from 'fs-extra';
import {Browsers} from '@mdn/browser-compat-data/types';

import logger from '../../logger.js';
import {
Expand Down Expand Up @@ -861,5 +862,44 @@ describe('BCD updater', () => {
version_added: null
});
});

it('does not report a modification when results corroborate existing data', () => {
const firefox92UaString =
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:92.0) Gecko/20100101 Firefox/92.0';
const initialBcd = {
api: {
AbortController: {
__compat: {
support: {
firefox: {version_added: '92'}
}
}
}
},
browsers: {
firefox: {name: 'Firefox', releases: {92: {}}}
} as unknown as Browsers
};
const finalBcd = JSON.parse(JSON.stringify(initialBcd));
const report: Report = {
__version: '0.3.1',
results: {
'https://mdn-bcd-collector.appspot.com/tests/': [
{
name: 'api.AbortController',
exposure: 'Window',
result: true
}
]
},
userAgent: firefox92UaString
};
const sm = getSupportMatrix([report], initialBcd.browsers, []);

const modified = update(finalBcd, sm, {});

assert.equal(modified, false, 'modified');
assert.deepEqual(finalBcd, initialBcd);
});
});
});
3 changes: 2 additions & 1 deletion update-bcd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,8 @@ export const update = (
!(
typeof simpleStatement.version_added === 'string' &&
inferredStatement.version_added === true
)
) &&
simpleStatement.version_added !== inferredStatement.version_added
) {
simpleStatement.version_added =
typeof inferredStatement.version_added === 'string'
Expand Down