1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 describe('Sharing tests', function () {
10 // Only set up common users once. These aren't set up as aliases because
11 // aliases are cleaned up after every test. Also it doesn't make sense
12 // to set the same users on beforeEach() over and over again, so we
13 // separate a little from Cypress' 'Best Practices' here.
14 cy.getUser('admin', 'Admin', 'User', true, true)
15 .as('adminUser').then(function () {
16 adminUser = this.adminUser;
19 cy.getUser('collectionuser1', 'Collection', 'User', false, true)
20 .as('activeUser').then(function () {
21 activeUser = this.activeUser;
26 beforeEach(function () {
28 cy.clearLocalStorage()
31 it('can share projects to other users', () => {
32 cy.loginAs(adminUser);
34 cy.createGroup(adminUser.token, {
35 name: `my-shared-writable-project ${Math.floor(Math.random() * 999999)}`,
36 group_class: 'project',
37 }).as('mySharedWritableProject').then(function (mySharedWritableProject) {
38 cy.contains('Refresh').click();
39 cy.get('main').contains(mySharedWritableProject.name).rightclick();
40 cy.get('[data-cy=context-menu]').within(() => {
41 cy.contains('Share').click();
43 cy.get('[id="select-permissions"]').as('selectPermissions');
44 cy.get('@selectPermissions').click();
45 cy.contains('Write').click();
46 cy.get('.sharing-dialog').as('sharingDialog');
47 cy.get('[data-cy=invite-people-field]').find('input').type(activeUser.user.email);
48 cy.get('[role=tooltip]').click();
49 cy.get('@sharingDialog').contains('Save').click();
52 cy.createGroup(adminUser.token, {
53 name: `my-shared-readonly-project ${Math.floor(Math.random() * 999999)}`,
54 group_class: 'project',
55 }).as('mySharedReadonlyProject').then(function (mySharedReadonlyProject) {
56 cy.contains('Refresh').click();
57 cy.get('main').contains(mySharedReadonlyProject.name).rightclick();
58 cy.get('[data-cy=context-menu]').within(() => {
59 cy.contains('Share').click();
61 cy.get('.sharing-dialog').as('sharingDialog');
62 cy.get('[data-cy=invite-people-field]').find('input').type(activeUser.user.email);
63 cy.get('[role=tooltip]').click();
64 cy.get('@sharingDialog').contains('Save').click();
67 cy.getAll('@mySharedWritableProject', '@mySharedReadonlyProject')
68 .then(function ([mySharedWritableProject, mySharedReadonlyProject]) {
69 cy.loginAs(activeUser);
71 cy.contains('Shared with me').click();
73 cy.get('main').contains(mySharedWritableProject.name).rightclick();
74 cy.get('[data-cy=context-menu]').should('contain', 'Move to trash');
75 cy.get('[data-cy=context-menu]').contains('Move to trash').click();
77 // GUARD: Let's wait for the above removed project to disappear
78 // before continuing, to avoid intermittent failures.
79 cy.get('main').should('not.contain', mySharedWritableProject.name);
81 cy.get('main').contains(mySharedReadonlyProject.name).rightclick();
82 cy.get('[data-cy=context-menu]').should('not.contain', 'Move to trash');
86 it('can edit project in shared with me', () => {
88 owningUser: adminUser,
89 targetUser: activeUser,
90 projectName: 'mySharedWritableProject',
95 cy.getAll('@mySharedWritableProject')
96 .then(function ([mySharedWritableProject]) {
97 cy.loginAs(activeUser);
99 cy.get('[data-cy=side-panel-tree]').contains('Shared with me').click();
101 const newProjectName = `New project name ${mySharedWritableProject.name}`;
102 const newProjectDescription = `New project description ${mySharedWritableProject.name}`;
104 cy.testEditProjectOrCollection('main', mySharedWritableProject.name, newProjectName, newProjectDescription);