15530: Set homeCluster to LoginCluster
[arvados.git] / src / store / auth / auth-action.test.ts
index db3211c47440fe8290569e19488658660396a2bf..1ebc8db993be3fc3d82125f24a59ac54dce8bba4 100644 (file)
@@ -11,15 +11,19 @@ import {
     USER_LAST_NAME_KEY,
     USER_OWNER_UUID_KEY,
     USER_UUID_KEY,
-    USER_IS_ADMIN, USER_USERNAME, USER_PREFS
+    USER_IS_ADMIN,
+    USER_IS_ACTIVE,
+    USER_USERNAME,
+    USER_PREFS
 } from "~/services/auth-service/auth-service";
 
 import 'jest-localstorage-mock';
 import { createServices } from "~/services/services";
 import { configureStore, RootStore } from "../store";
 import createBrowserHistory from "history/createBrowserHistory";
-import { Config, mockConfig } from '~/common/config';
+import { 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;
@@ -37,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");
@@ -45,7 +51,8 @@ describe('auth-actions', () => {
         localStorage.setItem(USER_USERNAME, "username");
         localStorage.setItem(USER_PREFS, JSON.stringify({}));
         localStorage.setItem(USER_OWNER_UUID_KEY, "ownerUuid");
-        localStorage.setItem(USER_IS_ADMIN, JSON.stringify("false"));
+        localStorage.setItem(USER_IS_ADMIN, JSON.stringify(false));
+        localStorage.setItem(USER_IS_ACTIVE, JSON.stringify(true));
 
         const config: any = {
             rootUrl: "https://zzzzz.arvadosapi.com",
@@ -60,6 +67,7 @@ describe('auth-actions', () => {
             sshKeys: [],
             homeCluster: "zzzzz",
             localCluster: "zzzzz",
+            remoteHostsConfig: {},
             remoteHosts: {
                 zzzzz: "zzzzz.arvadosapi.com",
                 xc59z: "xc59z.arvadosapi.com"
@@ -93,7 +101,8 @@ describe('auth-actions', () => {
                 ownerUuid: "ownerUuid",
                 username: "username",
                 prefs: {},
-                isAdmin: false
+                isAdmin: false,
+                isActive: true
             }
         });
     });