18123: Invert group member is visible logic
[arvados-workbench2.git] / cypress / integration / group-manage.spec.js
index b317ad3c0b392b2625d4ed9b7996ca4bf3d6b392..cae69efb4e021fbb72161ae40c908230fa97be97 100644 (file)
@@ -58,13 +58,13 @@ describe('Group manage tests', function() {
     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')
+        cy.get('.sharing-dialog')
+            .should('contain', 'Sharing settings')
             .within(() => {
-                cy.get('input').type("other");
+                cy.get('[data-cy=invite-people-field] input').type("other");
             });
-        cy.contains('Other User').click();
-        cy.get('[data-cy=form-dialog] button[type=submit]').click();
+        cy.get('[role=tooltip]').click();
+        cy.get('.sharing-dialog').contains('Save').click();
 
         // Check that both users are present with appropriate permissions
         cy.get('[data-cy=group-members-data-explorer]')
@@ -104,7 +104,7 @@ describe('Group manage tests', function() {
             });
     });
 
-    it('unhides users', function() {
+    it('can unhide and re-hide users', function() {
         // Must use admin user to have manage permission on user
         cy.loginAs(adminUser);
         cy.get('[data-cy=side-panel-tree]').contains('Groups').click();
@@ -121,7 +121,7 @@ describe('Group manage tests', function() {
             .contains('Other User')
             .parents('tr')
             .within(() => {
-                cy.get('[data-cy=user-hidden-checkbox]').click();
+                cy.get('[data-cy=user-visible-checkbox]').click();
             });
         // Check that other user is visible
         cy.get('[data-cy=group-details-permissions-tab]').click();
@@ -137,7 +137,7 @@ describe('Group manage tests', function() {
             .contains('Other User')
             .parents('tr')
             .within(() => {
-                cy.get('[data-cy=user-hidden-checkbox]').click();
+                cy.get('[data-cy=user-visible-checkbox]').click();
             });
         // Check that other user is hidden
         cy.get('[data-cy=group-details-permissions-tab]').click();
@@ -145,9 +145,40 @@ describe('Group manage tests', function() {
             .should('not.contain', 'Other User')
     });
 
-    it('removes users from the group', function() {
+    it('displays resources shared with the group', function() {
+        // Switch to activeUser
         cy.loginAs(activeUser);
         cy.get('[data-cy=side-panel-tree]').contains('Groups').click();
+
+        // Get groupUuid and create shared project
+        cy.get('[data-cy=groups-panel-data-explorer]')
+            .contains(groupName)
+            .parents('tr')
+            .find('[data-cy=uuid]')
+            .invoke('text')
+            .as('groupUuid')
+            .then((groupUuid) => {
+                cy.createProject({
+                    owningUser: activeUser,
+                    projectName: 'test-project',
+                }).as('testProject').then((testProject) => {
+                    cy.shareWith(activeUser.token, groupUuid, testProject.uuid, 'can_read');
+                });
+            });
+
+        // Check that the project is listed in permissions
+        cy.get('[data-cy=groups-panel-data-explorer]').contains(groupName).click();
+        cy.get('[data-cy=group-details-permissions-tab]').click();
+        cy.get('[data-cy=group-permissions-data-explorer]')
+            .contains('test-project')
+            .parents('tr')
+            .within(() => {
+                cy.contains('Read');
+            });
+    });
+
+    it('removes users from the group', function() {
+        cy.get('[data-cy=side-panel-tree]').contains('Groups').click();
         cy.get('[data-cy=groups-panel-data-explorer]').contains(groupName).click();
 
         // Remove other user
@@ -205,4 +236,29 @@ describe('Group manage tests', function() {
             .should('not.contain', groupName + ' (renamed)');
     });
 
+    it('disables group-related controls for built-in groups', function() {
+        cy.loginAs(adminUser);
+
+        ['All users', 'Anonymous users', 'System group'].forEach((builtInGroup) => {
+            cy.get('[data-cy=side-panel-tree]').contains('Groups').click();
+            cy.get('[data-cy=groups-panel-data-explorer]').contains(builtInGroup).click();
+
+            // Check group member actions
+            cy.get('[data-cy=group-members-data-explorer]')
+                .within(() => {
+                    cy.get('[data-cy=group-member-add]').should('not.exist');
+                    cy.get('[data-cy=user-visible-checkbox] input').should('be.disabled');
+                    cy.get('[data-cy=resource-delete-button]').should('be.disabled');
+                    cy.get('[data-cy=edit-permission-button]').should('not.exist');
+                });
+
+            // Check permissions actions
+            cy.get('[data-cy=group-details-permissions-tab]').click();
+            cy.get('[data-cy=group-permissions-data-explorer]').within(() => {
+                cy.get('[data-cy=resource-delete-button]').should('be.disabled');
+                cy.get('[data-cy=edit-permission-button]').should('not.exist');
+            });
+        });
+    });
+
 });