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
parent da5b77f74b
commit d7e4393107
2 changed files with 32 additions and 14 deletions

View File

@ -32,18 +32,6 @@ var EXPORTED_SYMBOLS = ["ActionsManager"];
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.
*/
@ -52,15 +40,29 @@ class ActionsManager {
this.finalized = false;
this.localActions = {};
for (const [name, Constructor] of Object.entries(actionConstructors)) {
for (const [name, Constructor] of Object.entries(
ActionsManager.actionConstructors
)) {
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() {
// Prefix each action name with "action." to turn it into a capability name.
let capabilities = new Set();
for (const actionName of Object.keys(actionConstructors)) {
for (const actionName of Object.keys(ActionsManager.actionConstructors)) {
capabilities.add(`action.${actionName}`);
}
return capabilities;

View File

@ -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/NormandyApi.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
decorate_task(async function(reportActionStub, Stub) {
@ -45,3 +48,16 @@ decorate_task(async function(reportActionStub, Stub) {
"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"
);
}
});