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.only("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();
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]").click().type(type);
146 cy.get("[data-cy=form-submit-btn]").click();
150 const verifyProjectDescription = (name, description) => {
151 cy.doRequest("GET", "/arvados/v1/groups", null, {
152 filters: `[["name", "=", "${name}"], ["group_class", "=", "project"]]`,
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);
182 it("creates new project on home project and then a subproject inside it", function () {
183 const createProject = function (name, parentName) {
184 cy.get("[data-cy=side-panel-button]").click();
185 cy.get("[data-cy=side-panel-new-project]").click();
186 cy.get("[data-cy=form-dialog]")
187 .should("contain", "New Project")
189 cy.get("[data-cy=parent-field]").within(() => {
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]")
245 .and("contain", "Project with the same name already exists")
247 cy.get("[data-cy=name-field]").within(() => {
248 cy.get("input").type(" renamed");
250 cy.get("[data-cy=form-submit-btn]").click();
252 cy.get("[data-cy=form-dialog]").should("not.exist");
255 it("navigates to the parent project after trashing the one being displayed", function () {
256 cy.createGroup(activeUser.token, {
257 name: `Test root project ${Math.floor(Math.random() * 999999)}`,
258 group_class: "project",
260 .as("testRootProject")
262 cy.createGroup(activeUser.token, {
263 name: `Test subproject ${Math.floor(Math.random() * 999999)}`,
264 group_class: "project",
265 owner_uuid: this.testRootProject.uuid,
266 }).as("testSubProject");
268 cy.getAll("@testRootProject", "@testSubProject").then(function ([testRootProject, testSubProject]) {
269 cy.loginAs(activeUser);
271 // Go to subproject and trash it.
272 cy.goToPath(`/projects/${testSubProject.uuid}`);
273 cy.get("[data-cy=side-panel-tree]").should("contain", testSubProject.name);
274 cy.get("[data-cy=breadcrumb-last]").should("contain", testSubProject.name).rightclick();
275 cy.get("[data-cy=context-menu]").contains("Move to trash").click();
277 // Confirm that the parent project should be displayed.
278 cy.get("[data-cy=breadcrumb-last]").should("contain", testRootProject.name);
279 cy.url().should("contain", `/projects/${testRootProject.uuid}`);
280 cy.get("[data-cy=side-panel-tree]").should("not.contain", testSubProject.name);
282 // Checks for bugfix #17637.
283 cy.get("[data-cy=not-found-content]").should("not.exist");
284 cy.get("[data-cy=not-found-page]").should("not.exist");
288 it("resets the search box only when navigating out of the current project", function () {
289 const fooProjectNameA = `Test foo project ${Math.floor(Math.random() * 999999)}`;
290 const fooProjectNameB = `Test foo project ${Math.floor(Math.random() * 999999)}`;
291 const barProjectNameA = `Test bar project ${Math.floor(Math.random() * 999999)}`;
293 [fooProjectNameA, fooProjectNameB, barProjectNameA].forEach(projName => {
294 cy.createGroup(activeUser.token, {
296 group_class: "project",
300 cy.loginAs(activeUser);
301 cy.get("[data-cy=project-panel]").should("contain", fooProjectNameA).and("contain", fooProjectNameB).and("contain", barProjectNameA);
303 cy.get("[data-cy=search-input]").type("foo");
304 cy.get("[data-cy=project-panel]").should("contain", fooProjectNameA).and("contain", fooProjectNameB).and("not.contain", barProjectNameA);
306 // Click on the table row to select it, search should remain the same.
307 cy.get(`p:contains(${fooProjectNameA})`).parent().parent().parent().parent().click();
308 cy.get("[data-cy=search-input] input").should("have.value", "foo");
310 // Click to navigate to the project, search should be reset
311 cy.get(`p:contains(${fooProjectNameA})`).click();
312 cy.get("[data-cy=search-input] input").should("not.have.value", "foo");
315 it("navigates to the root project after trashing the parent of the one being displayed", function () {
316 cy.createGroup(activeUser.token, {
317 name: `Test root project ${Math.floor(Math.random() * 999999)}`,
318 group_class: "project",
320 .as("testRootProject")
322 cy.createGroup(activeUser.token, {
323 name: `Test subproject ${Math.floor(Math.random() * 999999)}`,
324 group_class: "project",
325 owner_uuid: this.testRootProject.uuid,
327 .as("testSubProject")
329 cy.createGroup(activeUser.token, {
330 name: `Test sub subproject ${Math.floor(Math.random() * 999999)}`,
331 group_class: "project",
332 owner_uuid: this.testSubProject.uuid,
333 }).as("testSubSubProject");
336 cy.getAll("@testRootProject", "@testSubProject", "@testSubSubProject").then(function ([testRootProject, testSubProject, testSubSubProject]) {
337 cy.loginAs(activeUser);
339 // Go to innermost project and trash its parent.
340 cy.goToPath(`/projects/${testSubSubProject.uuid}`);
341 cy.get("[data-cy=side-panel-tree]").should("contain", testSubSubProject.name);
342 cy.get("[data-cy=breadcrumb-last]").should("contain", testSubSubProject.name);
343 cy.get("[data-cy=side-panel-tree]").contains(testSubProject.name).rightclick();
344 cy.get("[data-cy=context-menu]").contains("Move to trash").click();
346 // Confirm that the trashed project's parent should be displayed.
347 cy.get("[data-cy=breadcrumb-last]").should("contain", testRootProject.name);
348 cy.url().should("contain", `/projects/${testRootProject.uuid}`);
349 cy.get("[data-cy=side-panel-tree]").should("not.contain", testSubProject.name);
350 cy.get("[data-cy=side-panel-tree]").should("not.contain", testSubSubProject.name);
352 // Checks for bugfix #17637.
353 cy.get("[data-cy=not-found-content]").should("not.exist");
354 cy.get("[data-cy=not-found-page]").should("not.exist");
358 it("shows details panel when clicking on the info icon", () => {
359 cy.createGroup(activeUser.token, {
360 name: `Test root project ${Math.floor(Math.random() * 999999)}`,
361 group_class: "project",
363 .as("testRootProject")
364 .then(function (testRootProject) {
365 cy.loginAs(activeUser);
367 cy.get("[data-cy=side-panel-tree]").contains(testRootProject.name).click();
369 cy.get("[data-cy=additional-info-icon]").click();
371 cy.contains(testRootProject.uuid).should("exist");
375 it("clears search input when changing project", () => {
376 cy.createGroup(activeUser.token, {
377 name: `Test root project ${Math.floor(Math.random() * 999999)}`,
378 group_class: "project",
381 .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",
404 }).as("mainProject");
406 cy.getAll("@mainProject").then(function ([mainProject]) {
407 cy.loginAs(adminUser);
409 cy.get("[data-cy=side-panel-tree]").contains("Groups").click();
411 cy.get("[data-cy=uuid]")
415 cy.createLink(adminUser.token, {
417 link_class: "permission",
418 head_uuid: mainProject.uuid,
422 cy.createLink(adminUser.token, {
424 link_class: "permission",
425 head_uuid: mainProject.uuid,
426 tail_uuid: activeUser.user.uuid,
429 cy.get("[data-cy=side-panel-tree]").contains("Projects").click();
431 cy.get("main").contains(projectName).rightclick();
433 cy.get("[data-cy=context-menu]").contains("API Details").click();
435 cy.get("[role=tablist]").contains("METADATA").click();
437 cy.get("td").contains(uuid).should("exist");
439 cy.get("td").contains(activeUser.user.uuid).should("exist");
444 describe("Frozen projects", () => {
446 cy.createGroup(activeUser.token, {
447 name: `Main project ${Math.floor(Math.random() * 999999)}`,
448 group_class: "project",
449 }).as("mainProject");
451 cy.createGroup(adminUser.token, {
452 name: `Admin project ${Math.floor(Math.random() * 999999)}`,
453 group_class: "project",
456 .then(mainProject => {
457 cy.shareWith(adminUser.token, activeUser.user.uuid, mainProject.uuid, "can_write");
460 cy.get("@mainProject").then(mainProject => {
461 cy.createGroup(adminUser.token, {
462 name: `Sub project ${Math.floor(Math.random() * 999999)}`,
463 group_class: "project",
464 owner_uuid: mainProject.uuid,
467 cy.createCollection(adminUser.token, {
468 name: `Main collection ${Math.floor(Math.random() * 999999)}`,
469 owner_uuid: mainProject.uuid,
470 manifest_text: "./subdir 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo\n. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n",
471 }).as("mainCollection");
475 it("should be able to froze own project", () => {
476 cy.getAll("@mainProject").then(([mainProject]) => {
477 cy.loginAs(activeUser);
479 cy.get("[data-cy=project-panel]").contains(mainProject.name).rightclick();
481 cy.get("[data-cy=context-menu]").contains("Freeze").click();
483 cy.get("[data-cy=project-panel]").contains(mainProject.name).rightclick();
485 cy.get("[data-cy=context-menu]").contains("Freeze").should("not.exist");
489 it("should not be able to modify items within the frozen project", () => {
490 cy.getAll("@mainProject", "@mainCollection").then(([mainProject, mainCollection]) => {
491 cy.loginAs(activeUser);
493 cy.get("[data-cy=project-panel]").contains(mainProject.name).rightclick();
495 cy.get("[data-cy=context-menu]").contains("Freeze").click();
497 cy.get("[data-cy=project-panel]").contains(mainProject.name).click();
499 cy.get("[data-cy=project-panel]").contains(mainCollection.name).rightclick();
501 cy.get("[data-cy=context-menu]").contains("Move to trash").should("not.exist");
505 it("should be able to froze not owned project", () => {
506 cy.getAll("@adminProject").then(([adminProject]) => {
507 cy.loginAs(activeUser);
509 cy.get("[data-cy=side-panel-tree]").contains("Shared with me").click();
511 cy.get("main").contains(adminProject.name).rightclick();
513 cy.get("[data-cy=context-menu]").contains("Freeze").should("not.exist");
517 it("should be able to unfroze project if user is an admin", () => {
518 cy.getAll("@adminProject").then(([adminProject]) => {
519 cy.loginAs(adminUser);
521 cy.get("main").contains(adminProject.name).rightclick();
523 cy.get("[data-cy=context-menu]").contains("Freeze").click();
527 cy.get("main").contains(adminProject.name).rightclick();
529 cy.get("[data-cy=context-menu]").contains("Unfreeze").click();
531 cy.get("main").contains(adminProject.name).rightclick();
533 cy.get("[data-cy=context-menu]").contains("Freeze").should("exist");
538 it("copies project URL to clipboard", () => {
539 const projectName = `Test project (${Math.floor(999999 * Math.random())})`;
541 cy.loginAs(activeUser);
542 cy.get("[data-cy=side-panel-button]").click();
543 cy.get("[data-cy=side-panel-new-project]").click();
544 cy.get("[data-cy=form-dialog]")
545 .should("contain", "New Project")
547 cy.get("[data-cy=name-field]").within(() => {
548 cy.get("input").type(projectName);
550 cy.get("[data-cy=form-submit-btn]").click();
552 cy.get("[data-cy=form-dialog]").should("not.exist");
553 cy.get("[data-cy=side-panel-tree]").contains("Projects").click();
554 cy.get("[data-cy=project-panel]").contains(projectName).should("be.visible").rightclick();
555 cy.get("[data-cy=context-menu]").contains("Copy to clipboard").click();
556 cy.window().then(win =>
557 win.navigator.clipboard.readText().then(text => {
558 expect(text).to.match(/https\:\/\/localhost\:[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",
591 asc: "collections.trash_at asc,container_requests.trash_at asc,groups.trash_at asc",
592 desc: "collections.trash_at desc,container_requests.trash_at desc,groups.trash_at desc",
596 asc: "collections.delete_at asc,container_requests.delete_at asc,groups.delete_at asc",
597 desc: "collections.delete_at desc,container_requests.delete_at desc,groups.delete_at desc",
600 cy.get("[data-cy=project-panel] table thead th").contains(test.name).click();
601 cy.wait("@filteredQuery").then(interception => {
602 const searchParams = new URLSearchParams(new URL(interception.request.url).search);
603 expect(searchParams.get("order")).to.eq(test.asc);
605 cy.get("[data-cy=project-panel] table thead th").contains(test.name).click();
606 cy.wait("@filteredQuery").then(interception => {
607 const searchParams = new URLSearchParams(new URL(interception.request.url).search);
608 expect(searchParams.get("order")).to.eq(test.desc);