From f6d52fc8be3fa84d981bcd20763f35adb7a2c795 Mon Sep 17 00:00:00 2001 From: Lucas Di Pentima Date: Mon, 17 May 2021 20:09:50 -0300 Subject: [PATCH] 17637: Adds tests. Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- cypress/integration/project.spec.js | 50 +++++++++++++++++-- .../side-panel-tree/side-panel-tree.tsx | 4 +- 2 files changed, 50 insertions(+), 4 deletions(-) diff --git a/cypress/integration/project.spec.js b/cypress/integration/project.spec.js index 86dcbc2a..af2d93e3 100644 --- a/cypress/integration/project.spec.js +++ b/cypress/integration/project.spec.js @@ -122,17 +122,61 @@ describe('Project tests', function() { // Go to subproject and trash it. cy.goToPath(`/projects/${testSubProject.uuid}`); - cy.get('[data-cy=breadcrumb-last]').should('contain', testSubProject.name); - cy.get('[data-cy=breadcrumb-last]').rightclick(); + cy.get('[data-cy=side-panel-tree]').should('contain', testSubProject.name); + cy.get('[data-cy=breadcrumb-last]') + .should('contain', testSubProject.name) + .rightclick(); cy.get('[data-cy=context-menu]').contains('Move to trash').click(); // Confirm that the parent project should be displayed. cy.get('[data-cy=breadcrumb-last]').should('contain', testRootProject.name); cy.url().should('contain', `/projects/${testRootProject.uuid}`); + cy.get('[data-cy=side-panel-tree]').should('not.contain', testSubProject.name); // Checks for bugfix #17637. cy.get('[data-cy=not-found-content]').should('not.exist'); cy.get('[data-cy=not-found-page]').should('not.exist'); }); }); -}) \ No newline at end of file + + it('navigates to the root project after trashing the parent of the one being displayed', function() { + cy.createGroup(activeUser.token, { + name: `Test root project ${Math.floor(Math.random() * 999999)}`, + group_class: 'project', + }).as('testRootProject').then(function() { + cy.createGroup(activeUser.token, { + name : `Test subproject ${Math.floor(Math.random() * 999999)}`, + group_class: 'project', + owner_uuid: this.testRootProject.uuid, + }).as('testSubProject').then(function() { + cy.createGroup(activeUser.token, { + name : `Test sub subproject ${Math.floor(Math.random() * 999999)}`, + group_class: 'project', + owner_uuid: this.testSubProject.uuid, + }).as('testSubSubProject'); + }); + }); + cy.getAll('@testRootProject', '@testSubProject', '@testSubSubProject').then(function([testRootProject, testSubProject, testSubSubProject]) { + cy.loginAs(activeUser); + + // Go to innermost project and trash its parent. + cy.goToPath(`/projects/${testSubSubProject.uuid}`); + cy.get('[data-cy=side-panel-tree]').should('contain', testSubSubProject.name); + cy.get('[data-cy=breadcrumb-last]').should('contain', testSubSubProject.name); + cy.get('[data-cy=side-panel-tree]') + .contains(testSubProject.name) + .rightclick(); + cy.get('[data-cy=context-menu]').contains('Move to trash').click(); + + // Confirm that the trashed project's parent should be displayed. + cy.get('[data-cy=breadcrumb-last]').should('contain', testRootProject.name); + cy.url().should('contain', `/projects/${testRootProject.uuid}`); + cy.get('[data-cy=side-panel-tree]').should('not.contain', testSubProject.name); + cy.get('[data-cy=side-panel-tree]').should('not.contain', testSubSubProject.name); + + // Checks for bugfix #17637. + cy.get('[data-cy=not-found-content]').should('not.exist'); + cy.get('[data-cy=not-found-page]').should('not.exist'); + }); + }); +}); \ No newline at end of file diff --git a/src/views-components/side-panel-tree/side-panel-tree.tsx b/src/views-components/side-panel-tree/side-panel-tree.tsx index 4c6f01a1..bd6762e5 100644 --- a/src/views-components/side-panel-tree/side-panel-tree.tsx +++ b/src/views-components/side-panel-tree/side-panel-tree.tsx @@ -41,7 +41,9 @@ const mapDispatchToProps = (dispatch: Dispatch, props: SidePanelTreeProps): Side export const SidePanelTree = connect(undefined, mapDispatchToProps)( (props: SidePanelTreeActionProps) => - ); + + + ); const renderSidePanelItem = (item: TreeItem) => { const name = typeof item.data === 'string' ? item.data : item.data.name; -- 2.30.2