1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 describe('Favorites 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('checks that Public favorites does not appear under shared with me', function () {
32 cy.loginAs(adminUser);
33 cy.contains('Shared with me').click();
34 cy.get('main').contains('Public favorites').should('not.exist');
37 it('creates and removes a public favorite', function () {
38 cy.loginAs(adminUser);
39 cy.createGroup(adminUser.token, {
40 name: `my-favorite-project`,
41 group_class: 'project',
42 }).as('myFavoriteProject').then(function () {
43 cy.contains('Refresh').click();
44 cy.get('main').contains('my-favorite-project').rightclick();
45 cy.contains('Add to public favorites').click();
46 cy.contains('Public Favorites').click();
47 cy.get('main').contains('my-favorite-project').rightclick();
48 cy.contains('Remove from public favorites').click();
49 cy.get('main').contains('my-favorite-project').should('not.exist');
50 cy.trashGroup(adminUser.token, this.myFavoriteProject.uuid);
54 it('can copy collection to favorites', () => {
55 cy.loginAs(adminUser);
57 cy.createGroup(adminUser.token, {
58 name: `my-shared-writable-project ${Math.floor(Math.random() * 999999)}`,
59 group_class: 'project',
60 }).as('mySharedProject1').then(function (mySharedProject1) {
61 cy.contains('Refresh').click();
62 cy.get('main').contains(mySharedProject1.name).rightclick();
63 cy.get('[data-cy=context-menu]').within(() => {
64 cy.contains('Share').click();
66 cy.get('[id="select-permissions"]').as('selectPermissions');
67 cy.get('@selectPermissions').click();
68 cy.contains('Write').click();
69 cy.get('.sharing-dialog').as('sharingDialog');
70 cy.get('@sharingDialog').find('input').first().type(activeUser.user.email);
71 cy.get('[role=tooltip]').click();
72 cy.get('@sharingDialog').find('button').last().click();
75 cy.createGroup(adminUser.token, {
76 name: `my-shared-readonly-project ${Math.floor(Math.random() * 999999)}`,
77 group_class: 'project',
78 }).as('mySharedProject2').then(function (mySharedProject2) {
79 cy.contains('Refresh').click();
80 cy.get('main').contains(mySharedProject2.name).rightclick();
81 cy.get('[data-cy=context-menu]').within(() => {
82 cy.contains('Share').click();
84 cy.get('.sharing-dialog').as('sharingDialog');
85 cy.get('@sharingDialog').find('input').first().type(activeUser.user.email);
86 cy.get('[role=tooltip]').click();
87 cy.get('@sharingDialog').find('button').last().click();
90 cy.createGroup(activeUser.token, {
91 name: `my-project ${Math.floor(Math.random() * 999999)}`,
92 group_class: 'project',
95 cy.createCollection(adminUser.token, {
96 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
97 owner_uuid: activeUser.user.uuid,
98 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
100 .as('testCollection');
102 cy.getAll('@mySharedProject1', '@mySharedProject2', '@myProject1', '@testCollection')
103 .then(function ([mySharedProject1, mySharedProject2, myProject1, testCollection]) {
104 cy.loginAs(activeUser);
106 cy.contains('Shared with me').click();
108 cy.get('main').contains(mySharedProject1.name).rightclick();
109 cy.get('[data-cy=context-menu]').within(() => {
110 cy.contains('Add to favorites').click();
113 cy.get('main').contains(mySharedProject2.name).rightclick();
114 cy.get('[data-cy=context-menu]').within(() => {
115 cy.contains('Add to favorites').click();
118 cy.doSearch(`${activeUser.user.uuid}`);
120 cy.get('main').contains(myProject1.name).rightclick();
121 cy.get('[data-cy=context-menu]').within(() => {
122 cy.contains('Add to favorites').click();
125 cy.contains(testCollection.name).rightclick();
126 cy.get('[data-cy=context-menu]').within(() => {
127 cy.contains('Move to').click();
130 cy.get('[data-cy=form-dialog]').within(function () {
131 cy.get('ul').last().find('i').click();
132 cy.contains(myProject1.name);
133 cy.contains(mySharedProject1.name);
135 .should('not.contain', mySharedProject2.name);