1
0
Fork 0
firefox/toolkit/components/nimbus/test/browser/browser_remotesettingsexperimentloader_init.js
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00

47 lines
1.3 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
const { NimbusTelemetry } = ChromeUtils.importESModule(
"resource://nimbus/lib/Telemetry.sys.mjs"
);
add_task(async function test_double_feature_enrollment() {
const sandbox = sinon.createSandbox();
sandbox.stub(NimbusTelemetry, "recordEnrollmentFailure");
await ExperimentAPI.ready();
Assert.ok(
ExperimentAPI.manager.store.getAllActiveExperiments().length === 0,
"Clean state"
);
let recipe1 = NimbusTestUtils.factories.recipe("foo" + Math.random());
let recipe2 = NimbusTestUtils.factories.recipe("bar" + Math.random());
await ExperimentAPI.manager.enroll(recipe1, "test_double_feature_enrollment");
await ExperimentAPI.manager.enroll(recipe2, "test_double_feature_enrollment");
Assert.equal(
ExperimentAPI.manager.store.getAllActiveExperiments().length,
1,
"1 active experiment"
);
Assert.equal(
NimbusTelemetry.recordEnrollmentFailure.callCount,
1,
"Expected to fail one of the recipes"
);
Assert.ok(
NimbusTelemetry.recordEnrollmentFailure.calledOnceWith(
recipe2.slug,
"feature-conflict"
)
);
await NimbusTestUtils.cleanupManager([recipe1.slug]);
sandbox.restore();
});