1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 describe('Project 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('creates a new project with multiple properties', function() {
32 const projName = `Test project (${Math.floor(999999 * Math.random())})`;
33 cy.loginAs(activeUser);
34 cy.get('[data-cy=side-panel-button]').click();
35 cy.get('[data-cy=side-panel-new-project]').click();
36 cy.get('[data-cy=form-dialog]')
37 .should('contain', 'New Project')
39 cy.get('[data-cy=name-field]').within(() => {
40 cy.get('input').type(projName);
44 // Key: Color (IDTAGCOLORS) - Value: Magenta (IDVALCOLORS3)
45 cy.get('[data-cy=form-dialog]').should('not.contain', 'Color: Magenta');
46 cy.get('[data-cy=resource-properties-form]').within(() => {
47 cy.get('[data-cy=property-field-key]').within(() => {
48 cy.get('input').type('Color');
50 cy.get('[data-cy=property-field-value]').within(() => {
51 cy.get('input').type('Magenta');
54 cy.get('[data-cy=property-field-value]').within(() => {
55 cy.get('input').type('Pink');
58 cy.get('[data-cy=property-field-value]').within(() => {
59 cy.get('input').type('Yellow');
63 // Confirm proper vocabulary labels are displayed on the UI.
64 cy.get('[data-cy=form-dialog]').should('contain', 'Color: Magenta');
65 cy.get('[data-cy=form-dialog]').should('contain', 'Color: Pink');
66 cy.get('[data-cy=form-dialog]').should('contain', 'Color: Yellow');
68 cy.get('[data-cy=resource-properties-form]').within(() => {
69 cy.get('[data-cy=property-field-key]').within(() => {
70 cy.get('input').focus();
72 cy.get('[data-cy=property-field-key]').should('not.contain', 'Color');
75 // Create project and confirm the properties' real values.
76 cy.get('[data-cy=form-submit-btn]').click();
77 cy.get('[data-cy=breadcrumb-last]').should('contain', projName);
78 cy.doRequest('GET', '/arvados/v1/groups', null, {
79 filters: `[["name", "=", "${projName}"], ["group_class", "=", "project"]]`,
81 .its('body.items').as('projects')
83 expect(this.projects).to.have.lengthOf(1);
84 expect(this.projects[0].properties).to.deep.equal(
85 {IDTAGCOLORS: 'IDVALCOLORS3'});
89 it('creates new project on home project and then a subproject inside it', function() {
90 const createProject = function(name, parentName) {
91 cy.get('[data-cy=side-panel-button]').click();
92 cy.get('[data-cy=side-panel-new-project]').click();
93 cy.get('[data-cy=form-dialog]')
94 .should('contain', 'New Project')
96 cy.get('[data-cy=parent-field]').within(() => {
97 cy.get('input').invoke('val').then((val) => {
98 expect(val).to.include(parentName);
101 cy.get('[data-cy=name-field]').within(() => {
102 cy.get('input').type(name);
105 cy.get('[data-cy=form-submit-btn]').click();
108 cy.loginAs(activeUser);
109 cy.goToPath(`/projects/${activeUser.user.uuid}`);
110 cy.get('[data-cy=breadcrumb-first]').should('contain', 'Projects');
111 cy.get('[data-cy=breadcrumb-last]').should('not.exist');
112 // Create new project
113 const projName = `Test project (${Math.floor(999999 * Math.random())})`;
114 createProject(projName, 'Home project');
115 // Confirm that the user was taken to the newly created thing
116 cy.get('[data-cy=form-dialog]').should('not.exist');
117 cy.get('[data-cy=breadcrumb-first]').should('contain', 'Projects');
118 cy.get('[data-cy=breadcrumb-last]').should('contain', projName);
119 // Create a subproject
120 const subProjName = `Test project (${Math.floor(999999 * Math.random())})`;
121 createProject(subProjName, projName);
122 cy.get('[data-cy=form-dialog]').should('not.exist');
123 cy.get('[data-cy=breadcrumb-first]').should('contain', 'Projects');
124 cy.get('[data-cy=breadcrumb-last]').should('contain', subProjName);
127 it('navigates to the parent project after trashing the one being displayed', function() {
128 cy.createGroup(activeUser.token, {
129 name: `Test root project ${Math.floor(Math.random() * 999999)}`,
130 group_class: 'project',
131 }).as('testRootProject').then(function() {
132 cy.createGroup(activeUser.token, {
133 name : `Test subproject ${Math.floor(Math.random() * 999999)}`,
134 group_class: 'project',
135 owner_uuid: this.testRootProject.uuid,
136 }).as('testSubProject');
138 cy.getAll('@testRootProject', '@testSubProject').then(function([testRootProject, testSubProject]) {
139 cy.loginAs(activeUser);
141 // Go to subproject and trash it.
142 cy.goToPath(`/projects/${testSubProject.uuid}`);
143 cy.get('[data-cy=side-panel-tree]').should('contain', testSubProject.name);
144 cy.get('[data-cy=breadcrumb-last]')
145 .should('contain', testSubProject.name)
147 cy.get('[data-cy=context-menu]').contains('Move to trash').click();
149 // Confirm that the parent project should be displayed.
150 cy.get('[data-cy=breadcrumb-last]').should('contain', testRootProject.name);
151 cy.url().should('contain', `/projects/${testRootProject.uuid}`);
152 cy.get('[data-cy=side-panel-tree]').should('not.contain', testSubProject.name);
154 // Checks for bugfix #17637.
155 cy.get('[data-cy=not-found-content]').should('not.exist');
156 cy.get('[data-cy=not-found-page]').should('not.exist');
160 it('navigates to the root project after trashing the parent of the one being displayed', function() {
161 cy.createGroup(activeUser.token, {
162 name: `Test root project ${Math.floor(Math.random() * 999999)}`,
163 group_class: 'project',
164 }).as('testRootProject').then(function() {
165 cy.createGroup(activeUser.token, {
166 name : `Test subproject ${Math.floor(Math.random() * 999999)}`,
167 group_class: 'project',
168 owner_uuid: this.testRootProject.uuid,
169 }).as('testSubProject').then(function() {
170 cy.createGroup(activeUser.token, {
171 name : `Test sub subproject ${Math.floor(Math.random() * 999999)}`,
172 group_class: 'project',
173 owner_uuid: this.testSubProject.uuid,
174 }).as('testSubSubProject');
177 cy.getAll('@testRootProject', '@testSubProject', '@testSubSubProject').then(function([testRootProject, testSubProject, testSubSubProject]) {
178 cy.loginAs(activeUser);
180 // Go to innermost project and trash its parent.
181 cy.goToPath(`/projects/${testSubSubProject.uuid}`);
182 cy.get('[data-cy=side-panel-tree]').should('contain', testSubSubProject.name);
183 cy.get('[data-cy=breadcrumb-last]').should('contain', testSubSubProject.name);
184 cy.get('[data-cy=side-panel-tree]')
185 .contains(testSubProject.name)
187 cy.get('[data-cy=context-menu]').contains('Move to trash').click();
189 // Confirm that the trashed project's parent should be displayed.
190 cy.get('[data-cy=breadcrumb-last]').should('contain', testRootProject.name);
191 cy.url().should('contain', `/projects/${testRootProject.uuid}`);
192 cy.get('[data-cy=side-panel-tree]').should('not.contain', testSubProject.name);
193 cy.get('[data-cy=side-panel-tree]').should('not.contain', testSubSubProject.name);
195 // Checks for bugfix #17637.
196 cy.get('[data-cy=not-found-content]').should('not.exist');
197 cy.get('[data-cy=not-found-page]').should('not.exist');
201 it('shows details panel when clicking on the info icon', () => {
202 cy.createGroup(activeUser.token, {
203 name: `Test root project ${Math.floor(Math.random() * 999999)}`,
204 group_class: 'project',
205 }).as('testRootProject').then(function(testRootProject) {
206 cy.loginAs(activeUser);
208 cy.get('[data-cy=side-panel-tree]').contains(testRootProject.name).click();
210 cy.get('[data-cy=additional-info-icon]').click();
212 cy.contains(testRootProject.uuid).should('exist');
216 it('clears search input when changing project', () => {
217 cy.createGroup(activeUser.token, {
218 name: `Test root project ${Math.floor(Math.random() * 999999)}`,
219 group_class: 'project',
220 }).as('testProject1').then((testProject1) => {
221 cy.shareWith(adminUser.token, activeUser.user.uuid, testProject1.uuid, 'can_write');
224 cy.getAll('@testProject1').then(function([testProject1]) {
225 cy.loginAs(activeUser);
227 cy.get('[data-cy=side-panel-tree]').contains(testProject1.name).click();
229 cy.get('[data-cy=search-input] input').type('test123');
231 cy.get('[data-cy=side-panel-tree]').contains('Projects').click();
233 cy.get('[data-cy=search-input] input').should('not.have.value', 'test123');
237 it('opens advanced popup for project with username', () => {
238 const projectName = `Test project ${Math.floor(Math.random() * 999999)}`;
240 cy.createGroup(adminUser.token, {
242 group_class: 'project',
245 cy.getAll('@mainProject')
246 .then(function ([mainProject]) {
247 cy.loginAs(adminUser);
249 cy.get('[data-cy=side-panel-tree]').contains('Groups').click();
251 cy.get('[data-cy=uuid]').eq(0).invoke('text').then(uuid => {
252 cy.createLink(adminUser.token, {
254 link_class: 'permission',
255 head_uuid: mainProject.uuid,
259 cy.createLink(adminUser.token, {
261 link_class: 'permission',
262 head_uuid: mainProject.uuid,
263 tail_uuid: activeUser.user.uuid
266 cy.get('[data-cy=side-panel-tree]').contains('Projects').click();
268 cy.get('main').contains(projectName).rightclick();
270 cy.get('[data-cy=context-menu]').contains('Advanced').click();
272 cy.get('[role=tablist]').contains('METADATA').click();
274 cy.get('td').contains(uuid).should('exist');
276 cy.get('td').contains(activeUser.user.uuid).should('exist');