From b71d59f7e1876c9eb20c2aa7c749c0acc8568b6f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20Kuty=C5=82a?= Date: Wed, 26 Aug 2020 23:08:37 +0200 Subject: [PATCH] 16743: fix for non existing parent project MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła --- .../side-panel-button.test.tsx | 63 +++++++++++++++++++ .../side-panel-button/side-panel-button.tsx | 4 +- 2 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 src/views-components/side-panel-button/side-panel-button.test.tsx 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 index 00000000..056b2e64 --- /dev/null +++ b/src/views-components/side-panel-button/side-panel-button.test.tsx @@ -0,0 +1,63 @@ +// Copyright (C) The Arvados Authors. All rights reserved. +// +// SPDX-License-Identifier: AGPL-3.0 + +import { isProjectTrashed } from './side-panel-button'; + +describe('', () => { + describe('isProjectTrashed', () => { + 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.only('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 diff --git a/src/views-components/side-panel-button/side-panel-button.tsx b/src/views-components/side-panel-button/side-panel-button.tsx index 07784c5e..58cceafb 100644 --- a/src/views-components/side-panel-button/side-panel-button.tsx +++ b/src/views-components/side-panel-button/side-panel-button.tsx @@ -54,10 +54,12 @@ const transformOrigin: PopoverOrigin = { horizontal: 0 }; -const isProjectTrashed = (proj: GroupResource, resources: ResourcesState): boolean => { +export const isProjectTrashed = (proj: GroupResource, resources: ResourcesState): boolean => { + if (proj === undefined) { return false; } if (proj.isTrashed) { return true; } if (extractUuidKind(proj.ownerUuid) === ResourceKind.USER) { return false; } const parentProj = getResource(proj.ownerUuid)(resources); + console.log(1); return isProjectTrashed(parentProj!, resources); }; -- 2.30.2