16971: Added tests to cover more places
authorDaniel Kutyła <daniel.kutyla@contractors.roche.com>
Tue, 6 Jul 2021 08:44:08 +0000 (10:44 +0200)
committerDaniel Kutyła <daniel.kutyla@contractors.roche.com>
Tue, 6 Jul 2021 08:44:08 +0000 (10:44 +0200)
Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła <daniel.kutyla@contractors.roche.com>

cypress/integration/collection.spec.js
cypress/integration/favorites.spec.js
cypress/integration/sharing.spec.js
cypress/integration/side-panel.spec.js
cypress/support/commands.js
src/views/shared-with-me-panel/shared-with-me-panel.tsx

index 797a9d49fedf4838a8dfdc2619600a644dcbbe40..f3b63218de0901d39472368429bd9c2df51e6072 100644 (file)
@@ -586,7 +586,7 @@ describe('Collection panel tests', function () {
         cy.get('[data-cy=breadcrumb-last]').should('contain', collName);
     });
 
-    it.only('shows responsible person for collection if available', () => {
+    it('shows responsible person for collection if available', () => {
         cy.createCollection(adminUser.token, {
             name: `Test collection ${Math.floor(Math.random() * 999999)}`,
             owner_uuid: activeUser.user.uuid,
index 6c2116cf87c82071d9bfcfb9af02f04daa6ca58b..d81ad811434e4c563f643de49a4a31576b203e9a 100644 (file)
@@ -151,45 +151,33 @@ describe('Favorites tests', function () {
         cy.getAll('@mySharedWritableProject', '@testTargetCollection')
             .then(function ([mySharedWritableProject, testTargetCollection]) {
                 cy.loginAs(activeUser);
+                
+                cy.get('[data-cy=side-panel-tree]').contains('My Favorites').click();
 
                 const newProjectName = `New project name ${mySharedWritableProject.name}`;
                 const newProjectDescription = `New project description ${mySharedWritableProject.name}`;
                 const newCollectionName = `New collection name ${testTargetCollection.name}`;
                 const newCollectionDescription = `New collection description ${testTargetCollection.name}`;
 
-                cy.get('[data-cy=side-panel-tree]').contains('My Favorites').click();
-
-                cy.get('main').contains(mySharedWritableProject.name).rightclick();
-                cy.get('[data-cy=context-menu]').contains('Edit project').click();
-                cy.get('[data-cy=form-dialog]').within(() => {
-                    cy.get('input[name=name]').clear().type(newProjectName);
-                    cy.get('div[contenteditable=true]').type(newProjectDescription);
-                    cy.get('[data-cy=form-submit-btn]').click();
-                });
+                cy.editProjectOrCollection('main', mySharedWritableProject.name, newProjectName, newProjectDescription);
+                cy.editProjectOrCollection('main', testTargetCollection.name, newCollectionName, newCollectionDescription, false);
 
                 cy.get('main').contains(newProjectName).rightclick();
-                cy.get('[data-cy=context-menu]').contains('Edit project').click();
-                cy.get('[data-cy=form-dialog]').within(() => {
-                    cy.get('input[name=name]').should('have.value', newProjectName);
-                    cy.get('span[data-text=true]').contains( newProjectDescription);
-                    cy.get('[data-cy=form-cancel-btn]').click();
-                });
+                cy.contains('Remove from favorites').click();
+                cy.get('main').contains(newCollectionName).rightclick();
+                cy.contains('Remove from favorites').click();
 
-                cy.get('main').contains(testTargetCollection.name).rightclick();
-                cy.get('[data-cy=context-menu]').contains('Edit collection').click();
-                cy.get('[data-cy=form-dialog]').within(() => {
-                    cy.get('input[name=name]').clear().type(newCollectionName);
-                    cy.get('input[name=description]').type(newCollectionDescription);
-                    cy.get('[data-cy=form-submit-btn]').click();
-                });
+                cy.get('[data-cy=side-panel-tree]').contains('Projects').click();
 
+                cy.get('main').contains(newProjectName).rightclick();
+                cy.contains('Add to public favorites').click();
                 cy.get('main').contains(newCollectionName).rightclick();
-                cy.get('[data-cy=context-menu]').contains('Edit collection').click();
-                cy.get('[data-cy=form-dialog]').within(() => {
-                    cy.get('input[name=name]').should('have.value', newCollectionName);
-                    cy.get('input[name=description]').should('have.value', newCollectionDescription);
-                    cy.get('[data-cy=form-cancel-btn]').click();
-                });
+                cy.contains('Add to public favorites').click();
+
+                cy.get('[data-cy=side-panel-tree]').contains('Public Favorites').click();
+
+                cy.editProjectOrCollection('main', newProjectName, mySharedWritableProject.name, 'newProjectDescription');
+                cy.editProjectOrCollection('main', newCollectionName, testTargetCollection.name, 'newCollectionDescription', false); 
             });
     });
 
index 5786c41d563b6d9b68035095958a23404db040a5..4f4c2eb3b32f6974f629cff05d975f0362fbd404 100644 (file)
@@ -78,4 +78,26 @@ describe('Sharing tests', function () {
                 cy.get('[data-cy=context-menu]').should('not.contain', 'Move to trash');
             });
     });
+
+    it('can edit project in shared with me', () => {
+        cy.createProject({
+            owningUser: adminUser,
+            targetUser: activeUser,
+            projectName: 'mySharedWritableProject',
+            canWrite: true,
+            addToFavorites: true
+        });
+
+        cy.getAll('@mySharedWritableProject')
+            .then(function ([mySharedWritableProject]) {
+                cy.loginAs(activeUser);
+                
+                cy.get('[data-cy=side-panel-tree]').contains('Shared with me').click();
+
+                const newProjectName = `New project name ${mySharedWritableProject.name}`;
+                const newProjectDescription = `New project description ${mySharedWritableProject.name}`;
+
+                cy.editProjectOrCollection('main', mySharedWritableProject.name, newProjectName, newProjectDescription);
+            });
+    });
 });
\ No newline at end of file
index 8882494bf81c69e501d3a50092b558c502d2c5ac..2e31ec66cb040fc462bf80b48f365c290b842a5d 100644 (file)
@@ -92,4 +92,26 @@ describe('Side panel tests', function() {
         })
     })
 
