15088: Fixes auth-action test and simplifies link account cancel snackbar
authorEric Biagiotti <ebiagiotti@veritasgenetics.com>
Wed, 22 May 2019 18:47:54 +0000 (14:47 -0400)
committerEric Biagiotti <ebiagiotti@veritasgenetics.com>
Wed, 22 May 2019 18:47:54 +0000 (14:47 -0400)
Arvados-DCO-1.1-Signed-off-by: Eric Biagiotti <ebiagiotti@veritasgenetics.com>

src/store/auth/auth-action.test.ts
src/store/auth/auth-action.ts
src/store/link-account-panel/link-account-panel-actions.ts

index 4a69fc15b319a8089ab95354c32c01a39855a0d2..926121e39a734d089b927d8915ad6e374c92038b 100644 (file)
@@ -23,6 +23,7 @@ import { configureStore, RootStore } from "../store";
 import createBrowserHistory from "history/createBrowserHistory";
 import { Config, mockConfig } from '~/common/config';
 import { ApiActions } from "~/services/api/api-actions";
+import { ACCOUNT_LINK_STATUS_KEY} from '~/services/link-account-service/link-account-service';
 
 describe('auth-actions', () => {
     let reducer: (state: AuthState | undefined, action: AuthAction) => any;
@@ -40,6 +41,8 @@ describe('auth-actions', () => {
 
     it('should initialise state with user and api token from local storage', () => {
 
+        // Only test the case when a link account operation is not being cancelled
+        sessionStorage.setItem(ACCOUNT_LINK_STATUS_KEY, "0");
         localStorage.setItem(API_TOKEN_KEY, "token");
         localStorage.setItem(USER_EMAIL_KEY, "test@test.com");
         localStorage.setItem(USER_FIRST_NAME_KEY, "John");
index be6e9f489e90a8ef6748095d3850d3504be6801a..1d1ad18cbd8c985218fc7aa433b04056d76d031d 100644 (file)
@@ -51,7 +51,7 @@ function removeAuthorizationHeader(client: AxiosInstance) {
 }
 
 export const initAuth = (config: Config) => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
-    // Cancel any link account ops in progess unless the user has
+    // Cancel any link account ops in progress unless the user has
     // just logged in or there has been a successful link operation
     const data = services.linkAccountService.getLinkOpStatus();
     if (!matchTokenRoute(location.pathname) && (!matchFedTokenRoute(location.pathname)) && data === undefined) {
@@ -62,7 +62,6 @@ export const initAuth = (config: Config) => (dispatch: Dispatch, getState: () =>
     else {
         dispatch<any>(init(config));
     }
-
 };
 
 const init = (config: Config) => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
index 57f0681acd0c762a74ce30ccceb9ab71a19ef08f..cdc99660b7a3be268c66ee79351fa99ed75208e3 100644 (file)
@@ -223,16 +223,15 @@ export const cancelLinking = (reload: boolean = false) =>
                 setAuthorizationHeader(services, linkAccountData.token);
                 user = await services.userService.get(linkAccountData.userUuid);
                 dispatch(switchUser(user, linkAccountData.token));
+                services.linkAccountService.saveLinkOpStatus(LinkAccountStatus.CANCELLED);
             }
         }
         finally {
             if (reload) {
-                services.linkAccountService.saveLinkOpStatus(LinkAccountStatus.CANCELLED);
                 location.reload();
             }
             else {
                 dispatch(progressIndicatorActions.STOP_WORKING(WORKBENCH_LOADING_SCREEN));
-                dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Account link cancelled!", kind: SnackbarKind.INFO, hideDuration: 3000 }));
             }
         }
     };