From 46d2dcf910702c99affbb45daa020eb2d850e432 Mon Sep 17 00:00:00 2001 From: Nicolas Dupont Date: Thu, 5 Feb 2026 10:32:28 +0100 Subject: [PATCH 1/3] Fix validation for new declaration with filters --- scripts/declarations/utils/index.js | 4 ++++ scripts/declarations/utils/index.test.js | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/scripts/declarations/utils/index.js b/scripts/declarations/utils/index.js index 6b3338a9c..ce9385aa5 100644 --- a/scripts/declarations/utils/index.js +++ b/scripts/declarations/utils/index.js @@ -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; diff --git a/scripts/declarations/utils/index.test.js b/scripts/declarations/utils/index.test.js index c60babae0..616904567 100644 --- a/scripts/declarations/utils/index.test.js +++ b/scripts/declarations/utils/index.test.js @@ -188,6 +188,26 @@ describe('DeclarationUtils', () => { }); }); + context('when a new declaration has been added along with a filters file', () => { + before(async () => { + await commitChanges(COMMIT_PATHS.serviceB, FIXTURES.serviceB.content); + await fs.writeFile(path.resolve(SUBJECT_PATH, './declarations/ServiceB.filters.js'), 'module.exports = {};'); + await declarationUtils.git.add('./declarations/ServiceB.filters.js'); + await declarationUtils.git.commit('Add filters file for new service', './declarations/ServiceB.filters.js'); + }); + after(async () => { + await removeLatestCommit(); + await 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); From 7722960482e7f8c5d5f061126318fa534a7a6072 Mon Sep 17 00:00:00 2001 From: Nicolas Dupont Date: Thu, 5 Feb 2026 10:33:08 +0100 Subject: [PATCH 2/3] Add changelog entry --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27a2e5287..f0cbea108 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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). From d9692adfee4a5f9a01e3778bf723ac736faa31d6 Mon Sep 17 00:00:00 2001 From: Nicolas Dupont Date: Thu, 5 Feb 2026 10:36:40 +0100 Subject: [PATCH 3/3] Simplify test --- scripts/declarations/utils/index.test.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/scripts/declarations/utils/index.test.js b/scripts/declarations/utils/index.test.js index 616904567..2b26033b6 100644 --- a/scripts/declarations/utils/index.test.js +++ b/scripts/declarations/utils/index.test.js @@ -190,15 +190,12 @@ describe('DeclarationUtils', () => { context('when a new declaration has been added along with a filters file', () => { before(async () => { - await commitChanges(COMMIT_PATHS.serviceB, FIXTURES.serviceB.content); + 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('./declarations/ServiceB.filters.js'); - await declarationUtils.git.commit('Add filters file for new service', './declarations/ServiceB.filters.js'); - }); - after(async () => { - await removeLatestCommit(); - await removeLatestCommit(); + 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({