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();
138 cy.get('[data-cy=form-dialog]').should('not.exist');
140 const editProjectDescription = (name, type) => {
141 cy.get('[data-cy=side-panel-tree]').contains('Home Projects').click();
142 cy.get('[data-cy=project-panel] tbody tr').contains(name).rightclick();
143 cy.get('[data-cy=context-menu]').contains('Edit').click();
144 cy.get('[data-cy=form-dialog]').within(() => {
145 cy.get('div[contenteditable=true]')
148 cy.get('[data-cy=form-submit-btn]').click();
152 const verifyProjectDescription = (name, description) => {
153 cy.doRequest('GET', '/arvados/v1/groups', null, {
154 filters: `[["name", "=", "${name}"], ["group_class", "=", "project"]]`,
156 .its('body.items').as('projects')
158 expect(this.projects).to.have.lengthOf(1);
159 expect(this.projects[0].description).to.equal(description);
164 editProjectDescription(projName, 'Test description');
166 // Check description is set
167 verifyProjectDescription(projName, "<p>Test description</p>");
170 editProjectDescription(projName, '{selectall}{backspace}');
172 // Check description is null
173 verifyProjectDescription(projName, null);
175 // Set description to contain whitespace
176 editProjectDescription(projName, '{selectall}{backspace} x');
177 editProjectDescription(projName, '{backspace}');
179 // Check description is null
180 verifyProjectDescription(projName, null);
184 it('creates new project on home project and then a subproject inside it', function() {
185 const createProject = function(name, parentName) {
186 cy.get('[data-cy=side-panel-button]').click();
187 cy.get('[data-cy=side-panel-new-project]').click();
188 cy.get('[data-cy=form-dialog]')
189 .should('contain', 'New Project')
191 cy.get('[data-cy=parent-field]').within(() => {
192 cy.get('input').invoke('val').then((val) => {
193 expect(val).to.include(parentName);
196 cy.get('[data-cy=name-field]').within(() => {
197 cy.get('input').type(name);
200 cy.get('[data-cy=form-submit-btn]').click();
203 cy.loginAs(activeUser);
204 cy.goToPath(`/projects/${activeUser.user.uuid}`);
205 cy.get('[data-cy=breadcrumb-first]').should('contain', 'Projects');
206 cy.get('[data-cy=breadcrumb-last]').should('not.exist');
207 // Create new project
208 const projName = `Test project (${Math.floor(999999 * Math.random())})`;
209 createProject(projName, 'Home project');
210 // Confirm that the user was taken to the newly created thing
211 cy.get('[data-cy=form-dialog]').should('not.exist');
212 cy.get('[data-cy=breadcrumb-first]').should('contain', 'Projects');
213 cy.get('[data-cy=breadcrumb-last]').should('contain', projName);
214 // Create a subproject
215 const subProjName = `Test project (${Math.floor(999999 * Math.random())})`;
216 createProject(subProjName, projName);
217 cy.get('[data-cy=form-dialog]').should('not.exist');
218 cy.get('[data-cy=breadcrumb-first]').should('contain', 'Projects');
219 cy.get('[data-cy=breadcrumb-last]').should('contain', subProjName);
222 it('attempts to use a preexisting name creating a project', function() {
223 const name = `Test project ${Math.floor(Math.random() * 999999)}`;
224 cy.createGroup(activeUser.token, {
226 group_class: 'project',
228 cy.loginAs(activeUser);
229 cy.goToPath(`/projects/${activeUser.user.uuid}`);
231 // Attempt to create new collection with a duplicate name
232 cy.get('[data-cy=side-panel-button]').click();
233 cy.get('[data-cy=side-panel-new-project]').click();
234 cy.get('[data-cy=form-dialog]')
235 .should('contain', 'New Project')
237 cy.get('[data-cy=name-field]').within(() => {
238 cy.get('input').type(name);
240 cy.get('[data-cy=form-submit-btn]').click();
242 // Error message should display, allowing editing the name
243 cy.get('[data-cy=form-dialog]').should('exist')
244 .and('contain', 'Project with the same name already exists')
246 cy.get('[data-cy=name-field]').within(() => {
247 cy.get('input').type(' renamed');
249 cy.get('[data-cy=form-submit-btn]').click();
251 cy.get('[data-cy=form-dialog]').should('not.exist');
254 it('navigates to the parent project after trashing the one being displayed', function() {
255 cy.createGroup(activeUser.token, {
256 name: `Test root project ${Math.floor(Math.random() * 999999)}`,
257 group_class: 'project',
258 }).as('testRootProject').then(function() {
259 cy.createGroup(activeUser.token, {
260 name : `Test subproject ${Math.floor(Math.random() * 999999)}`,
261 group_class: 'project',
262 owner_uuid: this.testRootProject.uuid,
263 }).as('testSubProject');
265 cy.getAll('@testRootProject', '@testSubProject').then(function([testRootProject, testSubProject]) {
266 cy.loginAs(activeUser);
268 // Go to subproject and trash it.
269 cy.goToPath(`/projects/${testSubProject.uuid}`);
270 cy.get('[data-cy=side-panel-tree]').should('contain', testSubProject.name);
271 cy.get('[data-cy=breadcrumb-last]')
272 .should('contain', testSubProject.name)
274 cy.get('[data-cy=context-menu]').contains('Move to trash').click();
276 // Confirm that the parent project should be displayed.
277 cy.get('[data-cy=breadcrumb-last]').should('contain', testRootProject.name);
278 cy.url().should('contain', `/projects/${testRootProject.uuid}`);
279 cy.get('[data-cy=side-panel-tree]').should('not.contain', testSubProject.name);
281 // Checks for bugfix #17637.
282 cy.get('[data-cy=not-found-content]').should('not.exist');
283 cy.get('[data-cy=not-found-page]').should('not.exist');
287 it('resets the search box only when navigating out of the current project', function() {
288 const fooProjectNameA = `Test foo project ${Math.floor(Math.random() * 999999)}`;
289 const fooProjectNameB = `Test foo project ${Math.floor(Math.random() * 999999)}`;
290 const barProjectNameA = `Test bar project ${Math.floor(Math.random() * 999999)}`;
292 [fooProjectNameA, fooProjectNameB, barProjectNameA].forEach(projName => {
293 cy.createGroup(activeUser.token, {
295 group_class: 'project',
299 cy.loginAs(activeUser);
300 cy.get('[data-cy=project-panel]')
301 .should('contain', fooProjectNameA)
302 .and('contain', fooProjectNameB)
303 .and('contain', barProjectNameA);
305 cy.get('[data-cy=search-input]').type('foo');
306 cy.get('[data-cy=project-panel]')
307 .should('contain', fooProjectNameA)
308 .and('contain', fooProjectNameB)
309 .and('not.contain', barProjectNameA);
311 // Click on the table row to select it, search should remain the same.
312 cy.get(`p:contains(${fooProjectNameA})`)
313 .parent().parent().parent().parent().click();
314 cy.get('[data-cy=search-input] input').should('have.value', 'foo');
316 // Click to navigate to the project, search should be reset
317 cy.get(`p:contains(${fooProjectNameA})`).click();
318 cy.get('[data-cy=search-input] input').should('not.have.value', 'foo');
321 it('navigates to the root project after trashing the parent of the one being displayed', function() {
322 cy.createGroup(activeUser.token, {
323 name: `Test root project ${Math.floor(Math.random() * 999999)}`,
324 group_class: 'project',
325 }).as('testRootProject').then(function() {
326 cy.createGroup(activeUser.token, {
327 name : `Test subproject ${Math.floor(Math.random() * 999999)}`,
328 group_class: 'project',
329 owner_uuid: this.testRootProject.uuid,
330 }).as('testSubProject').then(function() {
331 cy.createGroup(activeUser.token, {
332 name : `Test sub subproject ${Math.floor(Math.random() * 999999)}`,
333 group_class: 'project',
334 owner_uuid: this.testSubProject.uuid,
335 }).as('testSubSubProject');
338 cy.getAll('@testRootProject', '@testSubProject', '@testSubSubProject').then(function([testRootProject, testSubProject, testSubSubProject]) {
339 cy.loginAs(activeUser);
341 // Go to innermost project and trash its parent.
342 cy.goToPath(`/projects/${testSubSubProject.uuid}`);
343 cy.get('[data-cy=side-panel-tree]').should('contain', testSubSubProject.name);
344 cy.get('[data-cy=breadcrumb-last]').should('contain', testSubSubProject.name);
345 cy.get('[data-cy=side-panel-tree]')
346 .contains(testSubProject.name)
348 cy.get('[data-cy=context-menu]').contains('Move to trash').click();
350 // Confirm that the trashed project's parent should be displayed.
351 cy.get('[data-cy=breadcrumb-last]').should('contain', testRootProject.name);
352 cy.url().should('contain', `/projects/${testRootProject.uuid}`);
353 cy.get('[data-cy=side-panel-tree]').should('not.contain', testSubProject.name);
354 cy.get('[data-cy=side-panel-tree]').should('not.contain', testSubSubProject.name);
356 // Checks for bugfix #17637.
357 cy.get('[data-cy=not-found-content]').should('not.exist');
358 cy.get('[data-cy=not-found-page]').should('not.exist');
362 it('shows details panel when clicking on the info icon', () => {
363 cy.createGroup(activeUser.token, {
364 name: `Test root project ${Math.floor(Math.random() * 999999)}`,
365 group_class: 'project',
366 }).as('testRootProject').then(function(testRootProject) {
367 cy.loginAs(activeUser);
369 cy.get('[data-cy=side-panel-tree]').contains(testRootProject.name).click();
371 cy.get('[data-cy=additional-info-icon]').click();
373 cy.contains(testRootProject.uuid).should('exist');
377 it('clears search input when changing project', () => {
378 cy.createGroup(activeUser.token, {
379 name: `Test root project ${Math.floor(Math.random() * 999999)}`,
380 group_class: 'project',
381 }).as('testProject1').then((testProject1) => {
382 cy.shareWith(adminUser.token, activeUser.user.uuid, testProject1.uuid, 'can_write');
385 cy.getAll('@testProject1').then(function([testProject1]) {
386 cy.loginAs(activeUser);
388 cy.get('[data-cy=side-panel-tree]').contains(testProject1.name).click();
390 cy.get('[data-cy=search-input] input').type('test123');
392 cy.get('[data-cy=side-panel-tree]').contains('Projects').click();
394 cy.get('[data-cy=search-input] input').should('not.have.value', 'test123');
398 it('opens advanced popup for project with username', () => {
399 const projectName = `Test project ${Math.floor(Math.random() * 999999)}`;
401 cy.createGroup(adminUser.token, {
403 group_class: 'project',
406 cy.getAll('@mainProject')
407 .then(function ([mainProject]) {
408 cy.loginAs(adminUser);
410 cy.get('[data-cy=side-panel-tree]').contains('Groups').click();
412 cy.get('[data-cy=uuid]').eq(0).invoke('text').then(uuid => {
413 cy.createLink(adminUser.token, {
415 link_class: 'permission',
416 head_uuid: mainProject.uuid,
420 cy.createLink(adminUser.token, {
422 link_class: 'permission',
423 head_uuid: mainProject.uuid,
424 tail_uuid: activeUser.user.uuid
427 cy.get('[data-cy=side-panel-tree]').contains('Projects').click();
429 cy.get('main').contains(projectName).rightclick();
431 cy.get('[data-cy=context-menu]').contains('API Details').click();
433 cy.get('[role=tablist]').contains('METADATA').click();
435 cy.get('td').contains(uuid).should('exist');
437 cy.get('td').contains(activeUser.user.uuid).should('exist');
442 describe('Frozen projects', () => {
444 cy.createGroup(activeUser.token, {
445 name: `Main project ${Math.floor(Math.random() * 999999)}`,
446 group_class: 'project',
447 }).as('mainProject');
449 cy.createGroup(adminUser.token, {
450 name: `Admin project ${Math.floor(Math.random() * 999999)}`,
451 group_class: 'project',
452 }).as('adminProject').then((mainProject) => {
453 cy.shareWith(adminUser.token, activeUser.user.uuid, mainProject.uuid, 'can_write');
456 cy.get('@mainProject').then((mainProject) => {
457 cy.createGroup(adminUser.token, {
458 name : `Sub project ${Math.floor(Math.random() * 999999)}`,
459 group_class: 'project',
460 owner_uuid: mainProject.uuid,
463 cy.createCollection(adminUser.token, {
464 name: `Main collection ${Math.floor(Math.random() * 999999)}`,
465 owner_uuid: mainProject.uuid,
466 manifest_text: "./subdir 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo\n. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
467 }).as('mainCollection');
471 it('should be able to froze own project', () => {
472 cy.getAll('@mainProject').then(([mainProject]) => {
473 cy.loginAs(activeUser);
475 cy.get('[data-cy=project-panel]').contains(mainProject.name).rightclick();
477 cy.get('[data-cy=context-menu]').contains('Freeze').click();
479 cy.get('[data-cy=project-panel]').contains(mainProject.name).rightclick();
481 cy.get('[data-cy=context-menu]').contains('Freeze').should('not.exist');
485 it('should not be able to modify items within the frozen project', () => {
486 cy.getAll('@mainProject', '@mainCollection').then(([mainProject, mainCollection]) => {
487 cy.loginAs(activeUser);
489 cy.get('[data-cy=project-panel]').contains(mainProject.name).rightclick();
491 cy.get('[data-cy=context-menu]').contains('Freeze').click();
493 cy.get('[data-cy=project-panel]').contains(mainProject.name).click();
495 cy.get('[data-cy=project-panel]').contains(mainCollection.name).rightclick();
497 cy.get('[data-cy=context-menu]').contains('Move to trash').should('not.exist');
501 it('should be able to froze not owned project', () => {
502 cy.getAll('@adminProject').then(([adminProject]) => {
503 cy.loginAs(activeUser);
505 cy.get('[data-cy=side-panel-tree]').contains('Shared with me').click();
507 cy.get('main').contains(adminProject.name).rightclick();
509 cy.get('[data-cy=context-menu]').contains('Freeze').should('not.exist');
513 it('should be able to unfroze project if user is an admin', () => {
514 cy.getAll('@adminProject').then(([adminProject]) => {
515 cy.loginAs(adminUser);
517 cy.get('main').contains(adminProject.name).rightclick();
519 cy.get('[data-cy=context-menu]').contains('Freeze').click();
523 cy.get('main').contains(adminProject.name).rightclick();
525 cy.get('[data-cy=context-menu]').contains('Unfreeze').click();
527 cy.get('main').contains(adminProject.name).rightclick();
529 cy.get('[data-cy=context-menu]').contains('Freeze').should('exist');
534 it('copies project URL to clipboard', () => {
535 const projectName = `Test project (${Math.floor(999999 * Math.random())})`;
537 cy.loginAs(activeUser);
538 cy.get('[data-cy=side-panel-button]').click();
539 cy.get('[data-cy=side-panel-new-project]').click();
540 cy.get('[data-cy=form-dialog]')
541 .should('contain', 'New Project')
543 cy.get('[data-cy=name-field]').within(() => {
544 cy.get('input').type(projectName);
546 cy.get('[data-cy=form-submit-btn]').click();
548 cy.get('[data-cy=form-dialog]').should("not.exist");
549 cy.get('[data-cy=snackbar]').contains('created');
550 cy.get('[data-cy=snackbar]').should("not.exist");
551 cy.get('[data-cy=side-panel-tree]').contains('Projects').click();
553 cy.get('[data-cy=project-panel]').contains(projectName).should('be.visible').rightclick();
554 cy.get('[data-cy=context-menu]').contains('Copy to clipboard').click();
555 cy.window().then((win) => (
556 win.navigator.clipboard.readText().then((text) => {
557 expect(text).to.match(/https\:\/\/127\.0\.0\.1\:[0-9]+\/projects\/[a-z0-9]{5}-[a-z0-9]{5}-[a-z0-9]{15}/,);
563 it('sorts displayed items correctly', () => {
564 cy.loginAs(activeUser);
566 cy.get('[data-cy=project-panel] button[title="Select columns"]').click();
567 cy.get('div[role=presentation] ul > div[role=button]').contains('Date Created').click();
568 cy.get('div[role=presentation] ul > div[role=button]').contains('Trash at').click();
569 cy.get('div[role=presentation] ul > div[role=button]').contains('Delete at').click();
570 cy.get('div[role=presentation] > div[aria-hidden=true]').click();
572 cy.intercept({method: 'GET', url: '**/arvados/v1/groups/*/contents*'}).as('filteredQuery');
576 asc: "collections.name asc,container_requests.name asc,groups.name asc",
577 desc: "collections.name desc,container_requests.name desc,groups.name desc"
580 name: "Last Modified",
581 asc: "collections.modified_at asc,container_requests.modified_at asc,groups.modified_at asc",
582 desc: "collections.modified_at desc,container_requests.modified_at desc,groups.modified_at desc"
585 name: "Date Created",
586 asc: "collections.created_at asc,container_requests.created_at asc,groups.created_at asc",
587 desc: "collections.created_at desc,container_requests.created_at desc,groups.created_at desc"
592 asc: "collections.trash_at asc,container_requests.trash_at asc,groups.trash_at asc",
593 desc: "collections.trash_at desc,container_requests.trash_at desc,groups.trash_at desc"
598 asc: "collections.delete_at asc,container_requests.delete_at asc,groups.delete_at asc",
599 desc: "collections.delete_at desc,container_requests.delete_at desc,groups.delete_at desc"
602 ].forEach((test) => {
603 cy.get('[data-cy=project-panel] table thead th').contains(test.name).click();
604 cy.wait('@filteredQuery').then(interception => {
605 const searchParams = new URLSearchParams((new URL(interception.request.url).search));
606 expect(searchParams.get('order')).to.eq(test.asc);
608 cy.get('[data-cy=project-panel] table thead th').contains(test.name).click();
609 cy.wait('@filteredQuery').then(interception => {
610 const searchParams = new URLSearchParams((new URL(interception.request.url).search));
611 expect(searchParams.get('order')).to.eq(test.desc);