Bug 1704317 - about:studies page is blank: Uncaught TypeError: can't convert undefined to object r=k88hudson

Differential Revision: https://phabricator.services.mozilla.com/D112734
This commit is contained in:
Andrei Oprea 2021-04-21 10:34:07 +00:00
parent 5f5198a521
commit e83a5f8471
2 changed files with 68 additions and 11 deletions

View File

@ -219,11 +219,14 @@ class StudyList extends React.Component {
translations,
});
}
return r(PreferenceStudyListItem, {
key: study.slug,
study,
translations,
});
if (study.type === "pref") {
return r(PreferenceStudyListItem, {
key: study.slug,
study,
translations,
});
}
return null;
})
),
r("h2", {}, translations.completedStudiesList),
@ -238,18 +241,24 @@ class StudyList extends React.Component {
translations,
});
}
if (study.experimentType === "nimbus") {
if (
study.type === "nimbus" ||
study.type === "messaging_experiment"
) {
return r(MessagingSystemListItem, {
key: study.slug,
study,
translations,
});
}
return r(PreferenceStudyListItem, {
key: study.slug,
study,
translations,
});
if (study.type === "pref") {
return r(PreferenceStudyListItem, {
key: study.slug,
study,
translations,
});
}
return null;
})
)
);

View File

@ -686,6 +686,54 @@ add_task(async function test_nimbus_about_studies() {
Assert.equal(ExperimentManager.store.getAll().length, 0, "Cleanup done");
});
add_task(async function test_nimbus_backwards_compatibility() {
const recipe = ExperimentFakes.recipe("about-studies-foo");
await ExperimentManager.enroll({
experimentType: "messaging_experiment",
...recipe,
});
await BrowserTestUtils.withNewTab(
{ gBrowser, url: "about:studies" },
async browser => {
const name = await SpecialPowers.spawn(browser, [], async () => {
await ContentTaskUtils.waitForCondition(
() => content.document.querySelector(".nimbus .remove-button"),
"waiting for page/experiment to load"
);
return content.document.querySelector(".study-name").innerText;
});
// Make sure strings are properly shown
Assert.equal(
name,
recipe.userFacingName,
"Correct active experiment name"
);
}
);
ExperimentManager.unenroll(recipe.slug);
await BrowserTestUtils.withNewTab(
{ gBrowser, url: "about:studies" },
async browser => {
const name = await SpecialPowers.spawn(browser, [], async () => {
await ContentTaskUtils.waitForCondition(
() => content.document.querySelector(".nimbus.disabled"),
"waiting for experiment to become disabled"
);
return content.document.querySelector(".study-name").innerText;
});
// Make sure strings are properly shown
Assert.equal(
name,
recipe.userFacingName,
"Correct disabled experiment name"
);
}
);
// Cleanup for multiple test runs
ExperimentManager.store._deleteForTests(recipe.slug);
Assert.equal(ExperimentManager.store.getAll().length, 0, "Cleanup done");
});
add_task(async function test_getStudiesEnabled() {
RecipeRunner.initializedPromise = PromiseUtils.defer();
let promise = AboutPages.aboutStudies.getStudiesEnabled();