1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 describe('Side panel 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('user', 'Active', 'User', false, true)
20 .as('activeUser').then(function() {
21 activeUser = this.activeUser;
26 beforeEach(function() {
28 cy.clearLocalStorage()
31 it('enables the +NEW side panel button on users home project', function() {
32 cy.loginAs(activeUser);
33 cy.get('[data-cy=side-panel-button]')
35 .and('not.be.disabled');
38 it('disables or enables the +NEW side panel button depending on project permissions', function() {
39 cy.loginAs(activeUser);
40 [true, false].map(function(isWritable) {
41 cy.createGroup(adminUser.token, {
42 name: `Test ${isWritable ? 'writable' : 'read-only'} project`,
43 group_class: 'project',
44 }).as('sharedGroup').then(function() {
45 cy.createLink(adminUser.token, {
46 name: isWritable ? 'can_write' : 'can_read',
47 link_class: 'permission',
48 head_uuid: this.sharedGroup.uuid,
49 tail_uuid: activeUser.user.uuid
51 cy.goToPath(`/projects/${this.sharedGroup.uuid}`);
52 cy.get('[data-cy=side-panel-button]')
54 .and(`${isWritable ? 'not.' : ''}be.disabled`);
59 it('disables the +NEW side panel button on appropriate sections', function() {
60 cy.loginAs(activeUser);
62 {url: '/shared-with-me', label: 'Shared with me'},
63 {url: '/public-favorites', label: 'Public Favorites'},
64 {url: '/favorites', label: 'My Favorites'},
65 {url: '/workflows', label: 'Workflows'},
66 {url: '/all_processes', label: 'All Processes'},
67 {url: '/trash', label: 'Trash'},
68 ].map(function(section) {
69 cy.goToPath(section.url);
70 cy.get('[data-cy=breadcrumb-first]')
71 .should('contain', section.label);
72 cy.get('[data-cy=side-panel-button]')
78 it('disables the +NEW side panel button when viewing filter group', function() {
79 cy.loginAs(adminUser);
80 cy.createGroup(adminUser.token, {
81 name: `my-favorite-filter-group`,
82 group_class: 'filter',
83 properties: {filters: []},
84 }).as('myFavoriteFilterGroup').then(function (myFavoriteFilterGroup) {
85 cy.contains('Refresh').click();
86 cy.goToPath(`/projects/${myFavoriteFilterGroup.uuid}`);
87 cy.get('[data-cy=breadcrumb-last]').should('contain', 'my-favorite-filter-group');
89 cy.get('[data-cy=side-panel-button]')
95 it('can edit project in side panel', () => {
97 owningUser: activeUser,
98 targetUser: activeUser,
99 projectName: 'mySharedWritableProject',
101 addToFavorites: false
104 cy.getAll('@mySharedWritableProject')
105 .then(function ([mySharedWritableProject]) {
106 cy.loginAs(activeUser);
108 cy.get('[data-cy=side-panel-tree]').contains('Projects').click();
110 const newProjectName = `New project name ${mySharedWritableProject.name}`;
111 const newProjectDescription = `New project description ${mySharedWritableProject.name}`;
113 cy.testEditProjectOrCollection('[data-cy=side-panel-tree]', mySharedWritableProject.name, newProjectName, newProjectDescription);
117 it('side panel react to refresh when project data changes', () => {
118 const project = 'writableProject';
121 owningUser: activeUser,
122 targetUser: activeUser,
123 projectName: project,
125 addToFavorites: false
128 cy.getAll('@writableProject')
129 .then(function ([writableProject]) {
130 cy.loginAs(activeUser);
132 cy.get('[data-cy=side-panel-tree]').contains('Projects').click();
134 cy.get('[data-cy=side-panel-tree]').contains(writableProject.name).should('exist');
136 cy.trashGroup(activeUser.token, writableProject.uuid);
138 cy.contains('Refresh').click();
140 cy.contains(writableProject.name).should('not.exist');