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)
17 adminUser = this.adminUser;
19 cy.getUser("user", "Active", "User", false, true)
22 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);
43 // Key: Color (IDTAGCOLORS) - Value: Magenta (IDVALCOLORS3)
44 cy.get("[data-cy=form-dialog]").should("not.contain", "Color: Magenta");
45 cy.get("[data-cy=resource-properties-form]").within(() => {
46 cy.get("[data-cy=property-field-key]").within(() => {
47 cy.get("input").type("Color");
49 cy.get("[data-cy=property-field-value]").within(() => {
50 cy.get("input").type("Magenta");
53 cy.get("[data-cy=property-field-value]").within(() => {
54 cy.get("input").type("Pink");
57 cy.get("[data-cy=property-field-value]").within(() => {
58 cy.get("input").type("Yellow");
62 // Confirm proper vocabulary labels are displayed on the UI.
63 cy.get("[data-cy=form-dialog]").should("contain", "Color: Magenta");
64 cy.get("[data-cy=form-dialog]").should("contain", "Color: Pink");
65 cy.get("[data-cy=form-dialog]").should("contain", "Color: Yellow");
67 cy.get("[data-cy=resource-properties-form]").within(() => {
68 cy.get("[data-cy=property-field-key]").within(() => {
69 cy.get("input").focus();
71 cy.get("[data-cy=property-field-key]").should("not.contain", "Color");
74 // Create project and confirm the properties' real values.
75 cy.get("[data-cy=form-submit-btn]").click();
76 cy.get("[data-cy=breadcrumb-last]").should("contain", projName);
77 cy.doRequest("GET", "/arvados/v1/groups", null, {
78 filters: `[["name", "=", "${projName}"], ["group_class", "=", "project"]]`,
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"] }
90 // Open project edit via breadcrumbs
91 cy.get("[data-cy=breadcrumbs]").contains(projName).rightclick();
92 cy.get("[data-cy=context-menu]").contains("Edit").click();
93 cy.get("[data-cy=form-dialog]").within(() => {
94 cy.get("[data-cy=resource-properties-list]").within(() => {
95 cy.get("div[role=button]").contains("Color: Magenta");
96 cy.get("div[role=button]").contains("Color: Pink");
97 cy.get("div[role=button]").contains("Color: Yellow");
100 // Add another property
101 cy.get("[data-cy=resource-properties-form]").within(() => {
102 cy.get("[data-cy=property-field-key]").within(() => {
103 cy.get("input").type("Animal");
105 cy.get("[data-cy=property-field-value]").within(() => {
106 cy.get("input").type("Dog");
110 cy.get("[data-cy=form-submit-btn]").click({ force: true });
111 // Reopen edit via breadcrumbs and verify properties
112 cy.get("[data-cy=breadcrumbs]").contains(projName).rightclick();
113 cy.get("[data-cy=context-menu]").contains("Edit").click();
114 cy.get("[data-cy=form-dialog]").within(() => {
115 cy.get("[data-cy=resource-properties-list]").within(() => {
116 cy.get("div[role=button]").contains("Color: Magenta");
117 cy.get("div[role=button]").contains("Color: Pink");
118 cy.get("div[role=button]").contains("Color: Yellow");
119 cy.get("div[role=button]").contains("Animal: Dog");
124 it("creates a project without and with description", function () {
125 const projName = `Test project (${Math.floor(999999 * Math.random())})`;
126 cy.loginAs(activeUser);
129 cy.get("[data-cy=side-panel-button]").click();
130 cy.get("[data-cy=side-panel-new-project]").click();
131 cy.get("[data-cy=form-dialog]")
132 .should("contain", "New Project")
134 cy.get("[data-cy=name-field]").within(() => {
135 cy.get("input").type(projName);
138 cy.get("[data-cy=form-submit-btn]").click();
139 cy.get("[data-cy=form-dialog]").should("not.exist");
141 const editProjectDescription = (name, type) => {
142 cy.get("[data-cy=side-panel-tree]").contains("Home Projects").click();
143 cy.get("[data-cy=project-panel] tbody tr").contains(name).rightclick({ force: true });
144 cy.get("[data-cy=context-menu]").contains("Edit").click();
145 cy.get("[data-cy=form-dialog]").within(() => {
146 cy.get("div[contenteditable=true]").click().type(type);
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"]]`,
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);
183 it('shows the appropriate buttons in the multiselect toolbar', () => {
185 const msButtonTooltips = [
195 'Open with 3rd party client',
200 cy.loginAs(activeUser);
201 const projName = `Test project (${Math.floor(999999 * Math.random())})`;
202 cy.get('[data-cy=side-panel-button]').click();
203 cy.get('[data-cy=side-panel-new-project]').click();
204 cy.get('[data-cy=form-dialog]')
205 .should('contain', 'New Project')
207 cy.get('[data-cy=name-field]').within(() => {
208 cy.get('input').type(projName);
211 cy.get("[data-cy=form-submit-btn]").click();
215 cy.get('[data-cy=data-table-row]').contains(projName).should('exist').parent().parent().parent().click()
216 cy.get('[data-cy=multiselect-button]').should('have.length', msButtonTooltips.length +1)
217 for (let i = 0; i < msButtonTooltips.length; i++) {
218 cy.get('[data-cy=multiselect-button]').eq(i).trigger('mouseover');
219 cy.get('body').contains(msButtonTooltips[i]).should('exist')
220 cy.get('[data-cy=multiselect-button]').eq(i).trigger('mouseout');
224 it("creates new project on home project and then a subproject inside it", function () {
225 const createProject = function (name, parentName) {
226 cy.get("[data-cy=side-panel-button]").click();
227 cy.get("[data-cy=side-panel-new-project]").click();
228 cy.get("[data-cy=form-dialog]")
229 .should("contain", "New Project")
231 cy.get("[data-cy=parent-field]").within(() => {
235 expect(val).to.include(parentName);
238 cy.get("[data-cy=name-field]").within(() => {
239 cy.get("input").type(name);
242 cy.get("[data-cy=form-submit-btn]").click();
245 cy.loginAs(activeUser);
246 cy.goToPath(`/projects/${activeUser.user.uuid}`);
247 cy.get("[data-cy=breadcrumb-first]").should("contain", "Projects");
248 cy.get("[data-cy=breadcrumb-last]").should("not.exist");
249 // Create new project
250 const projName = `Test project (${Math.floor(999999 * Math.random())})`;
251 createProject(projName, "Home project");
252 // Confirm that the user was taken to the newly created thing
253 cy.get("[data-cy=form-dialog]").should("not.exist");
254 cy.get("[data-cy=breadcrumb-first]").should("contain", "Projects");
255 cy.get("[data-cy=breadcrumb-last]").should("contain", projName);
256 // Create a subproject
257 const subProjName = `Test project (${Math.floor(999999 * Math.random())})`;
258 createProject(subProjName, projName);
259 cy.get("[data-cy=form-dialog]").should("not.exist");
260 cy.get("[data-cy=breadcrumb-first]").should("contain", "Projects");
261 cy.get("[data-cy=breadcrumb-last]").should("contain", subProjName);
264 it("attempts to use a preexisting name creating a project", function () {
265 const name = `Test project ${Math.floor(Math.random() * 999999)}`;
266 cy.createGroup(activeUser.token, {
268 group_class: "project",
270 cy.loginAs(activeUser);
271 cy.goToPath(`/projects/${activeUser.user.uuid}`);
273 // Attempt to create new collection with a duplicate name
274 cy.get("[data-cy=side-panel-button]").click();
275 cy.get("[data-cy=side-panel-new-project]").click();
276 cy.get("[data-cy=form-dialog]")
277 .should("contain", "New Project")
279 cy.get("[data-cy=name-field]").within(() => {
280 cy.get("input").type(name);
282 cy.get("[data-cy=form-submit-btn]").click();
284 // Error message should display, allowing editing the name
285 cy.get("[data-cy=form-dialog]")
287 .and("contain", "Project with the same name already exists")
289 cy.get("[data-cy=name-field]").within(() => {
290 cy.get("input").type(" renamed");
292 cy.get("[data-cy=form-submit-btn]").click();
294 cy.get("[data-cy=form-dialog]").should("not.exist");
297 it("navigates to the parent project after trashing the one being displayed", function () {
298 cy.createGroup(activeUser.token, {
299 name: `Test root project ${Math.floor(Math.random() * 999999)}`,
300 group_class: "project",
302 .as("testRootProject")
304 cy.createGroup(activeUser.token, {
305 name: `Test subproject ${Math.floor(Math.random() * 999999)}`,
306 group_class: "project",
307 owner_uuid: this.testRootProject.uuid,
308 }).as("testSubProject");
310 cy.getAll("@testRootProject", "@testSubProject").then(function ([testRootProject, testSubProject]) {
311 cy.loginAs(activeUser);
313 // Go to subproject and trash it.
314 cy.goToPath(`/projects/${testSubProject.uuid}`);
315 cy.get("[data-cy=side-panel-tree]").should("contain", testSubProject.name);
316 cy.get("[data-cy=breadcrumb-last]").should("contain", testSubProject.name).rightclick();
317 cy.get("[data-cy=context-menu]").contains("Move to trash").click();
319 // Confirm that the parent project should be displayed.
320 cy.get("[data-cy=breadcrumb-last]").should("contain", testRootProject.name);
321 cy.url().should("contain", `/projects/${testRootProject.uuid}`);
322 cy.get("[data-cy=side-panel-tree]").should("not.contain", testSubProject.name);
324 // Checks for bugfix #17637.
325 cy.get("[data-cy=not-found-content]").should("not.exist");
326 cy.get("[data-cy=not-found-page]").should("not.exist");
330 it("resets the search box only when navigating out of the current project", function () {
331 const fooProjectNameA = `Test foo project ${Math.floor(Math.random() * 999999)}`;
332 const fooProjectNameB = `Test foo project ${Math.floor(Math.random() * 999999)}`;
333 const barProjectNameA = `Test bar project ${Math.floor(Math.random() * 999999)}`;
335 [fooProjectNameA, fooProjectNameB, barProjectNameA].forEach(projName => {
336 cy.createGroup(activeUser.token, {
338 group_class: "project",
342 cy.loginAs(activeUser);
343 cy.get("[data-cy=project-panel]").should("contain", fooProjectNameA).and("contain", fooProjectNameB).and("contain", barProjectNameA);
345 cy.get("[data-cy=search-input]").type("foo");
346 cy.get("[data-cy=project-panel]").should("contain", fooProjectNameA).and("contain", fooProjectNameB).and("not.contain", barProjectNameA);
348 // Click on the table row to select it, search should remain the same.
349 cy.get(`p:contains(${fooProjectNameA})`).parent().parent().parent().parent().click();
350 cy.get("[data-cy=search-input] input").should("have.value", "foo");
352 // Click to navigate to the project, search should be reset
353 cy.get(`p:contains(${fooProjectNameA})`).click();
354 cy.get("[data-cy=search-input] input").should("not.have.value", "foo");
357 it("navigates to the root project after trashing the parent of the one being displayed", function () {
358 cy.createGroup(activeUser.token, {
359 name: `Test root project ${Math.floor(Math.random() * 999999)}`,
360 group_class: "project",
362 .as("testRootProject")
364 cy.createGroup(activeUser.token, {
365 name: `Test subproject ${Math.floor(Math.random() * 999999)}`,
366 group_class: "project",
367 owner_uuid: this.testRootProject.uuid,
369 .as("testSubProject")
371 cy.createGroup(activeUser.token, {
372 name: `Test sub subproject ${Math.floor(Math.random() * 999999)}`,
373 group_class: "project",
374 owner_uuid: this.testSubProject.uuid,
375 }).as("testSubSubProject");
378 cy.getAll("@testRootProject", "@testSubProject", "@testSubSubProject").then(function ([testRootProject, testSubProject, testSubSubProject]) {
379 cy.loginAs(activeUser);
381 // Go to innermost project and trash its parent.
382 cy.goToPath(`/projects/${testSubSubProject.uuid}`);
383 cy.get("[data-cy=side-panel-tree]").should("contain", testSubSubProject.name);
384 cy.get("[data-cy=breadcrumb-last]").should("contain", testSubSubProject.name);
385 cy.get("[data-cy=side-panel-tree]").contains(testSubProject.name).rightclick();
386 cy.get("[data-cy=context-menu]").contains("Move to trash").click();
388 // Confirm that the trashed project's parent should be displayed.
389 cy.get("[data-cy=breadcrumb-last]").should("contain", testRootProject.name);
390 cy.url().should("contain", `/projects/${testRootProject.uuid}`);
391 cy.get("[data-cy=side-panel-tree]").should("not.contain", testSubProject.name);
392 cy.get("[data-cy=side-panel-tree]").should("not.contain", testSubSubProject.name);
394 // Checks for bugfix #17637.
395 cy.get("[data-cy=not-found-content]").should("not.exist");
396 cy.get("[data-cy=not-found-page]").should("not.exist");
400 it("shows details panel when clicking on the info icon", () => {
401 cy.createGroup(activeUser.token, {
402 name: `Test root project ${Math.floor(Math.random() * 999999)}`,
403 group_class: "project",
405 .as("testRootProject")
406 .then(function (testRootProject) {
407 cy.loginAs(activeUser);
409 cy.get("[data-cy=side-panel-tree]").contains(testRootProject.name).click();
411 cy.get("[data-cy=additional-info-icon]").click();
413 cy.contains(testRootProject.uuid).should("exist");
417 it("clears search input when changing project", () => {
418 cy.createGroup(activeUser.token, {
419 name: `Test root project ${Math.floor(Math.random() * 999999)}`,
420 group_class: "project",
423 .then(testProject1 => {
424 cy.shareWith(adminUser.token, activeUser.user.uuid, testProject1.uuid, "can_write");
427 cy.getAll("@testProject1").then(function ([testProject1]) {
428 cy.loginAs(activeUser);
430 cy.get("[data-cy=side-panel-tree]").contains(testProject1.name).click();
432 cy.get("[data-cy=search-input] input").type("test123");
434 cy.get("[data-cy=side-panel-tree]").contains("Projects").click();
436 cy.get("[data-cy=search-input] input").should("not.have.value", "test123");
440 it("opens advanced popup for project with username", () => {
441 const projectName = `Test project ${Math.floor(Math.random() * 999999)}`;
443 cy.createGroup(adminUser.token, {
445 group_class: "project",
446 }).as("mainProject");
448 cy.getAll("@mainProject").then(function ([mainProject]) {
449 cy.loginAs(adminUser);
451 cy.get("[data-cy=side-panel-tree]").contains("Groups").click();
453 cy.get("[data-cy=uuid]")
457 cy.createLink(adminUser.token, {
459 link_class: "permission",
460 head_uuid: mainProject.uuid,
464 cy.createLink(adminUser.token, {
466 link_class: "permission",
467 head_uuid: mainProject.uuid,
468 tail_uuid: activeUser.user.uuid,
471 cy.get("[data-cy=side-panel-tree]").contains("Projects").click();
473 cy.get("main").contains(projectName).rightclick();
475 cy.get("[data-cy=context-menu]").contains("API Details").click();
477 cy.get("[role=tablist]").contains("METADATA").click();
479 cy.get("td").contains(uuid).should("exist");
481 cy.get("td").contains(activeUser.user.uuid).should("exist");
486 describe("Frozen projects", () => {
488 cy.createGroup(activeUser.token, {
489 name: `Main project ${Math.floor(Math.random() * 999999)}`,
490 group_class: "project",
491 }).as("mainProject");
493 cy.createGroup(adminUser.token, {
494 name: `Admin project ${Math.floor(Math.random() * 999999)}`,
495 group_class: "project",
498 .then(mainProject => {
499 cy.shareWith(adminUser.token, activeUser.user.uuid, mainProject.uuid, "can_write");
502 cy.get("@mainProject").then(mainProject => {
503 cy.createGroup(adminUser.token, {
504 name: `Sub project ${Math.floor(Math.random() * 999999)}`,
505 group_class: "project",
506 owner_uuid: mainProject.uuid,
509 cy.createCollection(adminUser.token, {
510 name: `Main collection ${Math.floor(Math.random() * 999999)}`,
511 owner_uuid: mainProject.uuid,
512 manifest_text: "./subdir 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo\n. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n",
513 }).as("mainCollection");
517 it("should be able to freeze own project", () => {
518 cy.getAll("@mainProject").then(([mainProject]) => {
519 cy.loginAs(activeUser);
521 cy.get("[data-cy=project-panel]").contains(mainProject.name).rightclick();
523 cy.get("[data-cy=context-menu]").contains("Freeze").click();
525 cy.get("[data-cy=project-panel]").contains(mainProject.name).rightclick();
527 cy.get("[data-cy=context-menu]").contains("Freeze").should("not.exist");
531 it("should not be able to modify items within the frozen project", () => {
532 cy.getAll("@mainProject", "@mainCollection").then(([mainProject, mainCollection]) => {
533 cy.loginAs(activeUser);
535 cy.get("[data-cy=project-panel]").contains(mainProject.name).rightclick();
537 cy.get("[data-cy=context-menu]").contains("Freeze").click();
539 cy.get("[data-cy=project-panel]").contains(mainProject.name).click();
541 cy.get("[data-cy=project-panel]").contains(mainCollection.name).rightclick();
543 cy.get("[data-cy=context-menu]").contains("Move to trash").should("not.exist");
547 it("should be able to freeze not owned project", () => {
548 cy.getAll("@adminProject").then(([adminProject]) => {
549 cy.loginAs(activeUser);
551 cy.get("[data-cy=side-panel-tree]").contains("Shared with me").click();
553 cy.get("main").contains(adminProject.name).rightclick();
555 cy.get("[data-cy=context-menu]").contains("Freeze").should("not.exist");
559 it("should be able to unfreeze project if user is an admin", () => {
560 cy.getAll("@adminProject").then(([adminProject]) => {
561 cy.loginAs(adminUser);
563 cy.get("main").contains(adminProject.name).rightclick();
565 cy.get("[data-cy=context-menu]").contains("Freeze").click();
569 cy.get("main").contains(adminProject.name).rightclick();
571 cy.get("[data-cy=context-menu]").contains("Unfreeze").click();
573 cy.get("main").contains(adminProject.name).rightclick();
575 cy.get("[data-cy=context-menu]").contains("Freeze").should("exist");
580 it("copies project URL to clipboard", () => {
581 const projectName = `Test project (${Math.floor(999999 * Math.random())})`;
583 cy.loginAs(activeUser);
584 cy.get("[data-cy=side-panel-button]").click();
585 cy.get("[data-cy=side-panel-new-project]").click();
586 cy.get("[data-cy=form-dialog]")
587 .should("contain", "New Project")
589 cy.get("[data-cy=name-field]").within(() => {
590 cy.get("input").type(projectName);
592 cy.get("[data-cy=form-submit-btn]").click();
594 cy.get("[data-cy=form-dialog]").should("not.exist");
595 cy.get("[data-cy=snackbar]").contains("created");
596 cy.get("[data-cy=snackbar]").should("not.exist");
597 cy.get("[data-cy=side-panel-tree]").contains("Projects").click();
599 cy.get("[data-cy=project-panel]").contains(projectName).should("be.visible").rightclick();
600 cy.get("[data-cy=context-menu]").contains("Copy to clipboard").click();
601 cy.window().then(win =>
602 win.navigator.clipboard.readText().then(text => {
603 expect(text).to.match(/https\:\/\/127\.0\.0\.1\:[0-9]+\/projects\/[a-z0-9]{5}-[a-z0-9]{5}-[a-z0-9]{15}/);
608 it("sorts displayed items correctly", () => {
609 cy.loginAs(activeUser);
611 cy.get('[data-cy=project-panel] button[title="Select columns"]').click();
612 cy.get("div[role=presentation] ul > div[role=button]").contains("Date Created").click();
613 cy.get("div[role=presentation] ul > div[role=button]").contains("Trash at").click();
614 cy.get("div[role=presentation] ul > div[role=button]").contains("Delete at").click();
615 cy.get("div[role=presentation] > div[aria-hidden=true]").click();
617 cy.intercept({ method: "GET", url: "**/arvados/v1/groups/*/contents*" }).as("filteredQuery");
621 asc: "collections.name asc,container_requests.name asc,groups.name asc,container_requests.created_at desc",
622 desc: "collections.name desc,container_requests.name desc,groups.name desc,container_requests.created_at desc",
625 name: "Last Modified",
626 asc: "collections.modified_at asc,container_requests.modified_at asc,groups.modified_at asc,container_requests.created_at desc",
627 desc: "collections.modified_at desc,container_requests.modified_at desc,groups.modified_at desc,container_requests.created_at desc",
630 name: "Date Created",
631 asc: "collections.created_at asc,container_requests.created_at asc,groups.created_at asc,container_requests.created_at desc",
632 desc: "collections.created_at desc,container_requests.created_at desc,groups.created_at desc,container_requests.created_at desc",
636 asc: "collections.trash_at asc,container_requests.trash_at asc,groups.trash_at asc,container_requests.created_at desc",
637 desc: "collections.trash_at desc,container_requests.trash_at desc,groups.trash_at desc,container_requests.created_at desc",
641 asc: "collections.delete_at asc,container_requests.delete_at asc,groups.delete_at asc,container_requests.created_at desc",
642 desc: "collections.delete_at desc,container_requests.delete_at desc,groups.delete_at desc,container_requests.created_at desc",
645 cy.get("[data-cy=project-panel] table thead th").contains(test.name).click();
646 cy.wait("@filteredQuery").then(interception => {
647 const searchParams = new URLSearchParams(new URL(interception.request.url).search);
648 expect(searchParams.get("order")).to.eq(test.asc);
650 cy.get("[data-cy=project-panel] table thead th").contains(test.name).click();
651 cy.wait("@filteredQuery").then(interception => {
652 const searchParams = new URLSearchParams(new URL(interception.request.url).search);
653 expect(searchParams.get("order")).to.eq(test.desc);