tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 4152252cd0fc1801f3121c62243c283c24bf4e67
parent 722c47dfd312afb26f4e33918d7e38d80a622cf9
Author: Beth Rennie <beth@brennie.ca>
Date:   Tue,  2 Dec 2025 18:17:47 +0000

Bug 2003365 - Remove NimbusTestUtils.waitForActiveEnrollments r=nimbus-reviewers,relud

Differential Revision: https://phabricator.services.mozilla.com/D274648

Diffstat:
Mtoolkit/components/nimbus/test/NimbusTestUtils.sys.mjs | 37++++++++++++++++++++++++++++++-------
Mtoolkit/components/nimbus/test/unit/test_ExperimentManager_prefs.js | 3+--
Mtoolkit/components/nimbus/test/unit/test_prefFlips.js | 16++++++++--------
3 files changed, 39 insertions(+), 17 deletions(-)

diff --git a/toolkit/components/nimbus/test/NimbusTestUtils.sys.mjs b/toolkit/components/nimbus/test/NimbusTestUtils.sys.mjs @@ -251,6 +251,36 @@ export const NimbusTestUtils = { }, /** + * Assert that the only active enrollments have the expected slugs. + * + * @param {string} expectedSlugs The slugs of the enrollments that we expect to be active. + */ + async activeEnrollments(expectedSlugs) { + await NimbusTestUtils.flushStore(); + + const conn = await lazy.ProfilesDatastoreService.getConnection(); + const slugs = await conn + .execute( + ` + SELECT + slug + FROM NimbusEnrollments + WHERE + active = true AND + profileId = :profileId; + `, + { profileId: ExperimentAPI.profileId } + ) + .then(rows => rows.map(row => row.getResultByName("slug"))); + + NimbusTestUtils.Assert.deepEqual( + slugs.sort(), + expectedSlugs.sort(), + "Should only see expected active enrollments" + ); + }, + + /** * Assert that an enrollment exists in the NimbusEnrollments table. * * @param {string} slug The slug to check for. @@ -1365,13 +1395,6 @@ export const NimbusTestUtils = { ); }, - /** - * Wait for the given slugs to be the only active enrollments in the - * NimbusEnrollments table. - * - * @param {string[]} expectedSlugs The slugs of the only active enrollments we - * expect. - */ async waitForActiveEnrollments(expectedSlugs) { const profileId = ExperimentAPI.profileId; diff --git a/toolkit/components/nimbus/test/unit/test_ExperimentManager_prefs.js b/toolkit/components/nimbus/test/unit/test_ExperimentManager_prefs.js @@ -1750,8 +1750,7 @@ add_task(async function test_prefChange() { PrefUtils.setPref(pref, OVERWRITE_VALUE, { branch: setBranch }); - await NimbusTestUtils.flushStore(); - await NimbusTestUtils.waitForActiveEnrollments( + await NimbusTestUtils.assert.activeEnrollments( expectedEnrollments.map(kind => slugs[kind]) ); diff --git a/toolkit/components/nimbus/test/unit/test_prefFlips.js b/toolkit/components/nimbus/test/unit/test_prefFlips.js @@ -1735,7 +1735,7 @@ add_task(async function test_prefFlips_unenrollment() { Assert.ok(enrollment.active, `It should still be active`); } - await NimbusTestUtils.waitForActiveEnrollments(expectedEnrollments); + await NimbusTestUtils.assert.activeEnrollments(expectedEnrollments); info("Checking expected unenrollments..."); for (const slug of expectedUnenrollments) { @@ -1770,7 +1770,7 @@ add_task(async function test_prefFlips_unenrollment() { let expectedCurrentEnrollments = new Set(expectedEnrollments).difference( new Set(expectedUnenrollments) ); - await NimbusTestUtils.waitForActiveEnrollments( + await NimbusTestUtils.assert.activeEnrollments( Array.from(expectedCurrentEnrollments) ); @@ -1784,7 +1784,7 @@ add_task(async function test_prefFlips_unenrollment() { expectedCurrentEnrollments = expectedCurrentEnrollments.difference( new Set(unenrollmentOrder) ); - await NimbusTestUtils.waitForActiveEnrollments( + await NimbusTestUtils.assert.activeEnrollments( Array.from(expectedCurrentEnrollments) ); @@ -1801,7 +1801,7 @@ add_task(async function test_prefFlips_unenrollment() { } } - await NimbusTestUtils.waitForActiveEnrollments([]); + await NimbusTestUtils.assert.activeEnrollments([]); info("Cleaning up prefs..."); Services.prefs.deleteBranch(PREF_FOO); @@ -2664,7 +2664,7 @@ add_task(async function test_prefFlips_failed_experiment_and_rollout_1() { Assert.ok(enrollment.active, `The enrollment for ${slug} is active`); } - await NimbusTestUtils.waitForActiveEnrollments(expectedEnrollments); + await NimbusTestUtils.assert.activeEnrollments(expectedEnrollments); info("Checking expected unenrollments..."); for (const slug of expectedUnenrollments) { @@ -2774,7 +2774,7 @@ add_task(async function test_prefFlips_failed_experiment_and_rollout_2() { ); } - await NimbusTestUtils.waitForActiveEnrollments(expectedEnrollments); + await NimbusTestUtils.assert.activeEnrollments(expectedEnrollments); info("Checking expected enrollments..."); for (const slug of expectedEnrollments) { @@ -2843,7 +2843,7 @@ add_task(async function test_prefFlips_update_failure() { { manager, slug: "experiment" } ); - await NimbusTestUtils.waitForActiveEnrollments(["rollout"]); + await NimbusTestUtils.assert.activeEnrollments(["rollout"]); const rolloutEnrollment = manager.store.get("rollout"); const experimentEnrollment = manager.store.get("experiment"); @@ -3109,7 +3109,7 @@ async function test_prefFlips_restore_failure_conflict() { migrationState: NimbusTestUtils.migrationState.LATEST, }); - await NimbusTestUtils.waitForActiveEnrollments(["rollout-1"]); + await NimbusTestUtils.assert.activeEnrollments(["rollout-1"]); await NimbusTestUtils.assert.enrollmentExists("rollout-2", { active: false }); Assert.ok(manager.store.get("rollout-1").active, "rollout-1 is active");