17426: Add "enableWhenPristine" option for dialog boxes.
[arvados-workbench2.git] / cypress / integration / side-panel.spec.js
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 describe('Side panel 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('user', 'Active', '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('enables the +NEW side panel button on users home project', function() {
32         cy.loginAs(activeUser);
33         cy.doSearch(`${activeUser.user.uuid}`);
34         cy.get('[data-cy=side-panel-button]')
35             .should('exist')
36             .and('not.be.disabled');
37     })
38
39     it('disables or enables the +NEW side panel button on depending on project permissions', function() {
40         cy.loginAs(activeUser);
41         [true, false].map(function(isWritable) {
42             cy.createGroup(adminUser.token, {
43                 name: `Test ${isWritable ? 'writable' : 'read-only'} project`,
44                 group_class: 'project',
45             }).as('sharedGroup').then(function() {
46                 cy.createLink(adminUser.token, {
47                     name: isWritable ? 'can_write' : 'can_read',
48                     link_class: 'permission',
49                     head_uuid: this.sharedGroup.uuid,
50                     tail_uuid: activeUser.user.uuid
51                 })
52                 cy.doSearch(`${this.sharedGroup.uuid}`);
53                 cy.get('[data-cy=side-panel-button]')
54                     .should('exist')
55                     .and(`${isWritable ? 'not.' : ''}be.disabled`);
56             })
57         })
58     })
59
60     it('disables the +NEW side panel button on appropriate sections', function() {
61         cy.loginAs(activeUser);
62         [
63             {url: '/shared-with-me', label: 'Shared with me'},
64             {url: '/public-favorites', label: 'Public Favorites'},
65             {url: '/favorites', label: 'My Favorites'},
66             {url: '/workflows', label: 'Workflows'},
67             {url: '/all_processes', label: 'All Processes'},
68             {url: '/trash', label: 'Trash'},
69         ].map(function(section) {
70             cy.visit(section.url);
71             cy.get('[data-cy=breadcrumb-first]')
72                 .should('contain', section.label);
73             cy.get('[data-cy=side-panel-button]')
74                 .should('exist')
75                 .and('be.disabled');
76         })
77     })
78 })