+    it('can edit project in side panel', () => {
+        cy.createProject({
+            owningUser: activeUser,
+            targetUser: activeUser,
+            projectName: 'mySharedWritableProject',
+            canWrite: true,
+            addToFavorites: false
+        });
+
+        cy.getAll('@mySharedWritableProject')
+            .then(function ([mySharedWritableProject]) {
+                cy.loginAs(activeUser);
+                
+                cy.get('[data-cy=side-panel-tree]').contains('Projects').click();
+
+                const newProjectName = `New project name ${mySharedWritableProject.name}`;
+                const newProjectDescription = `New project description ${mySharedWritableProject.name}`;
+
+                cy.editProjectOrCollection('[data-cy=side-panel-tree]', mySharedWritableProject.name, newProjectName, newProjectDescription);
+            });
+    });
+
 })
index dbb9cd0b1f9a82b33118d8cad630d8c87789128b..97bb2450909566ca0a964ffcc8edaa03adec28c9 100644 (file)
@@ -192,6 +192,32 @@ Cypress.Commands.add(
     }
 )
 
+Cypress.Commands.add(
+    "editProjectOrCollection", (container, oldName, newName, newDescription, isProject = true) => {
+        cy.get(container).contains(oldName).rightclick();
+        cy.get('[data-cy=context-menu]').contains(isProject ? 'Edit project' : 'Edit collection').click();
+        cy.get('[data-cy=form-dialog]').within(() => {
+            cy.get('input[name=name]').clear().type(newName);
+            cy.get(isProject ? 'div[contenteditable=true]' : 'input[name=description]').type(newDescription);
+            cy.get('[data-cy=form-submit-btn]').click();
+        });
+
+        cy.get(container).contains(newName).rightclick();
+        cy.get('[data-cy=context-menu]').contains(isProject ? 'Edit project' : 'Edit collection').click();
+        cy.get('[data-cy=form-dialog]').within(() => {
+            cy.get('input[name=name]').should('have.value', newName);
+
+            if (isProject) {
+                cy.get('span[data-text=true]').contains(newDescription);
+            } else {
+                cy.get('input[name=description]').should('have.value', newDescription);
+            }
+
+            cy.get('[data-cy=form-cancel-btn]').click();
+        });
+    }
+)
+
 Cypress.Commands.add(
     "doSearch", (searchTerm) => {
         cy.get('[data-cy=searchbar-input-field]').type(`{selectall}${searchTerm}{enter}`);
index 76a314ae306bd41ff9f56b6118e5c8ba7f45bac8..2bc72ba41e5c529d6dd0e8cd2b2890ef0c1ae98b 100644 (file)
@@ -61,8 +61,9 @@ export const SharedWithMePanel = withStyles(styles)(
                 const menuKind = this.props.dispatch<any>(resourceUuidToContextMenuKind(resourceUuid));
                 if (menuKind && resource) {
                     this.props.dispatch<any>(openContextMenu(event, {
-                        name: '',
+                        name: resource.name,
                         uuid: resource.uuid,
+                        description: resource.description,
                         ownerUuid: resource.ownerUuid,
                         isTrashed: ('isTrashed' in resource) ? resource.isTrashed: false,
                         kind: resource.kind,