diff --git a/toolkit/components/normandy/content/about-studies/about-studies.js b/toolkit/components/normandy/content/about-studies/about-studies.js index e02babe8aa18..412c80e58746 100644 --- a/toolkit/components/normandy/content/about-studies/about-studies.js +++ b/toolkit/components/normandy/content/about-studies/about-studies.js @@ -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; }) ) ); diff --git a/toolkit/components/normandy/test/browser/browser_about_studies.js b/toolkit/components/normandy/test/browser/browser_about_studies.js index 4185ef3b0be4..a31aff5f3bc6 100644 --- a/toolkit/components/normandy/test/browser/browser_about_studies.js +++ b/toolkit/components/normandy/test/browser/browser_about_studies.js @@ -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();