17637: Adds tests. 17637-not-found-after-trash
authorLucas Di Pentima <lucas.dipentima@curii.com>
Mon, 17 May 2021 23:09:50 +0000 (20:09 -0300)
committerLucas Di Pentima <lucas.dipentima@curii.com>
Mon, 17 May 2021 23:09:50 +0000 (20:09 -0300)
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas.dipentima@curii.com>

cypress/integration/project.spec.js
src/views-components/side-panel-tree/side-panel-tree.tsx

index 86dcbc2a95fe959df7fef7198d4a2e8b52a5f89b..af2d93e3c605ec79f1538c9224ce09800489bbfd 100644 (file)
@@ -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
index 4c6f01a146c910885de60244924529aaed575f59..bd6762e510c9162f2345dd3304458a11c6beeeb2 100644 (file)
@@ -41,7 +41,9 @@ const mapDispatchToProps = (dispatch: Dispatch, props: SidePanelTreeProps): Side
 
 export const SidePanelTree = connect(undefined, mapDispatchToProps)(
     (props: SidePanelTreeActionProps) =>
-        <TreePicker {...props} render={renderSidePanelItem} pickerId={SIDE_PANEL_TREE} />);
+        <span data-cy="side-panel-tree">
+        <TreePicker {...props} render={renderSidePanelItem} pickerId={SIDE_PANEL_TREE} />
+        </span>);
 
 const renderSidePanelItem = (item: TreeItem<ProjectResource>) => {
     const name = typeof item.data === 'string' ? item.data : item.data.name;