From 34ab7b5ec1a44dc39e02edc6b6a20e9957352887 Mon Sep 17 00:00:00 2001 From: Aleksey Khoroshilov Date: Fri, 25 Oct 2024 14:06:24 +0700 Subject: [PATCH] Forbid the version to be Brave-only (without the Chromium major). --- src/seed_tools/utils/study_validation.test.ts | 41 ++++++++++--------- src/seed_tools/utils/study_validation.ts | 4 +- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/src/seed_tools/utils/study_validation.test.ts b/src/seed_tools/utils/study_validation.test.ts index 107b3fae..a0348824 100644 --- a/src/seed_tools/utils/study_validation.test.ts +++ b/src/seed_tools/utils/study_validation.test.ts @@ -596,27 +596,28 @@ describe('getStudyErrors', () => { ); }); - test.each([{ min_version: '130.0.6517.0' }, { max_version: '135.0.6707.0' }])( - 'should error if version is Chromium %s', - (filter: any) => { - const study = Study.fromJson({ - name: 'study', - experiment: [ - { - name: 'experiment1', - probability_weight: 100, - }, - ], - filter, - }); + test.each([ + { min_version: '130.0.6517.0' }, + { max_version: '135.0.6707.0' }, + { min_version: '1.65.70' }, + ])('should error if version is non-Brave %s', (filter: any) => { + const study = Study.fromJson({ + name: 'study', + experiment: [ + { + name: 'experiment1', + probability_weight: 100, + }, + ], + filter, + }); - expect( - study_validation.getStudyErrors(study, studyFileBaseName), - ).toContainEqual( - expect.stringContaining('Detected Chromium version in a filter'), - ); - }, - ); + expect( + study_validation.getStudyErrors(study, studyFileBaseName), + ).toContainEqual( + expect.stringContaining('Detected non-Brave version in a filter'), + ); + }); test.each([{ min_version: '130.1.70.0' }, { max_version: '135.1.91.0' }])( 'should not error if version is Brave %s', diff --git a/src/seed_tools/utils/study_validation.ts b/src/seed_tools/utils/study_validation.ts index ba361ea0..51e65dd3 100644 --- a/src/seed_tools/utils/study_validation.ts +++ b/src/seed_tools/utils/study_validation.ts @@ -239,10 +239,10 @@ function checkVersionRange(study: Study): string[] { if ( version !== undefined && version.components.length >= 3 && - version.components[2] > 6000 + (version.components[0] < 90 || version.components[2] > 6000) ) { errors.push( - `Detected Chromium version in a filter for study ${study.name}: ${version.toString()}. Use Brave version in a format CHROMIUM_MAJOR.BRAVE_MAJOR.BRAVE_MINOR.BRAVE_BUILD`, + `Detected non-Brave version in a filter for study ${study.name}: ${version.toString()}. Use Brave version in a format CHROMIUM_MAJOR.BRAVE_MAJOR.BRAVE_MINOR.BRAVE_BUILD`, ); } };