Merge branch '17018-readonly-file-actions-fix'
[arvados-workbench2.git] / cypress / integration / favorites.js
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 describe('Favorites tests', function() {
6     let activeUser;
7     let adminUser;
8
9     before(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;
17             }
18         );
19         cy.getUser('collectionuser1', 'Collection', 'User', false, true)
20             .as('activeUser').then(function() {
21                 activeUser = this.activeUser;
22             }
23         );
24     })
25
26     beforeEach(function() {
27         cy.clearCookies()
28         cy.clearLocalStorage()
29     })
30
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');
35     })
36
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);
51             });
52     })
53 })