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.only('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 () {
61 cy.contains('Refresh').click();
62 cy.get('main').contains(this.mySharedProject1.name).rightclick();
63 cy.get('[data-cy=context-menu]').within(() => {
64 cy.contains('Share').click();
67 cy.get('[id="select-permissions"]').as('selectPermissions');
68 cy.get('@selectPermissions').click();
69 cy.contains('Write').click();
70 cy.get('.sharing-dialog').as('sharingDialog');
71 cy.get('@sharingDialog').find('input').first().type(activeUser.user.email);
72 cy.get('[role=tooltip]').click();
73 cy.get('@sharingDialog').find('button').last().click();
76 cy.createGroup(adminUser.token, {
77 name: `my-shared-readonly-project ${Math.floor(Math.random() * 999999)}`,
78 group_class: 'project',
79 }).as('mySharedProject2').then(function () {
80 cy.contains('Refresh').click();
81 cy.get('main').contains(this.mySharedProject2.name).rightclick();
82 cy.get('[data-cy=context-menu]').within(() => {
83 cy.contains('Share').click();
86 cy.get('.sharing-dialog').as('sharingDialog');
87 cy.get('@sharingDialog').find('input').first().type(activeUser.user.email);
88 cy.get('[role=tooltip]').click();
89 cy.get('@sharingDialog').find('button').last().click();
92 cy.createGroup(activeUser.token, {
93 name: `my-project ${Math.floor(Math.random() * 999999)}`,
94 group_class: 'project',
97 cy.get('@mySharedProject1').then(function () {
98 cy.get('@mySharedProject2').then(function () {
99 cy.get('@myProject1').then(function () {
100 cy.createCollection(adminUser.token, {
101 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
102 owner_uuid: activeUser.user.uuid,
103 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
105 .as('testCollection').then(function () {
106 cy.loginAs(activeUser);
108 cy.contains('Shared with me').click();
110 cy.get('main').contains(this.mySharedProject1.name).rightclick();
111 cy.get('[data-cy=context-menu]').within(() => {
112 cy.contains('Add to favorites').click();
115 cy.get('main').contains(this.mySharedProject2.name).rightclick();
116 cy.get('[data-cy=context-menu]').within(() => {
117 cy.contains('Add to favorites').click();
120 cy.doSearch(`${activeUser.user.uuid}`);
122 cy.get('main').contains(this.myProject1.name).rightclick();
123 cy.get('[data-cy=context-menu]').within(() => {
124 cy.contains('Add to favorites').click();
127 cy.contains(this.testCollection.name).rightclick();
128 cy.get('[data-cy=context-menu]').within(() => {
129 cy.contains('Move to').click();
132 cy.get('[data-cy=form-dialog]').within(function() {
133 cy.get('ul').last().find('i').click();
134 cy.contains(this.myProject1.name);
135 cy.contains(this.mySharedProject1.name);
137 .should('not.contain', this.mySharedProject2.name);