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 it('enables the +NEW side panel button on users home project', function() {
27 cy.loginAs(activeUser);
28 cy.get('[data-cy=side-panel-button]')
30 .and('not.be.disabled');
33 it('disables or enables the +NEW side panel button depending on project permissions', function() {
34 cy.loginAs(activeUser);
35 [true, false].map(function(isWritable) {
36 cy.createGroup(adminUser.token, {
37 name: `Test ${isWritable ? 'writable' : 'read-only'} project`,
38 group_class: 'project',
39 }).as('sharedGroup').then(function() {
40 cy.createLink(adminUser.token, {
41 name: isWritable ? 'can_write' : 'can_read',
42 link_class: 'permission',
43 head_uuid: this.sharedGroup.uuid,
44 tail_uuid: activeUser.user.uuid
46 cy.goToPath(`/projects/${this.sharedGroup.uuid}`);
47 cy.get('[data-cy=side-panel-button]')
49 .and(`${isWritable ? 'not.' : ''}be.disabled`);
54 it('disables the +NEW side panel button on appropriate sections', function() {
55 cy.loginAs(activeUser);
57 {url: '/shared-with-me', label: 'Shared with me'},
58 {url: '/public-favorites', label: 'Public Favorites'},
59 {url: '/favorites', label: 'My Favorites'},
60 {url: '/all_processes', label: 'All Processes'},
61 {url: '/trash', label: 'Trash'},
62 ].map(function(section) {
63 cy.waitForDom().goToPath(section.url);
64 cy.get('[data-cy=breadcrumb-first]')
65 .should('contain', section.label);
66 cy.get('[data-cy=side-panel-button]')
72 it('disables the +NEW side panel button when viewing filter group', function() {
73 cy.loginAs(adminUser);
74 cy.createGroup(adminUser.token, {
75 name: `my-favorite-filter-group`,
76 group_class: 'filter',
77 properties: {filters: []},
78 }).as('myFavoriteFilterGroup').then(function (myFavoriteFilterGroup) {
79 cy.goToPath(`/projects/${myFavoriteFilterGroup.uuid}`);
80 cy.get('[data-cy=breadcrumb-last]').should('contain', 'my-favorite-filter-group');
82 cy.get('[data-cy=side-panel-button]')
88 it('can edit project in side panel', () => {
90 owningUser: activeUser,
91 targetUser: activeUser,
92 projectName: 'mySharedWritableProject',
97 cy.getAll('@mySharedWritableProject')
98 .then(function ([mySharedWritableProject]) {
99 cy.loginAs(activeUser);
101 cy.get('[data-cy=side-panel-tree]').contains('Projects').click();
103 const newProjectName = `New project name ${mySharedWritableProject.name}`;
104 const newProjectDescription = `New project description ${mySharedWritableProject.name}`;
106 cy.testEditProjectOrCollection('[data-cy=side-panel-tree]', mySharedWritableProject.name, newProjectName, newProjectDescription);
110 it('side panel react to refresh when project data changes', () => {
111 const project = 'writableProject';
114 owningUser: activeUser,
115 targetUser: activeUser,
116 projectName: project,
118 addToFavorites: false
121 cy.getAll('@writableProject').then(function ([writableProject]) {
122 cy.loginAs(activeUser);
123 cy.get('[data-cy=side-panel-tree]')
124 .contains('Projects').click();
125 cy.get('[data-cy=side-panel-tree]')
126 .contains(writableProject.name).should('exist');
127 cy.trashGroup(activeUser.token, writableProject.uuid).then(() => {
128 cy.contains('Refresh').click();
129 cy.contains(writableProject.name).should('not.exist');
134 it('collapses and un-collapses', () => {
136 cy.loginAs(activeUser)
137 cy.get('[data-cy=side-panel-tree]').should('exist')
138 cy.get('[data-cy=side-panel-toggle]').click()
139 cy.get('[data-cy=side-panel-tree]').should('not.exist')
140 cy.get('[data-cy=side-panel-collapsed]').should('exist')
141 cy.get('[data-cy=side-panel-toggle]').click()
142 cy.get('[data-cy=side-panel-tree]').should('exist')
143 cy.get('[data-cy=side-panel-collapsed]').should('not.exist')
146 it('can navigate from collapsed panel', () => {
148 const collapsedCategories = {
149 'shared-with-me': '/shared-with-me',
150 'public-favorites': '/public-favorites',
151 'my-favorites': '/favorites',
153 'all-processes': '/all_processes',
155 'shell-access': '/virtual-machines-user',
156 'home-projects': `/projects/${activeUser.user.uuid}`,
159 cy.loginAs(activeUser)
160 cy.get('[data-cy=side-panel-tree]').should('exist')
161 cy.get('[data-cy=side-panel-toggle]').click()
162 cy.get('[data-cy=side-panel-collapsed]').should('exist')
164 for (const cat in collapsedCategories) {
165 cy.get(`[data-cy=collapsed-${cat}]`).should('exist').click()
166 cy.url().should('include', collapsedCategories[cat])