18549: Layout fixed, tests updated
[arvados-workbench2.git] / cypress / integration / group-manage.spec.js
index cae69efb4e021fbb72161ae40c908230fa97be97..848220344adfd9d43c547426edfabfdc24ada695 100644 (file)
@@ -6,6 +6,7 @@ describe('Group manage tests', function() {
     let activeUser;
     let adminUser;
     let otherUser;
+    let userThree;
     const groupName = `Test group (${Math.floor(999999 * Math.random())})`;
 
     before(function() {
@@ -28,11 +29,11 @@ describe('Group manage tests', function() {
                 otherUser = this.otherUser;
             }
         );
-    });
-
-    beforeEach(function() {
-        cy.clearCookies();
-        cy.clearLocalStorage();
+        cy.getUser('userThree', 'User', 'Three', false, true)
+            .as('userThree').then(function() {
+                userThree = this.userThree;
+            }
+        );
     });
 
     it('creates a new group', function() {
@@ -44,15 +45,20 @@ describe('Group manage tests', function() {
         // Create new group
         cy.get('[data-cy=groups-panel-new-group]').click();
         cy.get('[data-cy=form-dialog]')
-            .should('contain', 'Create a group')
+            .should('contain', 'New Group')
             .within(() => {
                 cy.get('input[name=name]').type(groupName);
-                cy.get('button[type=submit]').click();
+                cy.get('[data-cy=users-field] input').type("three");
             });
-        
+        cy.get('[role=tooltip]').click();
+        cy.get('[data-cy=form-dialog]').within(() => {
+            cy.get('[data-cy=form-submit-btn]').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');
+        cy.get('[data-cy=group-members-data-explorer]').contains(activeUser.user.full_name);
+        cy.get('[data-cy=group-members-data-explorer]').contains(userThree.user.full_name);
     });
 
     it('adds users to the group', function() {
@@ -68,13 +74,13 @@ describe('Group manage tests', function() {
 
         // Check that both users are present with appropriate permissions
         cy.get('[data-cy=group-members-data-explorer]')
-            .contains('Other User')
+            .contains(otherUser.user.full_name)
             .parents('tr')
             .within(() => {
                 cy.contains('Read');
             });
         cy.get('[data-cy=group-members-data-explorer] tr')
-            .contains('Active User')
+            .contains(activeUser.user.full_name)
             .parents('tr')
             .within(() => {
                 cy.contains('Manage');
@@ -84,7 +90,7 @@ describe('Group manage tests', function() {
     it('changes permission level of a member', function() {
         // Test change permission level
         cy.get('[data-cy=group-members-data-explorer]')
-            .contains('Other User')
+            .contains(otherUser.user.full_name)
             .parents('tr')
             .within(() => {
                 cy.contains('Read')
@@ -97,7 +103,7 @@ describe('Group manage tests', function() {
             .contains('Write')
             .click();
         cy.get('[data-cy=group-members-data-explorer]')
-            .contains('Other User')
+            .contains(otherUser.user.full_name)
             .parents('tr')
             .within(() => {
                 cy.contains('Write');
@@ -113,12 +119,12 @@ describe('Group manage tests', function() {
         // Check that other user is hidden
         cy.get('[data-cy=group-details-permissions-tab]').click();
         cy.get('[data-cy=group-permissions-data-explorer]')
-            .should('not.contain', 'Other User')
+            .should('not.contain', otherUser.user.full_name)
         cy.get('[data-cy=group-details-members-tab]').click();
 
         // Test unhide
         cy.get('[data-cy=group-members-data-explorer]')
-            .contains('Other User')
+            .contains(otherUser.user.full_name)
             .parents('tr')
             .within(() => {
                 cy.get('[data-cy=user-visible-checkbox]').click();
@@ -126,7 +132,7 @@ describe('Group manage tests', function() {
         // Check that other user is visible
         cy.get('[data-cy=group-details-permissions-tab]').click();
         cy.get('[data-cy=group-permissions-data-explorer]')
-            .contains('Other User')
+            .contains(otherUser.user.full_name)
             .parents('tr')
             .within(() => {
                 cy.contains('Read');
@@ -134,7 +140,7 @@ describe('Group manage tests', function() {
         // Test re-hide
         cy.get('[data-cy=group-details-members-tab]').click();
         cy.get('[data-cy=group-members-data-explorer]')
-            .contains('Other User')
+            .contains(otherUser.user.full_name)
             .parents('tr')
             .within(() => {
                 cy.get('[data-cy=user-visible-checkbox]').click();
@@ -142,7 +148,7 @@ describe('Group manage tests', function() {
         // Check that other user is hidden
         cy.get('[data-cy=group-details-permissions-tab]').click();
         cy.get('[data-cy=group-permissions-data-explorer]')
-            .should('not.contain', 'Other User')
+            .should('not.contain', otherUser.user.full_name)
     });
 
     it('displays resources shared with the group', function() {
@@ -183,14 +189,25 @@ describe('Group manage tests', function() {
 
         // Remove other user
         cy.get('[data-cy=group-members-data-explorer]')
-            .contains('Other User')
+            .contains(otherUser.user.full_name)
+            .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', otherUser.user.full_name);
+
+        // Remove user three
+        cy.get('[data-cy=group-members-data-explorer]')
+            .contains(userThree.user.full_name)
             .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');
+            .should('not.contain', userThree.user.full_name);
     });
 
     it('renames the group', function() {
@@ -207,10 +224,10 @@ describe('Group manage tests', function() {
 
         // Rename the group
         cy.get('[data-cy=form-dialog]')
-            .should('contain', 'Edit Project')
+            .should('contain', 'Edit Group')
             .within(() => {
                 cy.get('input[name=name]').clear().type(groupName + ' (renamed)');
-                cy.get('button[type=submit]').click();
+                cy.get('button').contains('Save').click();
             });
 
         // Check that the group was renamed