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('mySharedWritableProject').then(function (mySharedWritableProject) {
61 cy.contains('Refresh').click();
62 cy.get('main').contains(mySharedWritableProject.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('[data-cy=invite-people-field]').find('input').type(activeUser.user.email);
71 cy.get('[role=tooltip]').click();
72 cy.get('@sharingDialog').contains('Save').click();
75 cy.createGroup(adminUser.token, {
76 name: `my-shared-readonly-project ${Math.floor(Math.random() * 999999)}`,
77 group_class: 'project',
78 }).as('mySharedReadonlyProject').then(function (mySharedReadonlyProject) {
79 cy.contains('Refresh').click();
80 cy.get('main').contains(mySharedReadonlyProject.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('[data-cy=invite-people-field]').find('input').type(activeUser.user.email);
86 cy.get('[role=tooltip]').click();
87 cy.get('@sharingDialog').contains('Save').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('@mySharedWritableProject', '@mySharedReadonlyProject', '@myProject1', '@testCollection')
103 .then(function ([mySharedWritableProject, mySharedReadonlyProject, myProject1, testCollection]) {
104 cy.loginAs(activeUser);
106 cy.contains('Shared with me').click();
108 cy.get('main').contains(mySharedWritableProject.name).rightclick();
109 cy.get('[data-cy=context-menu]').within(() => {
110 cy.contains('Add to favorites').click();
113 cy.get('main').contains(mySharedReadonlyProject.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('[data-cy=projects-tree-favourites-tree-pciker]').find('i').click();
132 cy.contains(myProject1.name);
133 cy.contains(mySharedWritableProject.name);
134 cy.get('[data-cy=projects-tree-favourites-tree-pciker]')
135 .should('not.contain', mySharedReadonlyProject.name);
136 cy.contains(mySharedWritableProject.name).click();
137 cy.get('[data-cy=form-submit-btn]').click();
140 cy.doSearch(`${mySharedWritableProject.uuid}`);
141 cy.get('main').contains(testCollection.name);
145 it('can copy selected into the collection', () => {
146 cy.loginAs(activeUser);
148 cy.createCollection(adminUser.token, {
149 name: `Test source collection ${Math.floor(Math.random() * 999999)}`,
150 owner_uuid: activeUser.user.uuid,
151 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
153 .as('testSourceCollection');
155 cy.createCollection(adminUser.token, {
156 name: `Test target collection ${Math.floor(Math.random() * 999999)}`,
157 owner_uuid: activeUser.user.uuid
159 .as('testTargetCollection');
161 cy.getAll('@testSourceCollection', '@testTargetCollection')
162 .then(function ([testSourceCollection, testTargetCollection]) {
163 cy.loginAs(activeUser);
165 cy.get('.layout-pane-primary')
166 .contains('Projects').click();
168 cy.get('main').contains(testTargetCollection.name).rightclick();
169 cy.get('[data-cy=context-menu]').within(() => {
170 cy.contains('Add to favorites').click();
173 cy.get('main').contains(testSourceCollection.name).click();
174 cy.get('[data-cy=collection-files-panel]').contains('bar');
175 cy.get('[data-cy=collection-files-panel]').find('input[type=checkbox]').click({ force: true });
176 cy.get('[data-cy=collection-files-panel-options-btn]').click();
177 cy.get('[data-cy=context-menu]')
178 .contains('Copy selected into the collection').click();
180 cy.get('[data-cy=projects-tree-favourites-tree-pciker]')
184 cy.get('[data-cy=projects-tree-favourites-tree-pciker]')
185 .contains(testTargetCollection.name)
188 cy.get('[data-cy=form-submit-btn]').click();
190 cy.get('.layout-pane-primary')
191 .contains('Projects').click();
193 cy.get('main').contains(testTargetCollection.name).click();
195 cy.get('[data-cy=collection-files-panel]').contains('bar');