Merge branch '16602-wb2-acr-version' refs #16602
authorPeter Amstutz <peter.amstutz@curii.com>
Fri, 28 Aug 2020 20:25:44 +0000 (16:25 -0400)
committerPeter Amstutz <peter.amstutz@curii.com>
Fri, 28 Aug 2020 20:25:44 +0000 (16:25 -0400)
Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz@curii.com>

src/common/config.ts
src/views-components/side-panel-button/side-panel-button.test.tsx [new file with mode: 0644]
src/views-components/side-panel-button/side-panel-button.tsx
src/views/login-panel/login-panel.tsx

index cf539f3dd51856783b56dd6a90192c1dd69fe319..dd812c65bb488cce168fa6a178b4529a0cc58206 100644 (file)
@@ -76,6 +76,9 @@ export interface ClusterConfigJSON {
         SSO: {
             Enable: boolean;
         }
+        Test: {
+            Enable: boolean;
+        }
     };
     Collections: {
         ForwardSlashNameSubstitution: string;
@@ -231,6 +234,9 @@ export const mockClusterConfigJSON = (config: Partial<ClusterConfigJSON>): Clust
         SSO: {
             Enable: false,
         },
+        Test: {
+            Enable: false,
+        },
     },
     Collections: {
         ForwardSlashNameSubstitution: "",
diff --git a/src/views-components/side-panel-button/side-panel-button.test.tsx b/src/views-components/side-panel-button/side-panel-button.test.tsx
new file mode 100644 (file)
index 0000000..9704be7
--- /dev/null
@@ -0,0 +1,75 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { isProjectTrashed } from './side-panel-button';
+
+describe('<SidePanelButton />', () => {
+    describe('isProjectTrashed', () => {
+        it('should return false if project is undefined', () => {
+            // given
+            const proj = undefined;
+            const resources = {};
+
+            // when
+            const result = isProjectTrashed(proj, resources);
+
+            // then
+            expect(result).toBeFalsy();
+        });
+
+        it('should return false if parent project is undefined', () => {
+            // given
+            const proj = {};
+            const resources = {};
+
+            // when
+            const result = isProjectTrashed(proj, resources);
+
+            // then
+            expect(result).toBeFalsy();
+        });
+
+        it('should return false for owner', () => {
+            // given
+            const proj = {
+                ownerUuid: 'ce8i5-tpzed-000000000000000',
+            };
+            const resources = {};
+
+            // when
+            const result = isProjectTrashed(proj, resources);
+
+            // then
+            expect(result).toBeFalsy();
+        });
+
+        it('should return true for trashed', () => {
+            // given
+            const proj = {
+                isTrashed: true,
+            };
+            const resources = {};
+
+            // when
+            const result = isProjectTrashed(proj, resources);
+
+            // then
+            expect(result).toBeTruthy();
+        });
+
+        it('should return false for undefined parent projects', () => {
+            // given
+            const proj = {
+                ownerUuid: 'ce8i5-j7d0g-000000000000000',
+            };
+            const resources = {};
+
+            // when
+            const result = isProjectTrashed(proj, resources);
+
+            // then
+            expect(result).toBeFalsy();
+        });
+    });
+});
\ No newline at end of file
index 07784c5ec3ffa20e4c41564d1dd9eb84fd1f772d..3ca2f0d66e95d4cc552c54a70ca27f4644063d96 100644 (file)
@@ -54,11 +54,12 @@ const transformOrigin: PopoverOrigin = {
     horizontal: 0
 };
 
-const isProjectTrashed = (proj: GroupResource, resources: ResourcesState): boolean => {
+export const isProjectTrashed = (proj: GroupResource | undefined, resources: ResourcesState): boolean => {
+    if (proj === undefined) { return false; }
     if (proj.isTrashed) { return true; }
     if (extractUuidKind(proj.ownerUuid) === ResourceKind.USER) { return false; }
     const parentProj = getResource<GroupResource>(proj.ownerUuid)(resources);
-    return isProjectTrashed(parentProj!, resources);
+    return isProjectTrashed(parentProj, resources);
 };
 
 export const SidePanelButton = withStyles(styles)(
index c857c0b287efbf382c4a0c0c55278a0ec4aeb6cf..4538802b51403ed231702182c38f649c1b2cf1e4 100644 (file)
@@ -70,7 +70,7 @@ type LoginPanelProps = DispatchProp<any> & WithStyles<CssRules> & {
     passwordLogin: boolean,
 };
 
-const loginOptions = ['LDAP', 'PAM'];
+const loginOptions = ['LDAP', 'PAM', 'Test'];
 
 export const requirePasswordLogin = (config: Config): boolean => {
     if (config && config.clusterConfig && config.clusterConfig.Login) {