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 a project without and with description', function() {
124 const projName = `Test project (${Math.floor(999999 * Math.random())})`;
125 cy.loginAs(activeUser);
128 cy.get('[data-cy=side-panel-button]').click();
129 cy.get('[data-cy=side-panel-new-project]').click();
130 cy.get('[data-cy=form-dialog]')
131 .should('contain', 'New Project')
133 cy.get('[data-cy=name-field]').within(() => {
134 cy.get('input').type(projName);
137 cy.get('[data-cy=form-submit-btn]').click();
139 const editProjectDescription = (name, type) => {
140 cy.get('[data-cy=side-panel-tree]').contains('Home Projects').click();
141 cy.get('[data-cy=project-panel] tbody tr').contains(name).rightclick();
142 cy.get('[data-cy=context-menu]').contains('Edit').click();
143 cy.get('[data-cy=form-dialog]').within(() => {
144 cy.get('div[contenteditable=true]')
147 cy.get('[data-cy=form-submit-btn]').click();
151 const verifyProjectDescription = (name, description) => {
152 cy.doRequest('GET', '/arvados/v1/groups', null, {
153 filters: `[["name", "=", "${name}"], ["group_class", "=", "project"]]`,
155 .its('body.items').as('projects')
157 expect(this.projects).to.have.lengthOf(1);
158 expect(this.projects[0].description).to.equal(description);
163 editProjectDescription(projName, 'Test description');
165 // Check description is set
166 verifyProjectDescription(projName, "<p>Test description</p>");
169 editProjectDescription(projName, '{selectall}{backspace}');
171 // Check description is null
172 verifyProjectDescription(projName, null);
174 // Set description to contain whitespace
175 editProjectDescription(projName, '{selectall}{backspace} x');
176 editProjectDescription(projName, '{backspace}');
178 // Check description is null
179 verifyProjectDescription(projName, null);
183 it('creates new project on home project and then a subproject inside it', function() {
184 const createProject = function(name, parentName) {
185 cy.get('[data-cy=side-panel-button]').click();
186 cy.get('[data-cy=side-panel-new-project]').click();
187 cy.get('[data-cy=form-dialog]')
188 .should('contain', 'New Project')
190 cy.get('[data-cy=parent-field]').within(() => {
191 cy.get('input').invoke('val').then((val) => {
192 expect(val).to.include(parentName);
195 cy.get('[data-cy=name-field]').within(() => {
196 cy.get('input').type(name);
199 cy.get('[data-cy=form-submit-btn]').click();
202 cy.loginAs(activeUser);
203 cy.goToPath(`/projects/${activeUser.user.uuid}`);
204 cy.get('[data-cy=breadcrumb-first]').should('contain', 'Projects');
205 cy.get('[data-cy=breadcrumb-last]').should('not.exist');
206 // Create new project
207 const projName = `Test project (${Math.floor(999999 * Math.random())})`;
208 createProject(projName, 'Home project');
209 // Confirm that the user was taken to the newly created thing
210 cy.get('[data-cy=form-dialog]').should('not.exist');
211 cy.get('[data-cy=breadcrumb-first]').should('contain', 'Projects');
212 cy.get('[data-cy=breadcrumb-last]').should('contain', projName);
213 // Create a subproject
214 const subProjName = `Test project (${Math.floor(999999 * Math.random())})`;
215 createProject(subProjName, projName);
216 cy.get('[data-cy=form-dialog]').should('not.exist');
217 cy.get('[data-cy=breadcrumb-first]').should('contain', 'Projects');
218 cy.get('[data-cy=breadcrumb-last]').should('contain', subProjName);
221 it('attempts to use a preexisting name creating a project', function() {
222 const name = `Test project ${Math.floor(Math.random() * 999999)}`;
223 cy.createGroup(activeUser.token, {
225 group_class: 'project',
227 cy.loginAs(activeUser);
228 cy.goToPath(`/projects/${activeUser.user.uuid}`);
230 // Attempt to create new collection with a duplicate name
231 cy.get('[data-cy=side-panel-button]').click();
232 cy.get('[data-cy=side-panel-new-project]').click();
233 cy.get('[data-cy=form-dialog]')
234 .should('contain', 'New Project')
236 cy.get('[data-cy=name-field]').within(() => {
237 cy.get('input').type(name);
239 cy.get('[data-cy=form-submit-btn]').click();
241 // Error message should display, allowing editing the name
242 cy.get('[data-cy=form-dialog]').should('exist')
243 .and('contain', 'Project with the same name already exists')
245 cy.get('[data-cy=name-field]').within(() => {
246 cy.get('input').type(' renamed');
248 cy.get('[data-cy=form-submit-btn]').click();
250 cy.get('[data-cy=form-dialog]').should('not.exist');
253 it('navigates to the parent project after trashing the one being displayed', function() {
254 cy.createGroup(activeUser.token, {
255 name: `Test root project ${Math.floor(Math.random() * 999999)}`,
256 group_class: 'project',
257 }).as('testRootProject').then(function() {
258 cy.createGroup(activeUser.token, {
259 name : `Test subproject ${Math.floor(Math.random() * 999999)}`,
260 group_class: 'project',
261 owner_uuid: this.testRootProject.uuid,
262 }).as('testSubProject');
264 cy.getAll('@testRootProject', '@testSubProject').then(function([testRootProject, testSubProject]) {
265 cy.loginAs(activeUser);
267 // Go to subproject and trash it.
268 cy.goToPath(`/projects/${testSubProject.uuid}`);
269 cy.get('[data-cy=side-panel-tree]').should('contain', testSubProject.name);
270 cy.get('[data-cy=breadcrumb-last]')
271 .should('contain', testSubProject.name)
273 cy.get('[data-cy=context-menu]').contains('Move to trash').click();
275 // Confirm that the parent project should be displayed.
276 cy.get('[data-cy=breadcrumb-last]').should('contain', testRootProject.name);
277 cy.url().should('contain', `/projects/${testRootProject.uuid}`);
278 cy.get('[data-cy=side-panel-tree]').should('not.contain', testSubProject.name);
280 // Checks for bugfix #17637.
281 cy.get('[data-cy=not-found-content]').should('not.exist');
282 cy.get('[data-cy=not-found-page]').should('not.exist');
286 it('resets the search box only when navigating out of the current project', function() {
287 const fooProjectNameA = `Test foo project ${Math.floor(Math.random() * 999999)}`;
288 const fooProjectNameB = `Test foo project ${Math.floor(Math.random() * 999999)}`;
289 const barProjectNameA = `Test bar project ${Math.floor(Math.random() * 999999)}`;
291 [fooProjectNameA, fooProjectNameB, barProjectNameA].forEach(projName => {
292 cy.createGroup(activeUser.token, {
294 group_class: 'project',
298 cy.loginAs(activeUser);
299 cy.get('[data-cy=project-panel]')
300 .should('contain', fooProjectNameA)
301 .and('contain', fooProjectNameB)
302 .and('contain', barProjectNameA);
304 cy.get('[data-cy=search-input]').type('foo');
305 cy.get('[data-cy=project-panel]')
306 .should('contain', fooProjectNameA)
307 .and('contain', fooProjectNameB)
308 .and('not.contain', barProjectNameA);
310 // Click on the table row to select it, search should remain the same.
311 cy.get(`p:contains(${fooProjectNameA})`)
312 .parent().parent().parent().parent().click();
313 cy.get('[data-cy=search-input] input').should('have.value', 'foo');
315 // Click to navigate to the project, search should be reset
316 cy.get(`p:contains(${fooProjectNameA})`).click();
317 cy.get('[data-cy=search-input] input').should('not.have.value', 'foo');
320 it('navigates to the root project after trashing the parent of the one being displayed', function() {
321 cy.createGroup(activeUser.token, {
322 name: `Test root project ${Math.floor(Math.random() * 999999)}`,
323 group_class: 'project',
324 }).as('testRootProject').then(function() {
325 cy.createGroup(activeUser.token, {
326 name : `Test subproject ${Math.floor(Math.random() * 999999)}`,
327 group_class: 'project',
328 owner_uuid: this.testRootProject.uuid,
329 }).as('testSubProject').then(function() {
330 cy.createGroup(activeUser.token, {
331 name : `Test sub subproject ${Math.floor(Math.random() * 999999)}`,
332 group_class: 'project',
333 owner_uuid: this.testSubProject.uuid,
334 }).as('testSubSubProject');
337 cy.getAll('@testRootProject', '@testSubProject', '@testSubSubProject').then(function([testRootProject, testSubProject, testSubSubProject]) {
338 cy.loginAs(activeUser);
340 // Go to innermost project and trash its parent.
341 cy.goToPath(`/projects/${testSubSubProject.uuid}`);
342 cy.get('[data-cy=side-panel-tree]').should('contain', testSubSubProject.name);
343 cy.get('[data-cy=breadcrumb-last]').should('contain', testSubSubProject.name);
344 cy.get('[data-cy=side-panel-tree]')
345 .contains(testSubProject.name)
347 cy.get('[data-cy=context-menu]').contains('Move to trash').click();
349 // Confirm that the trashed project's parent should be displayed.
350 cy.get('[data-cy=breadcrumb-last]').should('contain', testRootProject.name);
351 cy.url().should('contain', `/projects/${testRootProject.uuid}`);
352 cy.get('[data-cy=side-panel-tree]').should('not.contain', testSubProject.name);
353 cy.get('[data-cy=side-panel-tree]').should('not.contain', testSubSubProject.name);
355 // Checks for bugfix #17637.
356 cy.get('[data-cy=not-found-content]').should('not.exist');
357 cy.get('[data-cy=not-found-page]').should('not.exist');
361 it('shows details panel when clicking on the info icon', () => {
362 cy.createGroup(activeUser.token, {
363 name: `Test root project ${Math.floor(Math.random() * 999999)}`,
364 group_class: 'project',
365 }).as('testRootProject').then(function(testRootProject) {
366 cy.loginAs(activeUser);
368 cy.get('[data-cy=side-panel-tree]').contains(testRootProject.name).click();
370 cy.get('[data-cy=additional-info-icon]').click();
372 cy.contains(testRootProject.uuid).should('exist');
376 it('clears search input when changing project', () => {
377 cy.createGroup(activeUser.token, {
378 name: `Test root project ${Math.floor(Math.random() * 999999)}`,
379 group_class: 'project',
380 }).as('testProject1').then((testProject1) => {
381 cy.shareWith(adminUser.token, activeUser.user.uuid, testProject1.uuid, 'can_write');
384 cy.getAll('@testProject1').then(function([testProject1]) {
385 cy.loginAs(activeUser);
387 cy.get('[data-cy=side-panel-tree]').contains(testProject1.name).click();
389 cy.get('[data-cy=search-input] input').type('test123');
391 cy.get('[data-cy=side-panel-tree]').contains('Projects').click();
393 cy.get('[data-cy=search-input] input').should('not.have.value', 'test123');
397 it('opens advanced popup for project with username', () => {
398 const projectName = `Test project ${Math.floor(Math.random() * 999999)}`;
400 cy.createGroup(adminUser.token, {
402 group_class: 'project',
405 cy.getAll('@mainProject')
406 .then(function ([mainProject]) {
407 cy.loginAs(adminUser);
409 cy.get('[data-cy=side-panel-tree]').contains('Groups').click();
411 cy.get('[data-cy=uuid]').eq(0).invoke('text').then(uuid => {
412 cy.createLink(adminUser.token, {
414 link_class: 'permission',
415 head_uuid: mainProject.uuid,
419 cy.createLink(adminUser.token, {
421 link_class: 'permission',
422 head_uuid: mainProject.uuid,
423 tail_uuid: activeUser.user.uuid
426 cy.get('[data-cy=side-panel-tree]').contains('Projects').click();
428 cy.get('main').contains(projectName).rightclick();
430 cy.get('[data-cy=context-menu]').contains('API Details').click();
432 cy.get('[role=tablist]').contains('METADATA').click();
434 cy.get('td').contains(uuid).should('exist');
436 cy.get('td').contains(activeUser.user.uuid).should('exist');
441 describe('Frozen projects', () => {
443 cy.createGroup(activeUser.token, {
444 name: `Main project ${Math.floor(Math.random() * 999999)}`,
445 group_class: 'project',
446 }).as('mainProject');
448 cy.createGroup(adminUser.token, {
449 name: `Admin project ${Math.floor(Math.random() * 999999)}`,
450 group_class: 'project',
451 }).as('adminProject').then((mainProject) => {
452 cy.shareWith(adminUser.token, activeUser.user.uuid, mainProject.uuid, 'can_write');
455 cy.get('@mainProject').then((mainProject) => {
456 cy.createGroup(adminUser.token, {
457 name : `Sub project ${Math.floor(Math.random() * 999999)}`,
458 group_class: 'project',
459 owner_uuid: mainProject.uuid,
462 cy.createCollection(adminUser.token, {
463 name: `Main collection ${Math.floor(Math.random() * 999999)}`,
464 owner_uuid: mainProject.uuid,
465 manifest_text: "./subdir 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo\n. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
466 }).as('mainCollection');
470 it('should be able to froze own project', () => {
471 cy.getAll('@mainProject').then(([mainProject]) => {
472 cy.loginAs(activeUser);
474 cy.get('[data-cy=project-panel]').contains(mainProject.name).rightclick();
476 cy.get('[data-cy=context-menu]').contains('Freeze').click();
478 cy.get('[data-cy=project-panel]').contains(mainProject.name).rightclick();
480 cy.get('[data-cy=context-menu]').contains('Freeze').should('not.exist');
484 it('should not be able to modify items within the frozen project', () => {
485 cy.getAll('@mainProject', '@mainCollection').then(([mainProject, mainCollection]) => {
486 cy.loginAs(activeUser);
488 cy.get('[data-cy=project-panel]').contains(mainProject.name).rightclick();
490 cy.get('[data-cy=context-menu]').contains('Freeze').click();
492 cy.get('[data-cy=project-panel]').contains(mainProject.name).click();
494 cy.get('[data-cy=project-panel]').contains(mainCollection.name).rightclick();
496 cy.get('[data-cy=context-menu]').contains('Move to trash').should('not.exist');
500 it('should be able to froze not owned project', () => {
501 cy.getAll('@adminProject').then(([adminProject]) => {
502 cy.loginAs(activeUser);
504 cy.get('[data-cy=side-panel-tree]').contains('Shared with me').click();
506 cy.get('main').contains(adminProject.name).rightclick();
508 cy.get('[data-cy=context-menu]').contains('Freeze').should('not.exist');
512 it('should be able to unfroze project if user is an admin', () => {
513 cy.getAll('@adminProject').then(([adminProject]) => {
514 cy.loginAs(adminUser);
516 cy.get('main').contains(adminProject.name).rightclick();
518 cy.get('[data-cy=context-menu]').contains('Freeze').click();
522 cy.get('main').contains(adminProject.name).rightclick();
524 cy.get('[data-cy=context-menu]').contains('Unfreeze').click();
526 cy.get('main').contains(adminProject.name).rightclick();
528 cy.get('[data-cy=context-menu]').contains('Freeze').should('exist');
533 it('copies project URL to clipboard', () => {
534 const projectName = `Test project (${Math.floor(999999 * Math.random())})`;
536 cy.loginAs(activeUser);
537 cy.get('[data-cy=side-panel-button]').click();
538 cy.get('[data-cy=side-panel-new-project]').click();
539 cy.get('[data-cy=form-dialog]')
540 .should('contain', 'New Project')
542 cy.get('[data-cy=name-field]').within(() => {
543 cy.get('input').type(projectName);
545 cy.get('[data-cy=form-submit-btn]').click();
547 cy.get('[data-cy=form-dialog]').should("not.exist");
548 cy.get('[data-cy=side-panel-tree]').contains('Projects').click();
549 cy.get('[data-cy=project-panel]').contains(projectName).should('be.visible').rightclick();
550 cy.get('[data-cy=context-menu]').contains('Copy to clipboard').click();
551 cy.window().then((win) => (
552 win.navigator.clipboard.readText().then((text) => {
553 expect(text).to.match(/https\:\/\/localhost\:[0-9]+\/projects\/[a-z0-9]{5}-[a-z0-9]{5}-[a-z0-9]{15}/,);
559 it('sorts displayed items correctly', () => {
560 cy.loginAs(activeUser);
562 cy.get('[data-cy=project-panel] button[title="Select columns"]').click();
563 cy.get('div[role=presentation] ul > div[role=button]').contains('Date Created').click();
564 cy.get('div[role=presentation] ul > div[role=button]').contains('Trash at').click();
565 cy.get('div[role=presentation] ul > div[role=button]').contains('Delete at').click();
566 cy.get('div[role=presentation] > div[aria-hidden=true]').click();
568 cy.intercept({method: 'GET', url: '**/arvados/v1/groups/*/contents*'}).as('filteredQuery');
572 asc: "collections.name asc,container_requests.name asc,groups.name asc",
573 desc: "collections.name desc,container_requests.name desc,groups.name desc"
576 name: "Last Modified",
577 asc: "collections.modified_at asc,container_requests.modified_at asc,groups.modified_at asc",
578 desc: "collections.modified_at desc,container_requests.modified_at desc,groups.modified_at desc"
581 name: "Date Created",
582 asc: "collections.created_at asc,container_requests.created_at asc,groups.created_at asc",
583 desc: "collections.created_at desc,container_requests.created_at desc,groups.created_at desc"
588 asc: "collections.trash_at asc,container_requests.trash_at asc,groups.trash_at asc",
589 desc: "collections.trash_at desc,container_requests.trash_at desc,groups.trash_at desc"
594 asc: "collections.delete_at asc,container_requests.delete_at asc,groups.delete_at asc",
595 desc: "collections.delete_at desc,container_requests.delete_at desc,groups.delete_at desc"
598 ].forEach((test) => {
599 cy.get('[data-cy=project-panel] table thead th').contains(test.name).click();
600 cy.wait('@filteredQuery').then(interception => {
601 const searchParams = new URLSearchParams((new URL(interception.request.url).search));
602 expect(searchParams.get('order')).to.eq(test.asc);
604 cy.get('[data-cy=project-panel] table thead th').contains(test.name).click();
605 cy.wait('@filteredQuery').then(interception => {
606 const searchParams = new URLSearchParams((new URL(interception.request.url).search));
607 expect(searchParams.get('order')).to.eq(test.desc);