Bug 1676241 - Fix usage of ExperimentAPI in TelemetryFeed r=nanj

Differential Revision: https://phabricator.services.mozilla.com/D96460
This commit is contained in:
Andrei Oprea 2020-11-09 20:15:25 +00:00
Родитель 297ab08c2d
Коммит f6d99002c8
3 изменённых файлов: 15 добавлений и 1 удалений

Просмотреть файл

@ -323,7 +323,7 @@ this.TelemetryFeed = class TelemetryFeed {
get isInCFRCohort() {
try {
const experimentData = ExperimentAPI.getExperiment({
group: "cfr",
featureId: "cfr",
});
if (experimentData && experimentData.slug) {
return true;

Просмотреть файл

@ -13,6 +13,9 @@ const { ExperimentAPI } = ChromeUtils.import(
const { ExperimentFakes } = ChromeUtils.import(
"resource://testing-common/MSTestUtils.jsm"
);
const { TelemetryFeed } = ChromeUtils.import(
"resource://activity-stream/lib/TelemetryFeed.jsm"
);
const EXPERIMENT_PAYLOAD = ExperimentFakes.recipe("test_xman_cfr", {
id: "xman_test_message",
@ -158,6 +161,12 @@ add_task(async function test_loading_experimentsAPI() {
"ExperimentAPI should return an experiment"
);
const telemetryFeedInstance = new TelemetryFeed();
Assert.ok(
telemetryFeedInstance.isInCFRCohort,
"Telemetry should return true"
);
// Reload the provider
await ASRouter._updateMessageProviders();
// Wait to load the messages from the messaging-experiments provider

Просмотреть файл

@ -1896,6 +1896,11 @@ describe("TelemetryFeed", () => {
});
assert.ok(instance.isInCFRCohort);
assert.propertyVal(
ExperimentAPI.getExperiment.firstCall.args[0],
"featureId",
"cfr"
);
});
});
});