From 8750607d3d7321f625856c140f839a3e94beaf54 Mon Sep 17 00:00:00 2001 From: Jason Gessner Date: Fri, 13 Dec 2024 23:37:31 -0600 Subject: [PATCH 1/2] Add a test to ensure that all restrictions are also in a snapshot. --- test/validate_v2.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/test/validate_v2.ts b/test/validate_v2.ts index a6766c7c..1683f81c 100644 --- a/test/validate_v2.ts +++ b/test/validate_v2.ts @@ -473,6 +473,31 @@ describe('Restrictions', () => { } }); }); + + it('are present in format files', () => { + let restrictionIdsFromFormats = new Set(); + + // Get all formats and their listed snapshots. + formatsByFilename.forEach((format, file) => { + format.snapshots.forEach(snapshot => { + if ('restriction_id' in snapshot) { + restrictionIdsFromFormats.add(snapshot.restriction_id); + } + }); + }); + + // Put any startup banlists for NRDB Classic in here. + const ignoreRestrictions = new Set( + ['startup_ban_list_24_01_for_classic_only', 'startup_ban_list_24_09_for_classic_only']); + + restrictionIds.forEach((restrictionId) => { + if (ignoreRestrictions.has(restrictionId)) { + return; + } + + expect(restrictionIdsFromFormats, `Restriction ${restrictionId} is not specified in any format snapshots.`).to.include(restrictionId); + }); + }); }); describe('Formats', () => { From bcddbcb8ba5a242b4d0db335808c60b6334d786d Mon Sep 17 00:00:00 2001 From: Jason Gessner Date: Sat, 14 Dec 2024 00:06:49 -0600 Subject: [PATCH 2/2] Lint fixes. --- test/validate_v2.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/validate_v2.ts b/test/validate_v2.ts index 1683f81c..400737c5 100644 --- a/test/validate_v2.ts +++ b/test/validate_v2.ts @@ -475,10 +475,10 @@ describe('Restrictions', () => { }); it('are present in format files', () => { - let restrictionIdsFromFormats = new Set(); + const restrictionIdsFromFormats = new Set(); // Get all formats and their listed snapshots. - formatsByFilename.forEach((format, file) => { + formatsByFilename.forEach((format) => { format.snapshots.forEach(snapshot => { if ('restriction_id' in snapshot) { restrictionIdsFromFormats.add(snapshot.restriction_id);