зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1709938 - about:support should list Nimbus experiments and remote defaults r=k88hudson
Differential Revision: https://phabricator.services.mozilla.com/D114976
This commit is contained in:
Родитель
8ef771a559
Коммит
3494dc5a49
|
@ -3,6 +3,13 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { ExperimentAPI, NimbusFeatures } = ChromeUtils.import(
|
||||
"resource://nimbus/ExperimentAPI.jsm"
|
||||
);
|
||||
const { ExperimentFakes } = ChromeUtils.import(
|
||||
"resource://testing-common/NimbusTestUtils.jsm"
|
||||
);
|
||||
|
||||
add_task(async function() {
|
||||
await BrowserTestUtils.withNewTab(
|
||||
{ gBrowser, url: "about:support" },
|
||||
|
@ -61,3 +68,69 @@ add_task(async function() {
|
|||
}
|
||||
);
|
||||
});
|
||||
|
||||
add_task(async function test_nimbus_experiments() {
|
||||
await ExperimentAPI.ready();
|
||||
let doExperimentCleanup = await ExperimentFakes.enrollWithFeatureConfig({
|
||||
enabled: true,
|
||||
featureId: "aboutwelcome",
|
||||
value: null,
|
||||
});
|
||||
|
||||
await BrowserTestUtils.withNewTab(
|
||||
{ gBrowser, url: "about:support" },
|
||||
async function(browser) {
|
||||
let experimentName = await SpecialPowers.spawn(
|
||||
browser,
|
||||
[],
|
||||
async function() {
|
||||
await ContentTaskUtils.waitForCondition(
|
||||
() =>
|
||||
content.document.querySelector(
|
||||
"#remote-experiments-tbody tr:first-child td"
|
||||
).innerText
|
||||
);
|
||||
return content.document.querySelector(
|
||||
"#remote-experiments-tbody tr:first-child td"
|
||||
).innerText;
|
||||
}
|
||||
);
|
||||
ok(
|
||||
experimentName.match("Nimbus"),
|
||||
"Rendered the expected experiment slug"
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
await doExperimentCleanup();
|
||||
});
|
||||
|
||||
add_task(async function test_remote_configuration() {
|
||||
await ExperimentAPI.ready();
|
||||
await ExperimentFakes.remoteDefaultsHelper({
|
||||
feature: NimbusFeatures.aboutwelcome,
|
||||
configuration: {
|
||||
slug: "about:studies-configuration-slug",
|
||||
enabled: true,
|
||||
variables: {},
|
||||
},
|
||||
});
|
||||
|
||||
await BrowserTestUtils.withNewTab(
|
||||
{ gBrowser, url: "about:support" },
|
||||
async function(browser) {
|
||||
let featureId = await SpecialPowers.spawn(browser, [], async function() {
|
||||
await ContentTaskUtils.waitForCondition(
|
||||
() =>
|
||||
content.document.querySelector(
|
||||
"#remote-features-tbody tr:first-child td"
|
||||
).innerText
|
||||
);
|
||||
return content.document.querySelector(
|
||||
"#remote-features-tbody tr:first-child td"
|
||||
).innerText;
|
||||
});
|
||||
ok(featureId.match("aboutwelcome"), "Rendered the expected featureId");
|
||||
}
|
||||
);
|
||||
});
|
||||
|
|
|
@ -297,6 +297,19 @@ class ExperimentStore extends SharedDataMap {
|
|||
];
|
||||
}
|
||||
|
||||
getAllRemoteConfigs() {
|
||||
const remoteDefaults = this.get(REMOTE_DEFAULTS_KEY);
|
||||
if (!remoteDefaults) {
|
||||
return [];
|
||||
}
|
||||
|
||||
let featureIds = Object.keys(remoteDefaults);
|
||||
return Object.values(remoteDefaults).map((rc, idx) => ({
|
||||
...rc,
|
||||
featureId: featureIds[idx],
|
||||
}));
|
||||
}
|
||||
|
||||
_deleteForTests(featureId) {
|
||||
super._deleteForTests(featureId);
|
||||
syncDataStore.deleteDefault(featureId);
|
||||
|
|
|
@ -1365,7 +1365,13 @@ var snapshotFormatters = {
|
|||
return;
|
||||
}
|
||||
|
||||
const { prefStudies, addonStudies, prefRollouts } = data;
|
||||
const {
|
||||
prefStudies,
|
||||
addonStudies,
|
||||
prefRollouts,
|
||||
nimbusExperiments,
|
||||
remoteConfigs,
|
||||
} = data;
|
||||
$.append(
|
||||
$("remote-features-tbody"),
|
||||
prefRollouts.map(({ slug, state }) =>
|
||||
|
@ -1376,14 +1382,24 @@ var snapshotFormatters = {
|
|||
)
|
||||
);
|
||||
|
||||
$.append(
|
||||
$("remote-features-tbody"),
|
||||
remoteConfigs.map(({ featureId, slug }) =>
|
||||
$.new("tr", [
|
||||
$.new("td", [document.createTextNode(featureId)]),
|
||||
$.new("td", [document.createTextNode(`Active (${slug})`)]),
|
||||
])
|
||||
)
|
||||
);
|
||||
|
||||
$.append(
|
||||
$("remote-experiments-tbody"),
|
||||
[addonStudies, prefStudies]
|
||||
[addonStudies, prefStudies, nimbusExperiments]
|
||||
.flat()
|
||||
.map(({ userFacingName, branch }) =>
|
||||
$.new("tr", [
|
||||
$.new("td", [document.createTextNode(userFacingName)]),
|
||||
$.new("td", [document.createTextNode(branch)]),
|
||||
$.new("td", [document.createTextNode(branch?.slug || branch)]),
|
||||
])
|
||||
)
|
||||
);
|
||||
|
|
|
@ -898,13 +898,28 @@ var dataProviders = {
|
|||
const {
|
||||
PreferenceRollouts: NormandyPreferenceRollouts,
|
||||
} = ChromeUtils.import("resource://normandy/lib/PreferenceRollouts.jsm");
|
||||
const { ExperimentManager } = ChromeUtils.import(
|
||||
"resource://nimbus/lib/ExperimentManager.jsm"
|
||||
);
|
||||
|
||||
// Get Normandy data in parallel, and sort each group by slug.
|
||||
const [addonStudies, prefRollouts, prefStudies] = await Promise.all(
|
||||
const [
|
||||
addonStudies,
|
||||
prefRollouts,
|
||||
prefStudies,
|
||||
nimbusExperiments,
|
||||
remoteConfigs,
|
||||
] = await Promise.all(
|
||||
[
|
||||
NormandyAddonStudies.getAllActive(),
|
||||
NormandyPreferenceRollouts.getAllActive(),
|
||||
NormandyPreferenceStudies.getAllActive(),
|
||||
ExperimentManager.store
|
||||
.ready()
|
||||
.then(() => ExperimentManager.store.getAllActive()),
|
||||
ExperimentManager.store
|
||||
.ready()
|
||||
.then(() => ExperimentManager.store.getAllRemoteConfigs()),
|
||||
].map(promise =>
|
||||
promise
|
||||
.catch(error => {
|
||||
|
@ -919,6 +934,8 @@ var dataProviders = {
|
|||
addonStudies,
|
||||
prefRollouts,
|
||||
prefStudies,
|
||||
nimbusExperiments,
|
||||
remoteConfigs,
|
||||
});
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1162,6 +1162,32 @@ const SNAPSHOT_SCHEMA = {
|
|||
},
|
||||
required: true,
|
||||
},
|
||||
nimbusExperiments: {
|
||||
type: "array",
|
||||
items: {
|
||||
type: "object",
|
||||
properties: {
|
||||
userFacingName: { type: "string", required: true },
|
||||
branch: {
|
||||
type: "object",
|
||||
properties: {
|
||||
slug: { type: "string", required: true },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
required: true,
|
||||
},
|
||||
remoteConfigs: {
|
||||
type: "array",
|
||||
items: {
|
||||
type: "object",
|
||||
properties: {
|
||||
featureId: { type: "string", required: true },
|
||||
slug: { type: "string", required: true },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
Загрузка…
Ссылка в новой задаче