From: Daniel Kutyła Date: Tue, 6 Jul 2021 08:44:08 +0000 (+0200) Subject: 16971: Added tests to cover more places X-Git-Tag: 2.2.1^2~1 X-Git-Url: https://git.arvados.org/arvados-workbench2.git/commitdiff_plain/40ad26356794ff381c4cecb35141417dad0807ea 16971: Added tests to cover more places Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła --- diff --git a/cypress/integration/collection.spec.js b/cypress/integration/collection.spec.js index 797a9d49..f3b63218 100644 --- a/cypress/integration/collection.spec.js +++ b/cypress/integration/collection.spec.js @@ -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, diff --git a/cypress/integration/favorites.spec.js b/cypress/integration/favorites.spec.js index 6c2116cf..d81ad811 100644 --- a/cypress/integration/favorites.spec.js +++ b/cypress/integration/favorites.spec.js @@ -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); }); }); diff --git a/cypress/integration/sharing.spec.js b/cypress/integration/sharing.spec.js index 5786c41d..4f4c2eb3 100644 --- a/cypress/integration/sharing.spec.js +++ b/cypress/integration/sharing.spec.js @@ -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 diff --git a/cypress/integration/side-panel.spec.js b/cypress/integration/side-panel.spec.js index 8882494b..2e31ec66 100644 --- a/cypress/integration/side-panel.spec.js +++ b/cypress/integration/side-panel.spec.js @@ -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); + }); + }); + }) diff --git a/cypress/support/commands.js b/cypress/support/commands.js index dbb9cd0b..97bb2450 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -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}`); diff --git a/src/views/shared-with-me-panel/shared-with-me-panel.tsx b/src/views/shared-with-me-panel/shared-with-me-panel.tsx index 76a314ae..2bc72ba4 100644 --- a/src/views/shared-with-me-panel/shared-with-me-panel.tsx +++ b/src/views/shared-with-me-panel/shared-with-me-panel.tsx @@ -61,8 +61,9 @@ export const SharedWithMePanel = withStyles(styles)( const menuKind = this.props.dispatch(resourceUuidToContextMenuKind(resourceUuid)); if (menuKind && resource) { this.props.dispatch(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,