diff --git a/resources/static/common/js/modules/interaction_data.js b/resources/static/common/js/modules/interaction_data.js index 2f399e001cdd27db9c336d6ef30f45059dc13e5c..51cff25a680a0180914dc4a46bf8ee9fb7e21180 100644 --- a/resources/static/common/js/modules/interaction_data.js +++ b/resources/static/common/js/modules/interaction_data.js @@ -78,7 +78,11 @@ BrowserID.Modules.InteractionData = (function() { user_staged: "user.user_staged", user_confirmed: "user.user_confirmed", email_staged: "user.email_staged", - email_confirmed: "user.email_confrimed", + email_confirmed: "user.email_confirmed", + reset_password_staged: "user.reset_password_staged", + reset_password_confirmed: "user.reset_password_confirmed", + reverify_email_staged: "user.reverify_email_staged", + reverify_email_confirmed: "user.reverify_email_confirmed", notme: "user.logout", enter_password: "authenticate.enter_password", password_submit: "authenticate.password_submitted", diff --git a/resources/static/dialog/js/misc/state.js b/resources/static/dialog/js/misc/state.js index afd16ccd7463f0ab45f900254028c2016f0628d2..34d1eb25d2cf59c431a3a0203321f66b9b72054d 100644 --- a/resources/static/dialog/js/misc/state.js +++ b/resources/static/dialog/js/misc/state.js @@ -226,8 +226,6 @@ BrowserID.State = (function() { handleState("user_confirmed", handleEmailConfirmed); - handleState("staged_address_confirmed", handleEmailConfirmed); - handleState("primary_user", function(msg, info) { self.addPrimaryUser = !!info.add; var email = self.email = info.email, @@ -370,6 +368,8 @@ BrowserID.State = (function() { handleState("reverify_email_staged", handleEmailStaged.curry("doConfirmReverifyEmail")); + handleState("reverify_email_confirmed", handleEmailConfirmed); + handleState("email_valid_and_ready", function(msg, info) { // this state is only called after all checking is done on the email // address. For secondaries, this means the email has been validated and @@ -435,6 +435,8 @@ BrowserID.State = (function() { } }); + handleState("reset_password_confirmed", handleEmailConfirmed); + handleState("notme", function() { startAction("doNotMe"); }); diff --git a/resources/static/dialog/js/modules/actions.js b/resources/static/dialog/js/modules/actions.js index 02c6b5748c5eb989656bf8de8e61429172742e91..0184bfe38c7948bea1f5acae9e76367cf32213bb 100644 --- a/resources/static/dialog/js/modules/actions.js +++ b/resources/static/dialog/js/modules/actions.js @@ -17,18 +17,19 @@ BrowserID.Modules.Actions = (function() { onsuccess, onerror; - function startService(name, options) { + function startService(name, options, reported_service_name) { + mediator.publish("service", { name: reported_service_name || name }); + // Only one service outside of the main dialog allowed. if(runningService) { serviceManager.stop(runningService); } + var module = serviceManager.start(name, options); if(module) { runningService = name; } - mediator.publish("service", { name: name }); - return module; } @@ -98,7 +99,7 @@ BrowserID.Modules.Actions = (function() { }, doResetPassword: function(info) { - startService("set_password", _.extend(info, { password_reset: true })); + startService("set_password", _.extend(info, { password_reset: true }), "reset_password"); }, doStageResetPassword: function(info) { @@ -106,7 +107,7 @@ BrowserID.Modules.Actions = (function() { }, doConfirmResetPassword: function(info) { - startRegCheckService.call(this, info, "waitForPasswordResetComplete", "staged_address_confirmed"); + startRegCheckService.call(this, info, "waitForPasswordResetComplete", "reset_password_confirmed"); }, doStageReverifyEmail: function(info) { @@ -114,7 +115,7 @@ BrowserID.Modules.Actions = (function() { }, doConfirmReverifyEmail: function(info) { - startRegCheckService.call(this, info, "waitForEmailReverifyComplete", "staged_address_confirmed"); + startRegCheckService.call(this, info, "waitForEmailReverifyComplete", "reverify_email_confirmed"); }, doAssertionGenerated: function(info) { diff --git a/resources/static/test/cases/dialog/js/misc/state.js b/resources/static/test/cases/dialog/js/misc/state.js index f77c0e346bdfbc385e6276f33ace5912deb4232b..10f6fad08efa6f583898e2202269f451819417c1 100644 --- a/resources/static/test/cases/dialog/js/misc/state.js +++ b/resources/static/test/cases/dialog/js/misc/state.js @@ -62,7 +62,7 @@ }); } - function testVerifyStagedAddress(startMessage, verifyScreenAction) { + function testVerifyStagedAddress(startMessage, confirmationMessage, verifyScreenAction) { // start with a site name to ensure the site name is passed to the // verifyScreenAction. mediator.publish("start", { siteName: "Unit Test Site" }); @@ -88,7 +88,7 @@ // addresses are synced. Add the test email and make sure the email_chosen // message is triggered. storage.addSecondaryEmail(TEST_EMAIL, { unverified: true }); - mediator.publish("staged_address_confirmed"); + mediator.publish(confirmationMessage); } @@ -206,8 +206,8 @@ ok(actions.info.doRPInfo.privacyPolicy, "doRPInfo called with privacyPolicy set"); }); - asyncTest("user_staged - call doConfirmUser", function() { - testVerifyStagedAddress("user_staged", "doConfirmUser"); + asyncTest("user_staged to user_confirmed - call doConfirmUser", function() { + testVerifyStagedAddress("user_staged", "user_confirmed", "doConfirmUser"); }); asyncTest("user_confirmed - redirect to email_chosen", function() { @@ -228,8 +228,8 @@ } }); - asyncTest("email_staged - call doConfirmEmail", function() { - testVerifyStagedAddress("email_staged", "doConfirmEmail"); + asyncTest("email_staged to email_confirmed - call doConfirmEmail", function() { + testVerifyStagedAddress("email_staged", "email_confirmed", "doConfirmEmail"); }); asyncTest("primary_user with already provisioned primary user - redirect to primary_user_ready", function() { @@ -323,8 +323,8 @@ }); - asyncTest("reset_password_staged to staged_address_confirmed - call doConfirmResetPassword then doEmailConfirmed", function() { - testVerifyStagedAddress("reset_password_staged", "doConfirmResetPassword"); + asyncTest("reset_password_staged to reset_password_confirmed - call doConfirmResetPassword then doEmailConfirmed", function() { + testVerifyStagedAddress("reset_password_staged", "reset_password_confirmed", "doConfirmResetPassword"); }); @@ -573,8 +573,8 @@ testActionStarted("doStageReverifyEmail", { email: TEST_EMAIL }); }); - asyncTest("reverify_email_staged - call doConfirmReverifyEmail", function() { - testVerifyStagedAddress("reverify_email_staged", "doConfirmReverifyEmail"); + asyncTest("reverify_email_staged to reverify_email_confirmed - call doConfirmReverifyEmail", function() { + testVerifyStagedAddress("reverify_email_staged", "reverify_email_confirmed", "doConfirmReverifyEmail"); }); asyncTest("window_unload - set the final KPIs", function() { diff --git a/resources/static/test/cases/dialog/js/modules/actions.js b/resources/static/test/cases/dialog/js/modules/actions.js index 7c44e045bcdeaa795310336ccc2db0452eea215b..db8682217aa149659dfc14b55b68b8782902e6c0 100644 --- a/resources/static/test/cases/dialog/js/modules/actions.js +++ b/resources/static/test/cases/dialog/js/modules/actions.js @@ -9,6 +9,7 @@ var bid = BrowserID, user = bid.User, storage = bid.Storage, + mediator = bid.Mediator, controller, el, testHelpers = bid.TestHelpers, @@ -19,17 +20,25 @@ controller.start(config); } - function testActionStartsModule(actionName, actionOptions, expectedModule) { + function testActionStartsModule(actionName, actionOptions, expectedModule, expectedServiceName) { createController({ ready: function() { - var error; + var error, + reportedServiceName; + + // Check that KPI service reporting is acting as expected. + mediator.subscribe("service", function(msg, data) { + reportedServiceName = data.name; + }); + try { controller[actionName](actionOptions); } catch(e) { error = e; } - equal(error, "module not registered for " + expectedModule, "correct service started"); + equal(error, "module not registered for " + expectedModule, "correct module started"); + equal(reportedServiceName, expectedServiceName || expectedModule, "correct service name"); start(); } }); @@ -116,7 +125,7 @@ }); asyncTest("doResetPassword - call the set_password controller with reset_password true", function() { - testActionStartsModule('doResetPassword', { email: TEST_EMAIL }, "set_password"); + testActionStartsModule('doResetPassword', { email: TEST_EMAIL }, "set_password", "reset_password"); }); asyncTest("doStageResetPassword - trigger reset_password_staged", function() {