Skip to content
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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

All changes that impact users of this module are documented in this file, in the [Common Changelog](https://common-changelog.org) format with some additional specifications defined in the CONTRIBUTING file. This codebase adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased [patch]

> Development of this release was supported by [Reset Tech](https://www.reset.tech).

### Fixed

- Fix declaration validation when a new service is added along with a filters file

## 10.6.0 - 2026-01-26

> Development of this release was supported by [Reset Tech](https://www.reset.tech).
Expand Down
4 changes: 4 additions & 0 deletions scripts/declarations/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ export default class DeclarationUtils {
if (modifiedFilePath.endsWith('.filters.js') || modifiedFilePath.endsWith('.filters.history.js')) {
const declaration = await this.getJSONFromFile(this.defaultBranch, `declarations/${serviceId}.json`);

if (!declaration) { // Happens when the file declaration exists in the branch but not in the default branch
return;
}

servicesTermsTypes[serviceId] = Object.keys(declaration.terms); // Considering how rarely filters are used, simply return all term types that could potentially be impacted to spare implementing a function change check

return;
Expand Down
17 changes: 17 additions & 0 deletions scripts/declarations/utils/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,23 @@ describe('DeclarationUtils', () => {
});
});

context('when a new declaration has been added along with a filters file', () => {
before(async () => {
await fs.writeFile(path.resolve(SUBJECT_PATH, COMMIT_PATHS.serviceB), JSON.stringify(FIXTURES.serviceB.content, null, 2));
await fs.writeFile(path.resolve(SUBJECT_PATH, './declarations/ServiceB.filters.js'), 'module.exports = {};');
await declarationUtils.git.add([ COMMIT_PATHS.serviceB, './declarations/ServiceB.filters.js' ]);
await declarationUtils.git.commit('Add declaration with filters for new service');
});
after(removeLatestCommit);

it('returns the added service ID along with all its terms types', async () => {
expect(await declarationUtils.getModifiedServicesAndTermsTypes()).to.deep.equal({
services: ['ServiceB'],
servicesTermsTypes: { ServiceB: ['Terms of Service'] },
});
});
});

context('when history file is modified without declaration changes', () => {
before(() => commitChanges(COMMIT_PATHS.serviceAHistory, FIXTURES.serviceATermsUpdatedHistory.content));
after(removeLatestCommit);
Expand Down
Loading