Remove out-of-date comment
[arvados.git] / services / workbench2 / src / store / auth / auth-reducer.cy.js
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { authReducer } from "./auth-reducer";
6 import { authActions } from "./auth-action";
7 import { createServices } from "services/services";
8 import { mockConfig } from 'common/config';
9
10 describe('auth-reducer', () => {
11     let reducer;
12     const actions = {
13         progressFn: (id, working) => { },
14         errorFn: (id, message) => { }
15     };
16
17     before(() => {
18         localStorage.clear();
19         reducer = authReducer(createServices(mockConfig({}), actions));
20     });
21
22     it('should correctly initialise state', () => {
23         const initialState = undefined;
24         const user = {
25             email: "test@test.com",
26             firstName: "John",
27             lastName: "Doe",
28             uuid: "zzzzz-tpzed-xurymjxw79nv3jz",
29             ownerUuid: "ownerUuid",
30             username: "username",
31             prefs: {},
32             isAdmin: false,
33             isActive: true,
34             canWrite: false,
35             canManage: false,
36         };
37         const state = reducer(initialState, authActions.INIT_USER({ user, token: "token" }));
38         expect(state).to.deep.equal({
39             apiToken: "token",
40             apiTokenExpiration: undefined,
41             apiTokenLocation: undefined,
42             config: mockConfig({}),
43             user,
44             sshKeys: [],
45             sessions: [],
46             extraApiToken: undefined,
47             extraApiTokenExpiration: undefined,
48             homeCluster: "zzzzz",
49             localCluster: "",
50             loginCluster: "",
51             remoteHosts: {},
52             remoteHostsConfig: {}
53         });
54     });
55
56     it('should set user details on success fetch', () => {
57         const initialState = undefined;
58
59         const user = {
60             email: "test@test.com",
61             firstName: "John",
62             lastName: "Doe",
63             uuid: "uuid",
64             ownerUuid: "ownerUuid",
65             username: "username",
66             prefs: {},
67             isAdmin: false,
68             isActive: true,
69             canWrite: false,
70             canManage: false,
71         };
72
73         const state = reducer(initialState, authActions.USER_DETAILS_SUCCESS(user));
74         expect(state).to.deep.equal({
75             apiToken: undefined,
76             apiTokenExpiration: undefined,
77             apiTokenLocation: undefined,
78             config: mockConfig({}),
79             sshKeys: [],
80             sessions: [],
81             extraApiToken: undefined,
82             extraApiTokenExpiration: undefined,
83             homeCluster: "uuid",
84             localCluster: "",
85             loginCluster: "",
86             remoteHosts: {},
87             remoteHostsConfig: {},
88             user: {
89                 email: "test@test.com",
90                 firstName: "John",
91                 lastName: "Doe",
92                 uuid: "uuid",
93                 ownerUuid: "ownerUuid",
94                 username: "username",
95                 prefs: {},
96                 isAdmin: false,
97                 isActive: true,
98                 canManage: false,
99                 canWrite: false,
100             }
101         });
102     });
103 });