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}`);
81 cy.get("[data-cy=breadcrumb-last]").should('exist', { timeout: 10000 });
82 cy.get('[data-cy=breadcrumb-last]').should('contain', 'my-favorite-filter-group');
84 cy.get('[data-cy=side-panel-button]')
90 it('can edit project in side panel', () => {
92 owningUser: activeUser,
93 targetUser: activeUser,
94 projectName: 'mySharedWritableProject',
99 cy.getAll('@mySharedWritableProject')
100 .then(function ([mySharedWritableProject]) {
101 cy.loginAs(activeUser);
103 cy.get('[data-cy=side-panel-tree]').contains('Projects').click();
105 const newProjectName = `New project name ${mySharedWritableProject.name}`;
106 const newProjectDescription = `New project description ${mySharedWritableProject.name}`;
108 cy.testEditProjectOrCollection('[data-cy=side-panel-tree]', mySharedWritableProject.name, newProjectName, newProjectDescription);
112 it('side panel react to refresh when project data changes', () => {
113 const project = 'writableProject';
116 owningUser: activeUser,
117 targetUser: activeUser,
118 projectName: project,
120 addToFavorites: false
123 cy.getAll('@writableProject').then(function ([writableProject]) {
124 cy.loginAs(activeUser);
125 cy.get('[data-cy=side-panel-tree]')
126 .contains('Projects').click();
127 cy.get('[data-cy=side-panel-tree]')
128 .contains(writableProject.name).should('exist');
129 cy.trashGroup(activeUser.token, writableProject.uuid).then(() => {
130 cy.contains('Refresh').click();
131 cy.contains(writableProject.name).should('not.exist');
136 it('collapses and un-collapses', () => {
138 cy.loginAs(activeUser)
139 cy.get('[data-cy=side-panel-tree]').should('exist')
140 cy.get('[data-cy=side-panel-toggle]').click()
141 cy.get('[data-cy=side-panel-tree]').should('not.exist')
142 cy.get('[data-cy=side-panel-collapsed]').should('exist')
143 cy.get('[data-cy=side-panel-toggle]').click()
144 cy.get('[data-cy=side-panel-tree]').should('exist')
145 cy.get('[data-cy=side-panel-collapsed]').should('not.exist')
148 it('can navigate from collapsed panel', () => {
150 const collapsedCategories = {
151 'shared-with-me': '/shared-with-me',
152 'public-favorites': '/public-favorites',
153 'my-favorites': '/favorites',
155 'all-processes': '/all_processes',
157 'shell-access': '/virtual-machines-user',
158 'home-projects': `/projects/${activeUser.user.uuid}`,
161 cy.loginAs(activeUser)
162 cy.get('[data-cy=side-panel-tree]').should('exist')
163 cy.get('[data-cy=side-panel-toggle]').click()
164 cy.get('[data-cy=side-panel-collapsed]').should('exist')
166 for (const cat in collapsedCategories) {
167 cy.get(`[data-cy=collapsed-${cat}]`).should('exist').click()
168 cy.url().should('include', collapsedCategories[cat])