blob: 7aa9d2a343ec0d8479dffb667a230d6ba3214c0e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
"use strict";
const { ExperimentFakes } = ChromeUtils.import(
"resource://testing-common/MSTestUtils.jsm"
);
const { CleanupManager } = ChromeUtils.import(
"resource://normandy/lib/CleanupManager.jsm"
);
const { ExperimentManager } = ChromeUtils.import(
"resource://messaging-system/experiments/ExperimentManager.jsm"
);
const { RemoteSettingsExperimentLoader } = ChromeUtils.import(
"resource://messaging-system/lib/RemoteSettingsExperimentLoader.jsm"
);
const { FirstStartup } = ChromeUtils.import(
"resource://gre/modules/FirstStartup.jsm"
);
add_task(async function test_updateRecipes_activeExperiments() {
const manager = ExperimentFakes.manager();
const sandbox = sinon.createSandbox();
const recipe = ExperimentFakes.recipe("foo");
const loader = ExperimentFakes.rsLoader();
loader.manager = manager;
const PASS_FILTER_RECIPE = ExperimentFakes.recipe("foo", {
targeting: `"${recipe.slug}" in activeExperiments`,
});
const onRecipe = sandbox.stub(manager, "onRecipe");
sinon.stub(loader.remoteSettingsClient, "get").resolves([PASS_FILTER_RECIPE]);
sandbox.stub(manager.store, "ready").resolves();
sandbox.stub(manager.store, "getAllActive").returns([recipe]);
await loader.init();
ok(onRecipe.calledOnce, "Should match active experiments");
});
add_task(async function test_updateRecipes_isFirstRun() {
const manager = ExperimentFakes.manager();
const sandbox = sinon.createSandbox();
const recipe = ExperimentFakes.recipe("foo");
const loader = ExperimentFakes.rsLoader();
loader.manager = manager;
const PASS_FILTER_RECIPE = { ...recipe, targeting: "isFirstStartup" };
const onRecipe = sandbox.stub(manager, "onRecipe");
sinon.stub(loader.remoteSettingsClient, "get").resolves([PASS_FILTER_RECIPE]);
sandbox.stub(manager.store, "ready").resolves();
sandbox.stub(manager.store, "getAllActive").returns([recipe]);
// Pretend to be in the first startup
FirstStartup._state = FirstStartup.IN_PROGRESS;
await loader.init();
Assert.ok(onRecipe.calledOnce, "Should match first run");
});
|