diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /toolkit/components/nimbus/test/unit/test_ExperimentManager_context.js | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/nimbus/test/unit/test_ExperimentManager_context.js')
-rw-r--r-- | toolkit/components/nimbus/test/unit/test_ExperimentManager_context.js | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/toolkit/components/nimbus/test/unit/test_ExperimentManager_context.js b/toolkit/components/nimbus/test/unit/test_ExperimentManager_context.js new file mode 100644 index 0000000000..b7ac49e905 --- /dev/null +++ b/toolkit/components/nimbus/test/unit/test_ExperimentManager_context.js @@ -0,0 +1,41 @@ +"use strict"; + +const { ExperimentFakes } = ChromeUtils.import( + "resource://testing-common/NimbusTestUtils.jsm" +); + +const { FirstStartup } = ChromeUtils.importESModule( + "resource://gre/modules/FirstStartup.sys.mjs" +); + +add_task(async function test_createTargetingContext() { + const manager = ExperimentFakes.manager(); + const sandbox = sinon.createSandbox(); + const recipe = ExperimentFakes.recipe("foo"); + const rollout = ExperimentFakes.rollout("bar"); + sandbox.stub(manager.store, "ready").resolves(); + sandbox.stub(manager.store, "getAllActive").returns([recipe]); + sandbox.stub(manager.store, "getAllRollouts").returns([rollout]); + + let context = manager.createTargetingContext(); + const activeSlugs = await context.activeExperiments; + const activeRollouts = await context.activeRollouts; + + Assert.ok(!context.isFirstStartup, "should not set the first startup flag"); + Assert.deepEqual( + activeSlugs, + ["foo"], + "should return slugs for all the active experiment" + ); + Assert.deepEqual( + activeRollouts, + ["bar"], + "should return slugs for all rollouts stored" + ); + + // Pretend to be in the first startup + FirstStartup._state = FirstStartup.IN_PROGRESS; + context = manager.createTargetingContext(); + + Assert.ok(context.isFirstStartup, "should set the first startup flag"); +}); |