1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 describe('Group manage tests', function() {
11 // Only set up common users once. These aren't set up as aliases because
12 // aliases are cleaned up after every test. Also it doesn't make sense
13 // to set the same users on beforeEach() over and over again, so we
14 // separate a little from Cypress' 'Best Practices' here.
15 cy.getUser('admin', 'Admin', 'User', true, true)
16 .as('adminUser').then(function() {
17 adminUser = this.adminUser;
20 cy.getUser('user', 'Active', 'User', false, true)
21 .as('activeUser').then(function() {
22 activeUser = this.activeUser;
25 cy.getUser('otheruser', 'Other', 'User', false, true)
26 .as('otherUser').then(function() {
27 otherUser = this.otherUser;
32 beforeEach(function() {
34 cy.clearLocalStorage();
37 it('creates a new group', function() {
38 const groupName = `Test group (${Math.floor(999999 * Math.random())})`;
39 cy.loginAs(activeUser);
42 cy.get('[data-cy=side-panel-tree]').contains('Groups').click();
45 cy.get('[data-cy=groups-panel-new-group]').click();
46 cy.get('[data-cy=form-dialog]')
47 .should('contain', 'Create a group')
49 cy.get('input[name=name]').type(groupName);
50 cy.get('button[type=submit]').click();
53 // Check that the group was created
54 cy.get('[data-cy=groups-panel-data-explorer]').contains(groupName).click();
55 cy.get('[data-cy=group-members-data-explorer]').contains('Active User');
58 it('adds users to the group', function() {
59 // Add other user to the group
60 cy.get('[data-cy=group-member-add]').click();
61 cy.get('[data-cy=form-dialog]')
62 .should('contain', 'Add users')
64 cy.get('input').type("other");
66 cy.contains('Other User').click();
67 cy.get('[data-cy=form-dialog] button[type=submit]').click();
69 // Check that both users are present with appropriate permissions
70 cy.get('[data-cy=group-members-data-explorer]')
71 .contains('Other User')
76 cy.get('[data-cy=group-members-data-explorer] tr')
77 .contains('Active User')
80 cy.contains('Manage');
84 it('changes permission level of a member', function() {
85 // Test change permission level
86 cy.get('[data-cy=group-members-data-explorer]')
87 .contains('Other User')
93 cy.get('button').click();
96 cy.get('[data-cy=form-dialog]')
97 .should('contain', 'Edit permission')
99 cy.contains('Read').click();
105 cy.get('[data-cy=form-dialog] button[type=submit]').click();
106 cy.get('[data-cy=group-members-data-explorer]')
107 .contains('Other User')
110 cy.contains('Write');
114 it('removes users from the group', function() {
116 cy.get('[data-cy=group-members-data-explorer]')
117 .contains('Other User')
120 cy.get('[data-cy=resource-delete-button]').click();
122 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
123 cy.get('[data-cy=group-members-data-explorer]')
124 .should('not.contain', 'Other User');