From: Stephen Smith Date: Tue, 23 Nov 2021 03:54:33 +0000 (-0500) Subject: 18123: Add basic group edit cypress tests. X-Git-Tag: 2.4.0~22^2~17 X-Git-Url: https://git.arvados.org/arvados-workbench2.git/commitdiff_plain/103a2d417eb9dfae62cb72385de5e8d836bb15e9 18123: Add basic group edit cypress tests. Arvados-DCO-1.1-Signed-off-by: Stephen Smith --- diff --git a/cypress/integration/group-manage.spec.js b/cypress/integration/group-manage.spec.js new file mode 100644 index 00000000..8f630033 --- /dev/null +++ b/cypress/integration/group-manage.spec.js @@ -0,0 +1,127 @@ +// Copyright (C) The Arvados Authors. All rights reserved. +// +// SPDX-License-Identifier: AGPL-3.0 + +describe('Group manage tests', function() { + let activeUser; + let adminUser; + let otherUser; + + before(function() { + // Only set up common users once. These aren't set up as aliases because + // aliases are cleaned up after every test. Also it doesn't make sense + // to set the same users on beforeEach() over and over again, so we + // separate a little from Cypress' 'Best Practices' here. + cy.getUser('admin', 'Admin', 'User', true, true) + .as('adminUser').then(function() { + adminUser = this.adminUser; + } + ); + cy.getUser('user', 'Active', 'User', false, true) + .as('activeUser').then(function() { + activeUser = this.activeUser; + } + ); + cy.getUser('otheruser', 'Other', 'User', false, true) + .as('otherUser').then(function() { + otherUser = this.otherUser; + } + ); + }); + + beforeEach(function() { + cy.clearCookies(); + cy.clearLocalStorage(); + }); + + it('creates a new group', function() { + const groupName = `Test group (${Math.floor(999999 * Math.random())})`; + cy.loginAs(activeUser); + + // Navigate to Groups + cy.get('[data-cy=side-panel-tree]').contains('Groups').click(); + + // Create new group + cy.get('[data-cy=groups-panel-new-group]').click(); + cy.get('[data-cy=form-dialog]') + .should('contain', 'Create a group') + .within(() => { + cy.get('input[name=name]').type(groupName); + cy.get('button[type=submit]').click(); + }); + + // Check that the group was created + cy.get('[data-cy=groups-panel-data-explorer]').contains(groupName).click(); + cy.get('[data-cy=group-members-data-explorer]').contains('Active User'); + }); + + it('adds users to the group', function() { + // Add other user to the group + cy.get('[data-cy=group-member-add]').click(); + cy.get('[data-cy=form-dialog]') + .should('contain', 'Add users') + .within(() => { + cy.get('input').type("other"); + }); + cy.contains('Other User').click(); + cy.get('[data-cy=form-dialog] button[type=submit]').click(); + + // Check that both users are present with appropriate permissions + cy.get('[data-cy=group-members-data-explorer]') + .contains('Other User') + .parents('tr') + .within(() => { + cy.contains('Read'); + }); + cy.get('[data-cy=group-members-data-explorer] tr') + .contains('Active User') + .parents('tr') + .within(() => { + cy.contains('Manage'); + }); + }); + + it('changes permission level of a member', function() { + // Test change permission level + cy.get('[data-cy=group-members-data-explorer]') + .contains('Other User') + .parents('tr') + .within(() => { + cy.contains('Read') + .parents('td') + .within(() => { + cy.get('button').click(); + }); + }); + cy.get('[data-cy=form-dialog]') + .should('contain', 'Edit permission') + .within(() => { + cy.contains('Read').click(); + }); + cy.get('li span') + .contains('Write') + .parents('li') + .click(); + cy.get('[data-cy=form-dialog] button[type=submit]').click(); + cy.get('[data-cy=group-members-data-explorer]') + .contains('Other User') + .parents('tr') + .within(() => { + cy.contains('Write'); + }); + }); + + it('removes users from the group', function() { + // Remove other user + cy.get('[data-cy=group-members-data-explorer]') + .contains('Other User') + .parents('tr') + .within(() => { + cy.get('[data-cy=resource-delete-button]').click(); + }); + cy.get('[data-cy=confirmation-dialog-ok-btn]').click(); + cy.get('[data-cy=group-members-data-explorer]') + .should('not.contain', 'Other User'); + + }); +}); diff --git a/src/components/data-explorer/data-explorer.tsx b/src/components/data-explorer/data-explorer.tsx index f3cccfce..928d3ed4 100644 --- a/src/components/data-explorer/data-explorer.tsx +++ b/src/components/data-explorer/data-explorer.tsx @@ -96,7 +96,8 @@ export const DataExplorer = withStyles(styles)( dataTableDefaultView, hideColumnSelector, actions, paperProps, hideSearchInput, paperKey, fetchMode, currentItemUuid, title } = this.props; - return + const dataCy = this.props["data-cy"]; + return {title &&
{title}
} {(!hideColumnSelector || !hideSearchInput || !!actions) && diff --git a/src/views-components/data-explorer/renderers.tsx b/src/views-components/data-explorer/renderers.tsx index aa200942..61086bd8 100644 --- a/src/views-components/data-explorer/renderers.tsx +++ b/src/views-components/data-explorer/renderers.tsx @@ -379,7 +379,7 @@ export const ResourceLinkTailUuid = connect( const renderLinkDelete = (dispatch: Dispatch, item: LinkResource) => { if (item.uuid) { return - dispatch(openRemoveGroupMemberDialog(item.uuid))}> + dispatch(openRemoveGroupMemberDialog(item.uuid))}> ; diff --git a/src/views/group-details-panel/group-details-panel.tsx b/src/views/group-details-panel/group-details-panel.tsx index bade28cb..427f4fb8 100644 --- a/src/views/group-details-panel/group-details-panel.tsx +++ b/src/views/group-details-panel/group-details-panel.tsx @@ -167,6 +167,7 @@ export const GroupDetailsPanel = connect( {value === 0 &&