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 // Pink is not in the test vocab
86 {IDTAGCOLORS: ['IDVALCOLORS3', 'Pink', 'IDVALCOLORS1']});
89 // Open project edit via breadcrumbs
90 cy.get('[data-cy=breadcrumbs]').contains(projName).rightclick();
91 cy.get('[data-cy=context-menu]').contains('Edit').click();
92 cy.get('[data-cy=form-dialog]').within(() => {
93 cy.get('[data-cy=resource-properties-list]').within(() => {
94 cy.get('div[role=button]').contains('Color: Magenta');
95 cy.get('div[role=button]').contains('Color: Pink');
96 cy.get('div[role=button]').contains('Color: Yellow');
99 // Add another property
100 cy.get('[data-cy=resource-properties-form]').within(() => {
101 cy.get('[data-cy=property-field-key]').within(() => {
102 cy.get('input').type('Animal');
104 cy.get('[data-cy=property-field-value]').within(() => {
105 cy.get('input').type('Dog');
109 cy.get('[data-cy=form-submit-btn]').click();
110 // Reopen edit via breadcrumbs and verify properties
111 cy.get('[data-cy=breadcrumbs]').contains(projName).rightclick();
112 cy.get('[data-cy=context-menu]').contains('Edit').click();
113 cy.get('[data-cy=form-dialog]').within(() => {
114 cy.get('[data-cy=resource-properties-list]').within(() => {
115 cy.get('div[role=button]').contains('Color: Magenta');
116 cy.get('div[role=button]').contains('Color: Pink');
117 cy.get('div[role=button]').contains('Color: Yellow');
118 cy.get('div[role=button]').contains('Animal: Dog');
123 it('creates new project on home project and then a subproject inside it', function() {
124 const createProject = function(name, parentName) {
125 cy.get('[data-cy=side-panel-button]').click();
126 cy.get('[data-cy=side-panel-new-project]').click();
127 cy.get('[data-cy=form-dialog]')
128 .should('contain', 'New Project')
130 cy.get('[data-cy=parent-field]').within(() => {
131 cy.get('input').invoke('val').then((val) => {
132 expect(val).to.include(parentName);
135 cy.get('[data-cy=name-field]').within(() => {
136 cy.get('input').type(name);
139 cy.get('[data-cy=form-submit-btn]').click();
142 cy.loginAs(activeUser);
143 cy.goToPath(`/projects/${activeUser.user.uuid}`);
144 cy.get('[data-cy=breadcrumb-first]').should('contain', 'Projects');
145 cy.get('[data-cy=breadcrumb-last]').should('not.exist');
146 // Create new project
147 const projName = `Test project (${Math.floor(999999 * Math.random())})`;
148 createProject(projName, 'Home project');
149 // Confirm that the user was taken to the newly created thing
150 cy.get('[data-cy=form-dialog]').should('not.exist');
151 cy.get('[data-cy=breadcrumb-first]').should('contain', 'Projects');
152 cy.get('[data-cy=breadcrumb-last]').should('contain', projName);
153 // Create a subproject
154 const subProjName = `Test project (${Math.floor(999999 * Math.random())})`;
155 createProject(subProjName, projName);
156 cy.get('[data-cy=form-dialog]').should('not.exist');
157 cy.get('[data-cy=breadcrumb-first]').should('contain', 'Projects');
158 cy.get('[data-cy=breadcrumb-last]').should('contain', subProjName);
161 it('navigates to the parent project after trashing the one being displayed', function() {
162 cy.createGroup(activeUser.token, {
163 name: `Test root project ${Math.floor(Math.random() * 999999)}`,
164 group_class: 'project',
165 }).as('testRootProject').then(function() {
166 cy.createGroup(activeUser.token, {
167 name : `Test subproject ${Math.floor(Math.random() * 999999)}`,
168 group_class: 'project',
169 owner_uuid: this.testRootProject.uuid,
170 }).as('testSubProject');
172 cy.getAll('@testRootProject', '@testSubProject').then(function([testRootProject, testSubProject]) {
173 cy.loginAs(activeUser);
175 // Go to subproject and trash it.
176 cy.goToPath(`/projects/${testSubProject.uuid}`);
177 cy.get('[data-cy=side-panel-tree]').should('contain', testSubProject.name);
178 cy.get('[data-cy=breadcrumb-last]')
179 .should('contain', testSubProject.name)
181 cy.get('[data-cy=context-menu]').contains('Move to trash').click();
183 // Confirm that the parent project should be displayed.
184 cy.get('[data-cy=breadcrumb-last]').should('contain', testRootProject.name);
185 cy.url().should('contain', `/projects/${testRootProject.uuid}`);
186 cy.get('[data-cy=side-panel-tree]').should('not.contain', testSubProject.name);
188 // Checks for bugfix #17637.
189 cy.get('[data-cy=not-found-content]').should('not.exist');
190 cy.get('[data-cy=not-found-page]').should('not.exist');
194 it('navigates to the root project after trashing the parent of the one being displayed', function() {
195 cy.createGroup(activeUser.token, {
196 name: `Test root project ${Math.floor(Math.random() * 999999)}`,
197 group_class: 'project',
198 }).as('testRootProject').then(function() {
199 cy.createGroup(activeUser.token, {
200 name : `Test subproject ${Math.floor(Math.random() * 999999)}`,
201 group_class: 'project',
202 owner_uuid: this.testRootProject.uuid,
203 }).as('testSubProject').then(function() {
204 cy.createGroup(activeUser.token, {
205 name : `Test sub subproject ${Math.floor(Math.random() * 999999)}`,
206 group_class: 'project',
207 owner_uuid: this.testSubProject.uuid,
208 }).as('testSubSubProject');
211 cy.getAll('@testRootProject', '@testSubProject', '@testSubSubProject').then(function([testRootProject, testSubProject, testSubSubProject]) {
212 cy.loginAs(activeUser);
214 // Go to innermost project and trash its parent.
215 cy.goToPath(`/projects/${testSubSubProject.uuid}`);
216 cy.get('[data-cy=side-panel-tree]').should('contain', testSubSubProject.name);
217 cy.get('[data-cy=breadcrumb-last]').should('contain', testSubSubProject.name);
218 cy.get('[data-cy=side-panel-tree]')
219 .contains(testSubProject.name)
221 cy.get('[data-cy=context-menu]').contains('Move to trash').click();
223 // Confirm that the trashed project's parent should be displayed.
224 cy.get('[data-cy=breadcrumb-last]').should('contain', testRootProject.name);
225 cy.url().should('contain', `/projects/${testRootProject.uuid}`);
226 cy.get('[data-cy=side-panel-tree]').should('not.contain', testSubProject.name);
227 cy.get('[data-cy=side-panel-tree]').should('not.contain', testSubSubProject.name);
229 // Checks for bugfix #17637.
230 cy.get('[data-cy=not-found-content]').should('not.exist');
231 cy.get('[data-cy=not-found-page]').should('not.exist');
235 it('shows details panel when clicking on the info icon', () => {
236 cy.createGroup(activeUser.token, {
237 name: `Test root project ${Math.floor(Math.random() * 999999)}`,
238 group_class: 'project',
239 }).as('testRootProject').then(function(testRootProject) {
240 cy.loginAs(activeUser);
242 cy.get('[data-cy=side-panel-tree]').contains(testRootProject.name).click();
244 cy.get('[data-cy=additional-info-icon]').click();
246 cy.contains(testRootProject.uuid).should('exist');
250 it('clears search input when changing project', () => {
251 cy.createGroup(activeUser.token, {
252 name: `Test root project ${Math.floor(Math.random() * 999999)}`,
253 group_class: 'project',
254 }).as('testProject1').then((testProject1) => {
255 cy.shareWith(adminUser.token, activeUser.user.uuid, testProject1.uuid, 'can_write');
258 cy.getAll('@testProject1').then(function([testProject1]) {
259 cy.loginAs(activeUser);
261 cy.get('[data-cy=side-panel-tree]').contains(testProject1.name).click();
263 cy.get('[data-cy=search-input] input').type('test123');
265 cy.get('[data-cy=side-panel-tree]').contains('Projects').click();
267 cy.get('[data-cy=search-input] input').should('not.have.value', 'test123');
271 it('opens advanced popup for project with username', () => {
272 const projectName = `Test project ${Math.floor(Math.random() * 999999)}`;
274 cy.createGroup(adminUser.token, {
276 group_class: 'project',
279 cy.getAll('@mainProject')
280 .then(function ([mainProject]) {
281 cy.loginAs(adminUser);
283 cy.get('[data-cy=side-panel-tree]').contains('Groups').click();
285 cy.get('[data-cy=uuid]').eq(0).invoke('text').then(uuid => {
286 cy.createLink(adminUser.token, {
288 link_class: 'permission',
289 head_uuid: mainProject.uuid,
293 cy.createLink(adminUser.token, {
295 link_class: 'permission',
296 head_uuid: mainProject.uuid,
297 tail_uuid: activeUser.user.uuid
300 cy.get('[data-cy=side-panel-tree]').contains('Projects').click();
302 cy.get('main').contains(projectName).rightclick();
304 cy.get('[data-cy=context-menu]').contains('Advanced').click();
306 cy.get('[role=tablist]').contains('METADATA').click();
308 cy.get('td').contains(uuid).should('exist');
310 cy.get('td').contains(activeUser.user.uuid).should('exist');
315 describe('Frozen projects', () => {
317 cy.createGroup(activeUser.token, {
318 name: `Main project ${Math.floor(Math.random() * 999999)}`,
319 group_class: 'project',
320 }).as('mainProject');
322 cy.createGroup(adminUser.token, {
323 name: `Admin project ${Math.floor(Math.random() * 999999)}`,
324 group_class: 'project',
325 }).as('adminProject').then((mainProject) => {
326 cy.shareWith(adminUser.token, activeUser.user.uuid, mainProject.uuid, 'can_write');
329 cy.get('@mainProject').then((mainProject) => {
330 cy.createGroup(adminUser.token, {
331 name : `Sub project ${Math.floor(Math.random() * 999999)}`,
332 group_class: 'project',
333 owner_uuid: mainProject.uuid,
336 cy.createCollection(adminUser.token, {
337 name: `Main collection ${Math.floor(Math.random() * 999999)}`,
338 owner_uuid: mainProject.uuid,
339 manifest_text: "./subdir 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo\n. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
340 }).as('mainCollection');
344 it('should be able to froze own project', () => {
345 cy.getAll('@mainProject').then(([mainProject]) => {
346 cy.loginAs(activeUser);
348 cy.get('[data-cy=project-panel]').contains(mainProject.name).rightclick();
350 cy.get('[data-cy=context-menu]').contains('Freeze').click();
352 cy.get('[data-cy=project-panel]').contains(mainProject.name).rightclick();
354 cy.get('[data-cy=context-menu]').contains('Freeze').should('not.exist');
358 it('should not be able to modify items within the frozen project', () => {
359 cy.getAll('@mainProject', '@mainCollection').then(([mainProject, mainCollection]) => {
360 cy.loginAs(activeUser);
362 cy.get('[data-cy=project-panel]').contains(mainProject.name).rightclick();
364 cy.get('[data-cy=context-menu]').contains('Freeze').click();
366 cy.get('[data-cy=project-panel]').contains(mainProject.name).click();
368 cy.get('[data-cy=project-panel]').contains(mainCollection.name).rightclick();
370 cy.get('[data-cy=context-menu]').contains('Move to trash').should('not.exist');
374 it('should be able to froze not owned project', () => {
375 cy.getAll('@adminProject').then(([adminProject]) => {
376 cy.loginAs(activeUser);
378 cy.get('[data-cy=side-panel-tree]').contains('Shared with me').click();
380 cy.get('main').contains(adminProject.name).rightclick();
382 cy.get('[data-cy=context-menu]').contains('Freeze').should('not.exist');
386 it('should be able to unfroze project if user is an admin', () => {
387 cy.getAll('@adminProject').then(([adminProject]) => {
388 cy.loginAs(adminUser);
390 cy.get('main').contains(adminProject.name).rightclick();
392 cy.get('[data-cy=context-menu]').contains('Freeze').click();
396 cy.get('main').contains(adminProject.name).rightclick();
398 cy.get('[data-cy=context-menu]').contains('Unfreeze').click();
400 cy.get('main').contains(adminProject.name).rightclick();
402 cy.get('[data-cy=context-menu]').contains('Freeze').should('exist');