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.visit(`/projects/${activeUser.user.uuid}`);
34 cy.get('[data-cy=side-panel-button]')
36 .and('not.be.disabled');
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
52 cy.visit(`/projects/${this.sharedGroup.uuid}`);
53 cy.get('[data-cy=side-panel-button]')
55 .and(`${isWritable ? 'not.' : ''}be.disabled`);
60 it('disables the +NEW side panel button on appropriate sections', function() {
61 cy.loginAs(activeUser);
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]')
79 it('creates new collection on home project', function() {
80 cy.loginAs(activeUser);
81 cy.visit(`/projects/${activeUser.user.uuid}`);
82 cy.get('[data-cy=breadcrumb-first]').should('contain', 'Projects');
83 cy.get('[data-cy=breadcrumb-last]').should('not.exist');
84 // Create new collection
85 cy.get('[data-cy=side-panel-button]').click();
86 cy.get('[data-cy=side-panel-new-collection]').click();
87 const collName = `Test collection (${Math.floor(999999 * Math.random())})`;
88 cy.get('[data-cy=form-dialog]')
89 .should('contain', 'New collection')
91 cy.get('[data-cy=parent-field]').within(() => {
92 cy.get('input').should('have.value', 'Home project');
94 cy.get('[data-cy=name-field]').within(() => {
95 cy.get('input').type(collName);
98 cy.get('[data-cy=form-submit-btn]').click();
99 // Confirm that the user was taken to the newly created thing
100 cy.get('[data-cy=form-dialog]').should('not.exist');
101 cy.get('[data-cy=breadcrumb-first]').should('contain', 'Projects');
102 cy.get('[data-cy=breadcrumb-last]').should('contain', collName);
105 it('creates new project on home project and then a subproject inside it', function() {
106 const createProject = function(name, parentName) {
107 cy.get('[data-cy=side-panel-button]').click();
108 cy.get('[data-cy=side-panel-new-project]').click();
109 cy.get('[data-cy=form-dialog]')
110 .should('contain', 'New project')
112 cy.get('[data-cy=parent-field]').within(() => {
113 cy.get('input').invoke('val').then((val) => {
114 expect(val).to.include(parentName);
117 cy.get('[data-cy=name-field]').within(() => {
118 cy.get('input').type(name);
121 cy.get('[data-cy=form-submit-btn]').click();
124 cy.loginAs(activeUser);
125 cy.visit(`/projects/${activeUser.user.uuid}`);
126 cy.get('[data-cy=breadcrumb-first]').should('contain', 'Projects');
127 cy.get('[data-cy=breadcrumb-last]').should('not.exist');
128 // Create new project
129 const projName = `Test project (${Math.floor(999999 * Math.random())})`;
130 createProject(projName, 'Home project');
131 // Confirm that the user was taken to the newly created thing
132 cy.get('[data-cy=form-dialog]').should('not.exist');
133 cy.get('[data-cy=breadcrumb-first]').should('contain', 'Projects');
134 cy.get('[data-cy=breadcrumb-last]').should('contain', projName);
135 // Create a subproject
136 const subProjName = `Test project (${Math.floor(999999 * Math.random())})`;
137 createProject(subProjName, projName);
138 cy.get('[data-cy=form-dialog]').should('not.exist');
139 cy.get('[data-cy=breadcrumb-first]').should('contain', 'Projects');
140 cy.get('[data-cy=breadcrumb-last]').should('contain', subProjName);