Bug 1635542 - Fix name of messaging experiment in ActionsManager r=k88hudson

Differential Revision: https://phabricator.services.mozilla.com/D73934
This commit is contained in:
Michael Cooper 2020-05-05 20:20:18 +00:00
Родитель da5b77f74b
Коммит d7e4393107
2 изменённых файлов: 32 добавлений и 14 удалений

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

@ -32,18 +32,6 @@ var EXPORTED_SYMBOLS = ["ActionsManager"];
const log = LogManager.getLogger("recipe-runner"); const log = LogManager.getLogger("recipe-runner");
const actionConstructors = {
"addon-rollback": AddonRollbackAction,
"addon-rollout": AddonRolloutAction,
"branched-addon-study": BranchedAddonStudyAction,
"console-log": ConsoleLogAction,
"messsaging-experiment": MessagingExperimentAction,
"multi-preference-experiment": PreferenceExperimentAction,
"preference-rollback": PreferenceRollbackAction,
"preference-rollout": PreferenceRolloutAction,
"show-heartbeat": ShowHeartbeatAction,
};
/** /**
* A class to manage the actions that recipes can use in Normandy. * A class to manage the actions that recipes can use in Normandy.
*/ */
@ -52,15 +40,29 @@ class ActionsManager {
this.finalized = false; this.finalized = false;
this.localActions = {}; this.localActions = {};
for (const [name, Constructor] of Object.entries(actionConstructors)) { for (const [name, Constructor] of Object.entries(
ActionsManager.actionConstructors
)) {
this.localActions[name] = new Constructor(); this.localActions[name] = new Constructor();
} }
} }
static actionConstructors = {
"addon-rollback": AddonRollbackAction,
"addon-rollout": AddonRolloutAction,
"branched-addon-study": BranchedAddonStudyAction,
"console-log": ConsoleLogAction,
"messaging-experiment": MessagingExperimentAction,
"multi-preference-experiment": PreferenceExperimentAction,
"preference-rollback": PreferenceRollbackAction,
"preference-rollout": PreferenceRolloutAction,
"show-heartbeat": ShowHeartbeatAction,
};
static getCapabilities() { static getCapabilities() {
// Prefix each action name with "action." to turn it into a capability name. // Prefix each action name with "action." to turn it into a capability name.
let capabilities = new Set(); let capabilities = new Set();
for (const actionName of Object.keys(actionConstructors)) { for (const actionName of Object.keys(ActionsManager.actionConstructors)) {
capabilities.add(`action.${actionName}`); capabilities.add(`action.${actionName}`);
} }
return capabilities; return capabilities;

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

@ -4,6 +4,9 @@ ChromeUtils.import("resource://normandy/actions/BaseAction.jsm", this);
ChromeUtils.import("resource://normandy/lib/ActionsManager.jsm", this); ChromeUtils.import("resource://normandy/lib/ActionsManager.jsm", this);
ChromeUtils.import("resource://normandy/lib/NormandyApi.jsm", this); ChromeUtils.import("resource://normandy/lib/NormandyApi.jsm", this);
ChromeUtils.import("resource://normandy/lib/Uptake.jsm", this); ChromeUtils.import("resource://normandy/lib/Uptake.jsm", this);
const { ActionSchemas } = ChromeUtils.import(
"resource://normandy/actions/schemas/index.js"
);
// Test life cycle methods for actions // Test life cycle methods for actions
decorate_task(async function(reportActionStub, Stub) { decorate_task(async function(reportActionStub, Stub) {
@ -45,3 +48,16 @@ decorate_task(async function(reportActionStub, Stub) {
"finalize should be called on the unused action" "finalize should be called on the unused action"
); );
}); });
decorate_task(async function() {
for (const [name, Constructor] of Object.entries(
ActionsManager.actionConstructors
)) {
const action = new Constructor();
Assert.deepEqual(
ActionSchemas[name],
action.schema,
"action name should map to a schema"
);
}
});