From: Eric Biagiotti Date: Wed, 22 May 2019 18:47:54 +0000 (-0400) Subject: 15088: Fixes auth-action test and simplifies link account cancel snackbar X-Git-Tag: 1.4.0~1^2~1 X-Git-Url: https://git.arvados.org/arvados-workbench2.git/commitdiff_plain/081ace17e2bbed7176960006baa57e20f13b7bdb 15088: Fixes auth-action test and simplifies link account cancel snackbar Arvados-DCO-1.1-Signed-off-by: Eric Biagiotti --- diff --git a/src/store/auth/auth-action.test.ts b/src/store/auth/auth-action.test.ts index 4a69fc15..926121e3 100644 --- a/src/store/auth/auth-action.test.ts +++ b/src/store/auth/auth-action.test.ts @@ -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"); diff --git a/src/store/auth/auth-action.ts b/src/store/auth/auth-action.ts index be6e9f48..1d1ad18c 100644 --- a/src/store/auth/auth-action.ts +++ b/src/store/auth/auth-action.ts @@ -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(init(config)); } - }; const init = (config: Config) => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { diff --git a/src/store/link-account-panel/link-account-panel-actions.ts b/src/store/link-account-panel/link-account-panel-actions.ts index 57f0681a..cdc99660 100644 --- a/src/store/link-account-panel/link-account-panel-actions.ts +++ b/src/store/link-account-panel/link-account-panel-actions.ts @@ -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 })); } } };