1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 describe('Group manage tests', function() {
9 const groupName = `Test group (${Math.floor(999999 * Math.random())})`;
12 // Only set up common users once. These aren't set up as aliases because
13 // aliases are cleaned up after every test. Also it doesn't make sense
14 // to set the same users on beforeEach() over and over again, so we
15 // separate a little from Cypress' 'Best Practices' here.
16 cy.getUser('admin', 'Admin', 'User', true, true)
17 .as('adminUser').then(function() {
18 adminUser = this.adminUser;
21 cy.getUser('user', 'Active', 'User', false, true)
22 .as('activeUser').then(function() {
23 activeUser = this.activeUser;
26 cy.getUser('otheruser', 'Other', 'User', false, true)
27 .as('otherUser').then(function() {
28 otherUser = this.otherUser;
33 beforeEach(function() {
35 cy.clearLocalStorage();
38 it('creates a new group', function() {
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('.sharing-dialog')
62 .should('contain', 'Sharing settings')
64 cy.get('[data-cy=invite-people-field] input').type("other");
66 cy.get('[role=tooltip]').click();
67 cy.get('.sharing-dialog').contains('Save').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=context-menu]')
99 cy.get('[data-cy=group-members-data-explorer]')
100 .contains('Other User')
103 cy.contains('Write');
107 it('can unhide and re-hide users', function() {
108 // Must use admin user to have manage permission on user
109 cy.loginAs(adminUser);
110 cy.get('[data-cy=side-panel-tree]').contains('Groups').click();
111 cy.get('[data-cy=groups-panel-data-explorer]').contains(groupName).click();
113 // Check that other user is hidden
114 cy.get('[data-cy=group-details-permissions-tab]').click();
115 cy.get('[data-cy=group-permissions-data-explorer]')
116 .should('not.contain', 'Other User')
117 cy.get('[data-cy=group-details-members-tab]').click();
120 cy.get('[data-cy=group-members-data-explorer]')
121 .contains('Other User')
124 cy.get('[data-cy=user-visible-checkbox]').click();
126 // Check that other user is visible
127 cy.get('[data-cy=group-details-permissions-tab]').click();
128 cy.get('[data-cy=group-permissions-data-explorer]')
129 .contains('Other User')
135 cy.get('[data-cy=group-details-members-tab]').click();
136 cy.get('[data-cy=group-members-data-explorer]')
137 .contains('Other User')
140 cy.get('[data-cy=user-visible-checkbox]').click();
142 // Check that other user is hidden
143 cy.get('[data-cy=group-details-permissions-tab]').click();
144 cy.get('[data-cy=group-permissions-data-explorer]')
145 .should('not.contain', 'Other User')
148 it('displays resources shared with the group', function() {
149 // Switch to activeUser
150 cy.loginAs(activeUser);
151 cy.get('[data-cy=side-panel-tree]').contains('Groups').click();
153 // Get groupUuid and create shared project
154 cy.get('[data-cy=groups-panel-data-explorer]')
157 .find('[data-cy=uuid]')
160 .then((groupUuid) => {
162 owningUser: activeUser,
163 projectName: 'test-project',
164 }).as('testProject').then((testProject) => {
165 cy.shareWith(activeUser.token, groupUuid, testProject.uuid, 'can_read');
169 // Check that the project is listed in permissions
170 cy.get('[data-cy=groups-panel-data-explorer]').contains(groupName).click();
171 cy.get('[data-cy=group-details-permissions-tab]').click();
172 cy.get('[data-cy=group-permissions-data-explorer]')
173 .contains('test-project')
180 it('removes users from the group', function() {
181 cy.get('[data-cy=side-panel-tree]').contains('Groups').click();
182 cy.get('[data-cy=groups-panel-data-explorer]').contains(groupName).click();
185 cy.get('[data-cy=group-members-data-explorer]')
186 .contains('Other User')
189 cy.get('[data-cy=resource-delete-button]').click();
191 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
192 cy.get('[data-cy=group-members-data-explorer]')
193 .should('not.contain', 'Other User');
196 it('renames the group', function() {
197 // Navigate to Groups
198 cy.get('[data-cy=side-panel-tree]').contains('Groups').click();
200 // Open rename dialog
201 cy.get('[data-cy=groups-panel-data-explorer]')
204 cy.get('[data-cy=context-menu]')
209 cy.get('[data-cy=form-dialog]')
210 .should('contain', 'Edit Project')
212 cy.get('input[name=name]').clear().type(groupName + ' (renamed)');
213 cy.get('button[type=submit]').click();
216 // Check that the group was renamed
217 cy.get('[data-cy=groups-panel-data-explorer]')
218 .contains(groupName + ' (renamed)');
221 it('deletes the group', function() {
222 // Navigate to Groups
223 cy.get('[data-cy=side-panel-tree]').contains('Groups').click();
226 cy.get('[data-cy=groups-panel-data-explorer]')
227 .contains(groupName + ' (renamed)')
229 cy.get('[data-cy=context-menu]')
232 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
234 // Check that the group was deleted
235 cy.get('[data-cy=groups-panel-data-explorer]')
236 .should('not.contain', groupName + ' (renamed)');
239 it('disables group-related controls for built-in groups', function() {
240 cy.loginAs(adminUser);
242 ['All users', 'Anonymous users', 'System group'].forEach((builtInGroup) => {
243 cy.get('[data-cy=side-panel-tree]').contains('Groups').click();
244 cy.get('[data-cy=groups-panel-data-explorer]').contains(builtInGroup).click();
246 // Check group member actions
247 cy.get('[data-cy=group-members-data-explorer]')
249 cy.get('[data-cy=group-member-add]').should('not.exist');
250 cy.get('[data-cy=user-visible-checkbox] input').should('be.disabled');
251 cy.get('[data-cy=resource-delete-button]').should('be.disabled');
252 cy.get('[data-cy=edit-permission-button]').should('not.exist');
255 // Check permissions actions
256 cy.get('[data-cy=group-details-permissions-tab]').click();
257 cy.get('[data-cy=group-permissions-data-explorer]').within(() => {
258 cy.get('[data-cy=resource-delete-button]').should('be.disabled');
259 cy.get('[data-cy=edit-permission-button]').should('not.exist');