[ARVADOS-WORKBENCH2] updated: 2.1.0-217-gd2817690

Git user git at public.arvados.org
Mon Mar 8 22:39:15 UTC 2021


Summary of changes:
 cypress/integration/favorites.spec.js | 45 ++++++++++++++++---
 cypress/integration/sharing.spec.js   | 81 +++++++++++++++++++++++++++++++++++
 cypress/support/commands.js           | 42 +++++++++---------
 3 files changed, 140 insertions(+), 28 deletions(-)
 create mode 100644 cypress/integration/sharing.spec.js

       via  d2817690f88befb0c306e637d6e87367016c76e3 (commit)
      from  335fee64075faf3dac519fba45da5ecbe5008f33 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit d2817690f88befb0c306e637d6e87367016c76e3
Author: Daniel Kutyła <daniel.kutyla at contractors.roche.com>
Date:   Mon Mar 8 23:38:08 2021 +0100

    17436: Created generic code for project creation in cypress
    
    Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła <daniel.kutyla at contractors.roche.com>

diff --git a/cypress/integration/favorites.spec.js b/cypress/integration/favorites.spec.js
index 5c012377..2afdf92e 100644
--- a/cypress/integration/favorites.spec.js
+++ b/cypress/integration/favorites.spec.js
@@ -30,6 +30,7 @@ describe('Favorites tests', function () {
 
     it('creates and removes a public favorite', function () {
         cy.loginAs(adminUser);
+
         cy.createGroup(adminUser.token, {
             name: `my-favorite-project`,
             group_class: 'project',
@@ -99,9 +100,25 @@ describe('Favorites tests', function () {
     });
 
     it('can copy collection to favorites', () => {
-        cy.loginAs(adminUser);
-
-        cy.createSharedProjects(adminUser, activeUser);
+        cy.createProject({
+            owningUser: adminUser,
+            targetUser: activeUser,
+            projectName: 'mySharedWritableProject',
+            canWrite: true,
+            addToFavorites: true
+        });
+        cy.createProject({
+            owningUser: adminUser,
+            targetUser: activeUser,
+            projectName: 'mySharedReadonlyProject',
+            canWrite: false,
+            addToFavorites: true
+        });
+        cy.createProject({
+            owningUser: activeUser,
+            projectName: 'myProject1',
+            addToFavorites: true
+        });
 
         cy.createCollection(adminUser.token, {
             name: `Test collection ${Math.floor(Math.random() * 999999)}`,
@@ -137,9 +154,25 @@ describe('Favorites tests', function () {
     });
 
     it('can view favourites in workflow', () => {
-        cy.loginAs(adminUser);
-
-        cy.createSharedProjects(adminUser, activeUser);
+        cy.createProject({
+            owningUser: adminUser,
+            targetUser: activeUser,
+            projectName: 'mySharedWritableProject',
+            canWrite: true,
+            addToFavorites: true
+        });
+        cy.createProject({
+            owningUser: adminUser,
+            targetUser: activeUser,
+            projectName: 'mySharedReadonlyProject',
+            canWrite: false,
+            addToFavorites: true
+        });
+        cy.createProject({
+            owningUser: activeUser,
+            projectName: 'myProject1',
+            addToFavorites: true
+        });
 
         cy.getAll('@mySharedWritableProject', '@mySharedReadonlyProject', '@myProject1')
             .then(function ([mySharedWritableProject, mySharedReadonlyProject, myProject1]) {
diff --git a/cypress/integration/sharing.spec.js b/cypress/integration/sharing.spec.js
new file mode 100644
index 00000000..5786c41d
--- /dev/null
+++ b/cypress/integration/sharing.spec.js
@@ -0,0 +1,81 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+describe('Sharing tests', function () {
+    let activeUser;
+    let adminUser;
+
+    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('collectionuser1', 'Collection', 'User', false, true)
+            .as('activeUser').then(function () {
+                activeUser = this.activeUser;
+            }
+            );
+    })
+
+    beforeEach(function () {
+        cy.clearCookies()
+        cy.clearLocalStorage()
+    });
+
+    it('can share projects to other users', () => {
+        cy.loginAs(adminUser);
+
+        cy.createGroup(adminUser.token, {
+            name: `my-shared-writable-project ${Math.floor(Math.random() * 999999)}`,
+            group_class: 'project',
+        }).as('mySharedWritableProject').then(function (mySharedWritableProject) {
+            cy.contains('Refresh').click();
+            cy.get('main').contains(mySharedWritableProject.name).rightclick();
+            cy.get('[data-cy=context-menu]').within(() => {
+                cy.contains('Share').click();
+            });
+            cy.get('[id="select-permissions"]').as('selectPermissions');
+            cy.get('@selectPermissions').click();
+            cy.contains('Write').click();
+            cy.get('.sharing-dialog').as('sharingDialog');
+            cy.get('[data-cy=invite-people-field]').find('input').type(activeUser.user.email);
+            cy.get('[role=tooltip]').click();
+            cy.get('@sharingDialog').contains('Save').click();
+        });
+
+        cy.createGroup(adminUser.token, {
+            name: `my-shared-readonly-project ${Math.floor(Math.random() * 999999)}`,
+            group_class: 'project',
+        }).as('mySharedReadonlyProject').then(function (mySharedReadonlyProject) {
+            cy.contains('Refresh').click();
+            cy.get('main').contains(mySharedReadonlyProject.name).rightclick();
+            cy.get('[data-cy=context-menu]').within(() => {
+                cy.contains('Share').click();
+            });
+            cy.get('.sharing-dialog').as('sharingDialog');
+            cy.get('[data-cy=invite-people-field]').find('input').type(activeUser.user.email);
+            cy.get('[role=tooltip]').click();
+            cy.get('@sharingDialog').contains('Save').click();
+        });
+
+        cy.getAll('@mySharedWritableProject', '@mySharedReadonlyProject')
+            .then(function ([mySharedWritableProject, mySharedReadonlyProject]) {
+                cy.loginAs(activeUser);
+
+                cy.contains('Shared with me').click();
+
+                cy.get('main').contains(mySharedWritableProject.name).rightclick();
+                cy.get('[data-cy=context-menu]').should('contain', 'Move to trash');
+                cy.get('[data-cy=context-menu]').contains('Move to trash').click();
+
+                cy.get('main').contains(mySharedReadonlyProject.name).rightclick();
+                cy.get('[data-cy=context-menu]').should('not.contain', 'Move to trash');
+            });
+    });
+});
\ No newline at end of file
diff --git a/cypress/support/commands.js b/cypress/support/commands.js
index 33590552..8dc003fe 100644
--- a/cypress/support/commands.js
+++ b/cypress/support/commands.js
@@ -217,27 +217,25 @@ Cypress.Commands.add('addToFavorites', (activeUserToken, activeUserUUID, itemUUI
     });
 })
 
-Cypress.Commands.add('createSharedProjects', (adminUser, activeUser) => {
-    cy.createGroup(adminUser.token, {
-        name: `my-shared-writable-project ${Math.floor(Math.random() * 999999)}`,
+Cypress.Commands.add('createProject', ({
+    owningUser,
+    targetUser,
+    projectName,
+    canWrite,
+    addToFavorites
+}) => {
+    const writePermission = canWrite ? 'can_write' : 'can_read';
+
+    cy.createGroup(owningUser.token, {
+        name: `${projectName} ${Math.floor(Math.random() * 999999)}`,
         group_class: 'project',
-    }).as('mySharedWritableProject').then((mySharedWritableProject) => {
-        cy.shareWith(adminUser.token, activeUser.user.uuid, mySharedWritableProject.uuid, 'can_write');
-        cy.addToFavorites(activeUser.token, activeUser.user.uuid, mySharedWritableProject.uuid);
+    }).as(`${projectName}`).then((project) => {
+        if (targetUser && targetUser !== owningUser) {
+            cy.shareWith(owningUser.token, targetUser.user.uuid, project.uuid, writePermission);
+        }
+        if (addToFavorites) {
+            const user = targetUser ? targetUser : owningUser;
+            cy.addToFavorites(user.token, user.user.uuid, project.uuid);
+        }
     });
-
-    cy.createGroup(adminUser.token, {
-        name: `my-shared-readonly-project ${Math.floor(Math.random() * 999999)}`,
-        group_class: 'project',
-    }).as('mySharedReadonlyProject').then((mySharedReadonlyProject) => {
-        cy.shareWith(adminUser.token, activeUser.user.uuid, mySharedReadonlyProject.uuid, 'can_read');
-        cy.addToFavorites(activeUser.token, activeUser.user.uuid, mySharedReadonlyProject.uuid);
-    });
-
-    cy.createGroup(activeUser.token, {
-        name: `my-project ${Math.floor(Math.random() * 999999)}`,
-        group_class: 'project',
-    }).as('myProject1').then((myProject1) => {
-        cy.addToFavorites(activeUser.token, activeUser.user.uuid, myProject1.uuid);
-    });
-})
\ No newline at end of file
+});
\ No newline at end of file

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list