15530: Fix tests
[arvados-workbench2.git] / src / store / auth / auth-action.test.ts
index f28ae1790c9739f11eed385203fb04f4006c1cb3..801d9e33ee9cb9d3e8a266298712fc7bdfe1b956 100644 (file)
@@ -21,8 +21,9 @@ 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;
@@ -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");
@@ -64,11 +67,20 @@ describe('auth-actions', () => {
             sshKeys: [],
             homeCluster: "zzzzz",
             localCluster: "zzzzz",
+            loginCluster: undefined,
+            remoteHostsConfig: {
+                "zzzzz": {
+                    "remoteHosts": {
+                        "xc59z": "xc59z.arvadosapi.com",
+                    },
+                    "rootUrl": "https://zzzzz.arvadosapi.com",
+                    "uuidPrefix": "zzzzz",
+                },
+            },
             remoteHosts: {
                 zzzzz: "zzzzz.arvadosapi.com",
                 xc59z: "xc59z.arvadosapi.com"
             },
-           remoteHostsConfig: {},
             sessions: [{
                 "active": true,
                 "baseUrl": undefined,
@@ -86,7 +98,7 @@ describe('auth-actions', () => {
                 "email": "",
                 "loggedIn": false,
                 "remoteHost": "xc59z.arvadosapi.com",
-                "status": 0,
+                "status": 1,
                 "token": "",
                 "username": ""
             }],