1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 const path = require("path");
6 require('cypress-plugin-tab')
8 describe("Collection panel tests", function () {
14 // Only set up common users once. These aren't set up as aliases because
15 // aliases are cleaned up after every test. Also it doesn't make sense
16 // to set the same users on beforeEach() over and over again, so we
17 // separate a little from Cypress' 'Best Practices' here.
18 cy.getUser("admin", "Admin", "User", true, true)
21 adminUser = this.adminUser;
23 cy.getUser("collectionuser1", "Collection", "User", false, true)
26 activeUser = this.activeUser;
28 downloadsFolder = Cypress.config("downloadsFolder");
31 it('shows the appropriate buttons in the toolbar', () => {
33 const msButtonTooltips = [
36 'Copy link to clipboard',
37 'Open with 3rd party client',
47 cy.loginAs(activeUser);
48 const name = `Test collection ${Math.floor(Math.random() * 999999)}`;
49 cy.get("[data-cy=side-panel-button]").click({force: true});
50 cy.get("[data-cy=side-panel-new-collection]").click();
51 cy.get("[data-cy=form-dialog]")
52 .should("contain", "New collection")
54 cy.get("[data-cy=name-field]").within(() => {
55 cy.get("input").type(name);
57 cy.get("[data-cy=form-submit-btn]").click();
59 cy.get("[data-cy=side-panel-tree]").contains("Home Projects").click();
61 cy.get('[data-cy=data-table-row]').contains(name).should('exist').parents('td').click()
63 cy.get('[data-cy=multiselect-button]').should('have.length', msButtonTooltips.length)
64 msButtonTooltips.forEach((tooltip, index) => {
65 cy.get('[data-cy=multiselect-button]').eq(index).parent().should('have.attr', 'aria-label', tooltip)
69 it("allows to download mountain duck config for a collection", () => {
70 cy.createCollection(adminUser.token, {
71 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
72 owner_uuid: activeUser.user.uuid,
73 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n",
76 .then(function (testCollection) {
77 cy.loginAs(activeUser);
78 cy.goToPath(`/collections/${testCollection.uuid}`);
80 cy.get("[data-cy=collection-panel-options-btn]").click();
81 cy.get("[data-cy=context-menu]").contains("Open with 3rd party client").click();
82 cy.get("[data-cy=download-button").click();
84 const filename = path.join(downloadsFolder, `${testCollection.name}.duck`);
86 cy.readFile(filename, { timeout: 15000 })
88 const childrenCollection = Array.prototype.slice.call(Cypress.$(body).find("dict")[0].children);
93 for (i = 0; i < childrenCollection.length; i += j) {
94 map[childrenCollection[i].outerText] = childrenCollection[i + 1].outerText;
97 cy.get("#simple-tabpanel-0")
100 const [host, port] = a.text().split("@")[1].split("/")[0].split(":");
101 expect(map["Protocol"]).to.equal("davs");
102 expect(map["UUID"]).to.equal(testCollection.uuid);
103 expect(map["Username"]).to.equal(activeUser.user.username);
104 expect(map["Port"]).to.equal(port);
105 expect(map["Hostname"]).to.equal(host);
107 expect(map["Path"]).to.equal(`/c=${testCollection.uuid}`);
111 .then(() => cy.task("clearDownload", { filename }));
115 it("attempts to use a preexisting name creating or updating a collection", function () {
116 const name = `Test collection ${Math.floor(Math.random() * 999999)}`;
117 cy.createCollection(adminUser.token, {
119 owner_uuid: activeUser.user.uuid,
120 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n",
122 cy.loginAs(activeUser);
123 cy.goToPath(`/projects/${activeUser.user.uuid}`);
124 cy.get("[data-cy=breadcrumb-first]").should("contain", "Projects");
125 cy.get("[data-cy=breadcrumb-last]").should("not.exist");
126 // Attempt to create new collection with a duplicate name
127 cy.get("[data-cy=side-panel-button]").click();
128 cy.get("[data-cy=side-panel-new-collection]").click();
129 cy.get("[data-cy=form-dialog]")
130 .should("contain", "New collection")
132 cy.get("[data-cy=name-field]").within(() => {
133 cy.get("input").type(name);
135 cy.get("[data-cy=form-submit-btn]").click();
137 // Error message should display, allowing editing the name
138 cy.get("[data-cy=form-dialog]")
140 .and("contain", "Collection with the same name already exists")
142 cy.get("[data-cy=name-field]").within(() => {
143 cy.get("input").type(" renamed");
145 cy.get("[data-cy=form-submit-btn]").click({timeout: 10000});
147 cy.get("[data-cy=form-dialog]").should("not.exist");
148 // Attempt to rename the collection with the duplicate name
149 cy.get("[data-cy=collection-panel-options-btn]").click();
150 cy.get("[data-cy=context-menu]").contains("Edit collection").click();
151 cy.get("[data-cy=form-dialog]")
152 .should("contain", "Edit Collection")
154 cy.get("[data-cy=name-field]").within(() => {
155 cy.get("input").type("{selectall}{backspace}").type(name);
157 cy.get("[data-cy=form-submit-btn]").click();
159 cy.get("[data-cy=form-dialog]").should("exist").and("contain", "Collection with the same name already exists");
162 it("uses the property editor (from edit dialog) with vocabulary terms", function () {
163 cy.createCollection(adminUser.token, {
164 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
165 owner_uuid: activeUser.user.uuid,
166 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n",
168 .as("testCollection")
170 cy.loginAs(activeUser);
171 cy.goToPath(`/collections/${this.testCollection.uuid}`);
173 cy.get("[data-cy=collection-info-panel").should("contain", this.testCollection.name).and("not.contain", "Color: Magenta");
175 cy.get("[data-cy=collection-panel-options-btn]").click();
176 cy.get("[data-cy=context-menu]").contains("Edit collection").click();
177 cy.get("[data-cy=form-dialog]").should("contain", "Properties");
179 // Key: Color (IDTAGCOLORS) - Value: Magenta (IDVALCOLORS3)
180 cy.get("[data-cy=resource-properties-form]").within(() => {
181 cy.get("[data-cy=property-field-key]").within(() => {
182 cy.get("input").type("Color");
184 cy.get("[data-cy=property-field-value]").within(() => {
185 cy.get("input").type("Magenta");
189 // Confirm proper vocabulary labels are displayed on the UI.
190 cy.get("[data-cy=form-dialog]").should("contain", "Color: Magenta");
191 cy.get("[data-cy=form-dialog]").contains("Save").click();
192 cy.get("[data-cy=form-dialog]").should("not.exist");
193 // Confirm proper vocabulary IDs were saved on the backend.
194 cy.doRequest("GET", `/arvados/v1/collections/${this.testCollection.uuid}`)
198 expect(this.collection.properties.IDTAGCOLORS).to.equal("IDVALCOLORS3");
200 // Confirm the property is displayed on the UI.
201 cy.get("[data-cy=collection-info-panel").should("contain", this.testCollection.name).and("contain", "Color: Magenta");
205 it("uses the editor (from details panel) with vocabulary terms", function () {
206 cy.createCollection(adminUser.token, {
207 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
208 owner_uuid: activeUser.user.uuid,
209 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n",
211 .as("testCollection")
213 cy.loginAs(activeUser);
214 cy.goToPath(`/collections/${this.testCollection.uuid}`);
216 cy.get("[data-cy=collection-info-panel")
217 .should("contain", this.testCollection.name)
218 .and("not.contain", "Color: Magenta")
219 .and("not.contain", "Size: S");
220 cy.get("[data-cy=collection-panel-options-btn]").click();
221 cy.get("[data-cy=context-menu]").contains("View details").click();
223 cy.get("[data-cy=details-panel]").within(() => {
224 cy.get("[data-cy=details-panel-edit-btn]").click();
226 cy.get("[data-cy=form-dialog").contains("Edit Collection");
228 // Key: Color (IDTAGCOLORS) - Value: Magenta (IDVALCOLORS3)
229 cy.get("[data-cy=resource-properties-form]").within(() => {
230 cy.get("[data-cy=property-field-key]").within(() => {
231 cy.get("input").type("Color");
233 cy.get("[data-cy=property-field-value]").within(() => {
234 cy.get("input").type("Magenta");
238 // Confirm proper vocabulary labels are displayed on the UI.
239 cy.get("[data-cy=form-dialog]").should("contain", "Color: Magenta");
241 // Case-insensitive on-blur auto-selection test
242 // Key: Size (IDTAGSIZES) - Value: Small (IDVALSIZES2)
243 cy.get("[data-cy=resource-properties-form]").within(() => {
244 cy.get("[data-cy=property-field-key]").within(() => {
245 cy.get("input").type("sIzE");
247 cy.get("[data-cy=property-field-value]").within(() => {
248 cy.get("input").type("sMaLL");
250 // simulate tabbing out of the value field
255 // Confirm proper vocabulary labels are displayed on the UI.
256 cy.get("[data-cy=form-dialog]").should("contain", "Size: S");
258 cy.get("[data-cy=form-dialog]").contains("Save").click();
259 cy.get("[data-cy=form-dialog]").should("not.exist");
261 // Confirm proper vocabulary IDs were saved on the backend.
262 cy.doRequest("GET", `/arvados/v1/collections/${this.testCollection.uuid}`)
266 expect(this.collection.properties.IDTAGCOLORS).to.equal("IDVALCOLORS3");
267 expect(this.collection.properties.IDTAGSIZES).to.equal("IDVALSIZES2");
270 // Confirm properties display on the UI.
271 cy.get("[data-cy=collection-info-panel")
272 .should("contain", this.testCollection.name)
273 .and("contain", "Color: Magenta")
274 .and("contain", "Size: S");
278 it("shows collection by URL", function () {
279 cy.loginAs(activeUser);
280 [true, false].map(function (isWritable) {
281 // Using different file names to avoid test flakyness: the second iteration
282 // on this loop may pass an assertion from the first iteration by looking
283 // for the same file name.
284 const fileName = isWritable ? "bar" : "foo";
285 const subDirName = "subdir";
286 cy.createGroup(adminUser.token, {
287 name: "Shared project",
288 group_class: "project",
292 // Creates the collection using the admin token so we can set up
293 // a bogus manifest text without block signatures.
294 cy.doRequest("GET", "/arvados/v1/config", null, null)
296 .should(clusterConfig => {
297 expect(clusterConfig.Collections, "clusterConfig").to.have.property("TrustAllContent", true);
298 expect(clusterConfig.Services, "clusterConfig").to.have.property("WebDAV").have.property("ExternalURL");
299 expect(clusterConfig.Services, "clusterConfig").to.have.property("WebDAVDownload").have.property("ExternalURL");
301 clusterConfig.Services.WebDAV.ExternalURL !== ""
302 ? clusterConfig.Services.WebDAV.ExternalURL
303 : clusterConfig.Services.WebDAVDownload.ExternalURL;
304 expect(inlineUrl).to.not.contain("*");
306 .createCollection(adminUser.token, {
307 name: "Test collection",
308 owner_uuid: this.sharedGroup.uuid,
309 properties: { someKey: "someValue" },
310 manifest_text: `. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:${fileName}\n./${subDirName} 37b51d194a7513e45b56f6524f2d51f2+3 0:3:${fileName}\n`,
312 .as("testCollection")
314 // Share the group with active user.
315 cy.createLink(adminUser.token, {
316 name: isWritable ? "can_write" : "can_read",
317 link_class: "permission",
318 head_uuid: this.sharedGroup.uuid,
319 tail_uuid: activeUser.user.uuid,
321 cy.goToPath(`/collections/${this.testCollection.uuid}`);
323 // Check that name & uuid are correct.
324 cy.get("[data-cy=collection-info-panel]")
325 .should("contain", this.testCollection.name)
326 .and("contain", this.testCollection.uuid)
327 .and("not.contain", "This is an old version");
328 // Check for the read-only icon
329 cy.get("[data-cy=read-only-icon]").should(`${isWritable ? "not." : ""}exist`);
330 // Check that both read and write operations are available on
331 // the 'More options' menu.
332 cy.get("[data-cy=collection-panel-options-btn]").click();
333 cy.get("[data-cy=context-menu]")
334 .should("contain", "Add to favorites")
335 .and(`${isWritable ? "" : "not."}contain`, "Edit collection");
336 cy.get("body").click(); // Collapse the menu avoiding details panel expansion
337 cy.get("[data-cy=collection-info-panel]")
338 .should("contain", "someKey: someValue")
339 .and("not.contain", "anotherKey: anotherValue");
340 // Check that the file listing show both read & write operations
342 .get("[data-cy=collection-files-panel]")
344 cy.get("[data-cy=collection-files-right-panel]", { timeout: 5000 }).should("contain", fileName);
346 cy.get("[data-cy=upload-button]").should(`${isWritable ? "" : "not."}contain`, "Upload data");
349 // Test context menus
350 cy.get("[data-cy=collection-files-panel]").contains(fileName).rightclick();
351 cy.get("[data-cy=context-menu]")
352 .should("contain", "Download")
353 .and("contain", "Open in new tab")
354 .and("contain", "Copy link to latest version")
355 .and("contain", "Copy link to immutable version")
356 .and(`${isWritable ? "" : "not."}contain`, "Rename")
357 .and(`${isWritable ? "" : "not."}contain`, "Remove");
358 cy.get("body").click(); // Collapse the menu
359 cy.get("[data-cy=collection-files-panel]").contains(subDirName).rightclick();
360 cy.get("[data-cy=context-menu]")
361 .should("not.contain", "Download")
362 .and("contain", "Open in new tab")
363 .and("contain", "Copy link to latest version")
364 .and("contain", "Copy link to immutable version")
365 .and(`${isWritable ? "" : "not."}contain`, "Rename")
366 .and(`${isWritable ? "" : "not."}contain`, "Remove");
367 cy.get("body").click(); // Collapse the menu
368 // File/dir item 'more options' button
369 cy.get("[data-cy=file-item-options-btn").first().click();
370 cy.get("[data-cy=context-menu]").should(`${isWritable ? "" : "not."}contain`, "Remove");
371 cy.get("body").click(); // Collapse the menu
372 // Hamburger 'more options' menu button
373 cy.get("[data-cy=collection-files-panel-options-btn]").click();
374 cy.get("[data-cy=context-menu]").should("contain", "Select all").click();
375 cy.get("[data-cy=collection-files-panel-options-btn]").click();
376 cy.get("[data-cy=context-menu]").should(`${isWritable ? "" : "not."}contain`, "Remove selected");
377 cy.get("body").click(); // Collapse the menu
383 it("renames a file using valid names", function () {
384 function eachPair(lst, func) {
385 for (var i = 0; i < lst.length - 1; i++) {
386 func(lst[i], lst[i + 1]);
389 // Creates the collection using the admin token so we can set up
390 // a bogus manifest text without block signatures.
391 cy.createCollection(adminUser.token, {
392 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
393 owner_uuid: activeUser.user.uuid,
394 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n",
396 .as("testCollection")
398 cy.loginAs(activeUser);
399 cy.goToPath(`/collections/${this.testCollection.uuid}`);
402 "bar", // initial name already set
409 "some name with whitespaces",
411 "is this name legal? I hope it is",
419 "G%C3%BCnter's%20file.pdf",
421 "bar", // make sure we can go back to the original name as a last step
423 cy.intercept({ method: "PUT", url: "**/arvados/v1/collections/*" }).as("renameRequest");
424 eachPair(names, (from, to) => {
425 cy.waitForDom().get("[data-cy=collection-files-panel]").contains(`${from}`).rightclick();
426 cy.get("[data-cy=context-menu]").contains("Rename").click();
427 cy.get("[data-cy=form-dialog]")
428 .should("contain", "Rename")
430 cy.get("input").type("{selectall}{backspace}").type(to, { parseSpecialCharSequences: false });
432 cy.get("[data-cy=form-submit-btn]").click();
433 cy.wait("@renameRequest");
434 cy.get("[data-cy=collection-files-panel]").should("not.contain", `${from}`).and("contain", `${to}`);
439 it("renames a file to a different directory", function () {
440 // Creates the collection using the admin token so we can set up
441 // a bogus manifest text without block signatures.
442 cy.createCollection(adminUser.token, {
443 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
444 owner_uuid: activeUser.user.uuid,
445 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n",
447 .as("testCollection")
449 cy.loginAs(activeUser);
450 cy.goToPath(`/collections/${this.testCollection.uuid}`);
452 ["subdir", "G%C3%BCnter's%20file", "table%&?*2"].forEach(subdir => {
453 cy.waitForDom().get("[data-cy=collection-files-panel]").contains("bar").rightclick();
454 cy.get("[data-cy=context-menu]").contains("Rename").click();
455 cy.get("[data-cy=form-dialog]")
456 .should("contain", "Rename")
458 cy.get("input").type(`{selectall}{backspace}${subdir}/foo`);
460 cy.get("[data-cy=form-submit-btn]").click();
461 cy.get("[data-cy=collection-files-panel]").should("not.contain", "bar").and("contain", subdir);
462 cy.get("[data-cy=collection-files-panel]").contains(subdir).click();
464 // Rename 'subdir/foo' to 'bar'
466 cy.get("[data-cy=collection-files-panel]").contains("foo").rightclick();
467 cy.get("[data-cy=context-menu]").contains("Rename").click();
468 cy.get("[data-cy=form-dialog]")
469 .should("contain", "Rename")
471 cy.get("input").should("have.value", `${subdir}/foo`).type(`{selectall}{backspace}bar`);
473 cy.get("[data-cy=form-submit-btn]").click();
475 // need to wait for dialog to dismiss
476 cy.get("[data-cy=form-dialog]").should("not.exist");
478 cy.waitForDom().get("[data-cy=collection-files-panel]").contains("Home").click();
481 cy.get("[data-cy=collection-files-panel]")
482 .should("contain", subdir) // empty dir kept
483 .and("contain", "bar");
485 cy.get("[data-cy=collection-files-panel]").contains(subdir).rightclick();
486 cy.get("[data-cy=context-menu]").contains("Remove").click();
487 cy.get("[data-cy=confirmation-dialog-ok-btn]").click();
488 cy.get("[data-cy=form-dialog]").should("not.exist");
493 it("shows collection owner", () => {
494 cy.createCollection(adminUser.token, {
495 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
496 owner_uuid: activeUser.user.uuid,
497 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n",
499 .as("testCollection")
500 .then(testCollection => {
501 cy.loginAs(activeUser);
502 cy.goToPath(`/collections/${testCollection.uuid}`);
504 cy.get("[data-cy=collection-info-panel]").contains(`Collection User`);
508 it("tries to rename a file with illegal names", function () {
509 // Creates the collection using the admin token so we can set up
510 // a bogus manifest text without block signatures.
511 cy.createCollection(adminUser.token, {
512 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
513 owner_uuid: activeUser.user.uuid,
514 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n",
516 .as("testCollection")
518 cy.loginAs(activeUser);
519 cy.goToPath(`/collections/${this.testCollection.uuid}`);
521 const illegalNamesFromUI = [
522 [".", "Name cannot be '.' or '..'"],
523 ["..", "Name cannot be '.' or '..'"],
524 ["", "This field is required"],
525 [" ", "Leading/trailing whitespaces not allowed"],
526 [" foo", "Leading/trailing whitespaces not allowed"],
527 ["foo ", "Leading/trailing whitespaces not allowed"],
528 ["//foo", "Empty dir name not allowed"],
530 illegalNamesFromUI.forEach(([name, errMsg]) => {
531 cy.get("[data-cy=collection-files-panel]").contains("bar").rightclick();
532 cy.get("[data-cy=context-menu]").contains("Rename").click();
533 cy.get("[data-cy=form-dialog]")
534 .should("contain", "Rename")
536 cy.get("input").type(`{selectall}{backspace}${name}`);
538 cy.get("[data-cy=form-dialog]")
539 .should("contain", "Rename")
541 cy.contains(`${errMsg}`);
543 cy.get("[data-cy=form-cancel-btn]").click();
548 it("can correctly display old versions", function () {
549 const colName = `Versioned Collection ${Math.floor(Math.random() * 999999)}`;
551 let oldVersionUuid = "";
552 // Make sure no other collections with this name exist
553 cy.doRequest("GET", "/arvados/v1/collections", null, {
554 filters: `[["name", "=", "${colName}"]]`,
555 include_old_versions: true,
560 expect(this.collections).to.be.empty;
562 // Creates the collection using the admin token so we can set up
563 // a bogus manifest text without block signatures.
564 cy.createCollection(adminUser.token, {
566 owner_uuid: activeUser.user.uuid,
567 preserve_version: true,
568 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n",
570 .as("originalVersion")
572 // Change the file name to create a new version.
573 cy.updateCollection(adminUser.token, this.originalVersion.uuid, {
574 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo\n",
576 colUuid = this.originalVersion.uuid;
578 // Confirm that there are 2 versions of the collection
579 cy.doRequest("GET", "/arvados/v1/collections", null, {
580 filters: `[["name", "=", "${colName}"]]`,
581 include_old_versions: true,
586 expect(this.collections).to.have.lengthOf(2);
587 this.collections.map(function (aCollection) {
588 expect(aCollection.current_version_uuid).to.equal(colUuid);
589 if (aCollection.uuid !== aCollection.current_version_uuid) {
590 oldVersionUuid = aCollection.uuid;
593 // Check the old version displays as what it is.
594 cy.loginAs(activeUser);
595 cy.goToPath(`/collections/${oldVersionUuid}`);
597 cy.get("[data-cy=collection-info-panel]").should("contain", "This is an old version");
598 cy.get("[data-cy=read-only-icon]").should("exist");
599 cy.get("[data-cy=collection-info-panel]").should("contain", colName);
600 cy.get("[data-cy=collection-files-panel]").should("contain", "bar");
604 it("views & edits storage classes data", function () {
605 const colName = `Test Collection ${Math.floor(Math.random() * 999999)}`;
606 cy.createCollection(adminUser.token, {
608 owner_uuid: activeUser.user.uuid,
609 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:some-file\n",
613 expect(this.collection.storage_classes_desired).to.deep.equal(["default"]);
615 cy.loginAs(activeUser);
616 cy.goToPath(`/collections/${this.collection.uuid}`);
618 // Initial check: it should show the 'default' storage class
619 cy.get("[data-cy=collection-info-panel]")
620 .should("contain", "Storage classes")
621 .and("contain", "default")
622 .and("not.contain", "foo")
623 .and("not.contain", "bar");
624 // Edit collection: add storage class 'foo'
625 cy.get("[data-cy=collection-panel-options-btn]").click();
626 cy.get("[data-cy=context-menu]").contains("Edit collection").click();
627 cy.get("[data-cy=form-dialog]")
628 .should("contain", "Edit Collection")
629 .and("contain", "Storage classes")
630 .and("contain", "default")
631 .and("contain", "foo")
632 .and("contain", "bar")
634 cy.get("[data-cy=checkbox-foo]").click();
636 cy.get("[data-cy=form-submit-btn]").click();
637 cy.get("[data-cy=collection-info-panel]").should("contain", "default").and("contain", "foo").and("not.contain", "bar");
638 cy.doRequest("GET", `/arvados/v1/collections/${this.collection.uuid}`)
640 .as("updatedCollection")
642 expect(this.updatedCollection.storage_classes_desired).to.deep.equal(["default", "foo"]);
644 // Edit collection: remove storage class 'default'
645 cy.get("[data-cy=collection-panel-options-btn]").click();
646 cy.get("[data-cy=context-menu]").contains("Edit collection").click();
647 cy.get("[data-cy=form-dialog]")
648 .should("contain", "Edit Collection")
649 .and("contain", "Storage classes")
650 .and("contain", "default")
651 .and("contain", "foo")
652 .and("contain", "bar")
654 cy.get("[data-cy=checkbox-default]").click();
656 cy.get("[data-cy=form-submit-btn]").click();
657 cy.get("[data-cy=collection-info-panel]").should("not.contain", "default").and("contain", "foo").and("not.contain", "bar");
658 cy.doRequest("GET", `/arvados/v1/collections/${this.collection.uuid}`)
660 .as("updatedCollection")
662 expect(this.updatedCollection.storage_classes_desired).to.deep.equal(["foo"]);
667 it("moves a collection to a different project", function () {
668 const collName = `Test Collection ${Math.floor(Math.random() * 999999)}`;
669 const projName = `Test Project ${Math.floor(Math.random() * 999999)}`;
670 const fileName = `Test_File_${Math.floor(Math.random() * 999999)}`;
672 cy.createCollection(adminUser.token, {
674 owner_uuid: activeUser.user.uuid,
675 manifest_text: `. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:${fileName}\n`,
676 }).as("testCollection");
677 cy.createGroup(adminUser.token, {
679 group_class: "project",
680 owner_uuid: activeUser.user.uuid,
681 }).as("testProject");
683 cy.getAll("@testCollection", "@testProject").then(function ([testCollection, testProject]) {
684 cy.loginAs(activeUser);
685 cy.goToPath(`/collections/${testCollection.uuid}`);
686 cy.get("[data-cy=collection-files-panel]").should("contain", fileName);
687 cy.get("[data-cy=collection-info-panel]").should("not.contain", projName).and("not.contain", testProject.uuid);
688 cy.get("[data-cy=collection-panel-options-btn]").click();
689 cy.get("[data-cy=context-menu]").contains("Move to").click();
690 cy.get("[data-cy=form-dialog]")
691 .should("contain", "Move to")
693 // must use .then to avoid selecting instead of expanding https://github.com/cypress-io/cypress/issues/5529
694 cy.get("[data-cy=projects-tree-home-tree-picker]")
696 .then(el => el.click());
697 cy.get("[data-cy=projects-tree-home-tree-picker]").contains(projName).click();
699 cy.get("[data-cy=form-submit-btn]").click();
700 cy.get("[data-cy=snackbar]").contains("Collection has been moved");
701 cy.get("[data-cy=collection-info-panel]").contains(projName).and("contain", testProject.uuid);
702 // Double check that the collection is in the project
703 cy.goToPath(`/projects/${testProject.uuid}`);
704 cy.waitForDom().get("[data-cy=project-panel]").should("contain", collName);
708 it("automatically updates the collection UI contents without using the Refresh button", function () {
709 const collName = `Test Collection ${Math.floor(Math.random() * 999999)}`;
711 cy.createCollection(adminUser.token, {
713 owner_uuid: activeUser.user.uuid,
714 }).as("testCollection");
716 cy.getAll("@testCollection").then(function ([testCollection]) {
717 cy.loginAs(activeUser);
719 const files = ["foobar", "anotherFile", "", "finalName"];
721 cy.goToPath(`/collections/${testCollection.uuid}`);
722 cy.get("[data-cy=collection-files-panel]").should("contain", "This collection is empty");
723 cy.get("[data-cy=collection-files-panel]").should("not.contain", files[0]);
724 cy.get("[data-cy=collection-info-panel]").should("contain", collName);
726 files.map((fileName, i, files) => {
727 cy.updateCollection(adminUser.token, testCollection.uuid, {
728 name: `${collName + " updated"}`,
729 manifest_text: fileName ? `. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:${fileName}\n` : "",
730 }).as("updatedCollection");
731 cy.getAll("@updatedCollection").then(function ([updatedCollection]) {
732 expect(updatedCollection.name).to.equal(`${collName + " updated"}`);
733 cy.get("[data-cy=collection-info-panel]").should("contain", updatedCollection.name);
735 ? cy.get("[data-cy=collection-files-panel]").should("contain", fileName)
736 : cy.get("[data-cy=collection-files-panel]").should("not.contain", files[i - 1]);
742 it("makes a copy of an existing collection", function () {
743 const collName = `Test Collection ${Math.floor(Math.random() * 999999)}`;
744 const copyName = `Copy of: ${collName}`;
746 cy.createCollection(adminUser.token, {
748 owner_uuid: activeUser.user.uuid,
749 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:some-file\n",
753 cy.loginAs(activeUser);
754 cy.goToPath(`/collections/${this.collection.uuid}`);
755 cy.get("[data-cy=collection-files-panel]").should("contain", "some-file");
756 cy.get("[data-cy=collection-panel-options-btn]").click();
757 cy.get("[data-cy=context-menu]").contains("Make a copy").click();
758 cy.get("[data-cy=form-dialog]")
759 .should("contain", "Make a copy")
761 cy.get("[data-cy=projects-tree-home-tree-picker]").contains("Projects").click();
762 cy.get("[data-cy=form-submit-btn]").click();
764 cy.get("[data-cy=snackbar]").contains("Collection has been copied.");
765 cy.get("[data-cy=snackbar-goto-action]").click();
766 cy.get("[data-cy=project-panel]").contains(copyName).click();
767 cy.get("[data-cy=collection-files-panel]").should("contain", "some-file");
771 it("uses the collection version browser to view a previous version", function () {
772 const colName = `Test Collection ${Math.floor(Math.random() * 999999)}`;
774 // Creates the collection using the admin token so we can set up
775 // a bogus manifest text without block signatures.
776 cy.createCollection(adminUser.token, {
778 owner_uuid: activeUser.user.uuid,
779 preserve_version: true,
780 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo 0:3:bar\n",
784 // Visit collection, check basic information
785 cy.loginAs(activeUser);
786 cy.goToPath(`/collections/${this.collection.uuid}`);
788 cy.get("[data-cy=collection-info-panel]").should("not.contain", "This is an old version");
789 cy.get("[data-cy=read-only-icon]").should("not.exist");
790 cy.get("[data-cy=collection-version-number]").should("contain", "1");
791 cy.get("[data-cy=collection-info-panel]").should("contain", colName);
792 cy.get("[data-cy=collection-files-panel]").should("contain", "foo").and("contain", "bar");
794 // Modify collection, expect version number change
795 cy.get("[data-cy=collection-files-panel]").contains("foo").rightclick();
796 cy.get("[data-cy=context-menu]").contains("Remove").click();
797 cy.get("[data-cy=confirmation-dialog]").should("contain", "Removing file");
798 cy.get("[data-cy=confirmation-dialog-ok-btn]").click();
799 cy.get("[data-cy=collection-version-number]").should("contain", "2");
800 cy.get("[data-cy=collection-files-panel]").should("not.contain", "foo").and("contain", "bar");
802 // Click on version number, check version browser. Click on past version.
803 cy.get("[data-cy=collection-version-browser]").should("not.exist");
804 cy.get("[data-cy=collection-version-number]").contains("2").click();
805 cy.get("[data-cy=collection-version-browser]")
806 .should("contain", "Nr")
807 .and("contain", "Size")
808 .and("contain", "Date")
810 // Version 1: 6 bytes in size
811 cy.get("[data-cy=collection-version-browser-select-1]")
812 .should("contain", "1")
813 .and("contain", "6 B")
814 .and("contain", adminUser.user.full_name);
815 // Version 2: 3 bytes in size (one file removed)
816 cy.get("[data-cy=collection-version-browser-select-2]")
817 .should("contain", "2")
818 .and("contain", "3 B")
819 .and("contain", activeUser.user.full_name);
820 cy.get("[data-cy=collection-version-browser-select-3]").should("not.exist");
821 cy.get("[data-cy=collection-version-browser-select-1]").click();
823 cy.get("[data-cy=collection-info-panel]").should("contain", "This is an old version");
824 cy.get("[data-cy=read-only-icon]").should("exist");
825 cy.get("[data-cy=collection-version-number]").should("contain", "1");
826 cy.get("[data-cy=collection-info-panel]").should("contain", colName);
827 cy.get("[data-cy=collection-files-panel]").should("contain", "foo").and("contain", "bar");
829 // Check that only old collection action are available on context menu
830 cy.get("[data-cy=collection-panel-options-btn]").click();
831 cy.get("[data-cy=context-menu]").should("contain", "Restore version").and("not.contain", "Add to favorites");
832 cy.get("body").click(); // Collapse the menu avoiding details panel expansion
834 // Click on "head version" link, confirm that it's the latest version.
835 cy.get("[data-cy=collection-info-panel]").contains("head version").click();
836 cy.get("[data-cy=collection-info-panel]").should("not.contain", "This is an old version");
837 cy.get("[data-cy=read-only-icon]").should("not.exist");
838 cy.get("[data-cy=collection-version-number]").should("contain", "2");
839 cy.get("[data-cy=collection-info-panel]").should("contain", colName);
840 cy.get("[data-cy=collection-files-panel]").should("not.contain", "foo").and("contain", "bar");
842 // Check that old collection action isn't available on context menu
843 cy.get("[data-cy=collection-panel-options-btn]").click();
844 cy.get("[data-cy=context-menu]").should("not.contain", "Restore version");
845 cy.get("body").click(); // Collapse the menu avoiding details panel expansion
847 // Make another change, confirm new version.
848 cy.get("[data-cy=collection-panel-options-btn]").click();
849 cy.get("[data-cy=context-menu]").contains("Edit collection").click();
850 cy.get("[data-cy=form-dialog]")
851 .should("contain", "Edit Collection")
854 cy.get("input").first().type(" renamed");
856 cy.get("[data-cy=form-submit-btn]").click();
857 cy.get("[data-cy=collection-info-panel]").should("not.contain", "This is an old version");
858 cy.get("[data-cy=read-only-icon]").should("not.exist");
859 cy.get("[data-cy=collection-version-number]").should("contain", "3");
860 cy.get("[data-cy=collection-info-panel]").should("contain", colName + " renamed");
861 cy.get("[data-cy=collection-files-panel]").should("not.contain", "foo").and("contain", "bar");
862 cy.get("[data-cy=collection-version-browser-select-3]").should("contain", "3").and("contain", "3 B");
864 // Check context menus on version browser
866 cy.get("[data-cy=collection-version-browser-select-3]").rightclick();
867 cy.get("[data-cy=context-menu]")
868 .should("contain", "Add to favorites")
869 .and("contain", "Make a copy")
870 .and("contain", "Edit collection");
871 cy.get("body").click();
872 // (and now an old version...)
873 cy.get("[data-cy=collection-version-browser-select-1]").rightclick();
874 cy.get("[data-cy=context-menu]")
875 .should("not.contain", "Add to favorites")
876 .and("contain", "Make a copy")
877 .and("not.contain", "Edit collection");
878 cy.get("body").click();
880 // Restore first version
881 cy.get("[data-cy=collection-version-browser]").within(() => {
882 cy.get("[data-cy=collection-version-browser-select-1]").click();
884 cy.get("[data-cy=collection-panel-options-btn]").click();
885 cy.get("[data-cy=context-menu]").contains("Restore version").click();
886 cy.get("[data-cy=confirmation-dialog]").should("contain", "Restore version");
887 cy.get("[data-cy=confirmation-dialog-ok-btn]").click();
888 cy.get("[data-cy=collection-info-panel]").should("not.contain", "This is an old version");
889 cy.get("[data-cy=collection-version-number]").should("contain", "4");
890 cy.get("[data-cy=collection-info-panel]").should("contain", colName);
891 cy.get("[data-cy=collection-files-panel]").should("contain", "foo").and("contain", "bar");
895 it("copies selected files into new collection", () => {
896 cy.createCollection(adminUser.token, {
897 name: `Test Collection ${Math.floor(Math.random() * 999999)}`,
898 owner_uuid: activeUser.user.uuid,
899 preserve_version: true,
900 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo 0:3:bar\n",
904 // Visit collection, check basic information
905 cy.loginAs(activeUser);
906 cy.goToPath(`/collections/${this.collection.uuid}`);
908 cy.get("[data-cy=collection-files-panel]").within(() => {
909 cy.get("input[type=checkbox]").first().click();
912 cy.get("[data-cy=collection-files-panel-options-btn]").click();
913 cy.get("[data-cy=context-menu]").contains("Copy selected into new collection").click();
915 cy.get("[data-cy=form-dialog]").contains("Projects").click();
917 cy.get("[data-cy=form-submit-btn]").click();
919 cy.waitForDom().get(".layout-pane-primary", { timeout: 12000 }).contains("Projects").click();
921 cy.waitForDom().get("main").contains(`Files extracted from: ${this.collection.name}`).click();
922 cy.get("[data-cy=collection-files-panel]").and("contain", "bar");
926 it("copies selected files into existing collection", () => {
927 cy.createCollection(adminUser.token, {
928 name: `Test Collection ${Math.floor(Math.random() * 999999)}`,
929 owner_uuid: activeUser.user.uuid,
930 preserve_version: true,
931 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo 0:3:bar\n",
932 }).as("sourceCollection");
934 cy.createCollection(adminUser.token, {
935 name: `Destination Collection ${Math.floor(Math.random() * 999999)}`,
936 owner_uuid: activeUser.user.uuid,
937 preserve_version: true,
939 }).as("destinationCollection");
941 cy.getAll("@sourceCollection", "@destinationCollection").then(function ([sourceCollection, destinationCollection]) {
942 // Visit collection, check basic information
943 cy.loginAs(activeUser);
944 cy.goToPath(`/collections/${sourceCollection.uuid}`);
946 cy.get("[data-cy=collection-files-panel]").within(() => {
947 cy.get("input[type=checkbox]").first().click();
950 cy.get("[data-cy=collection-files-panel-options-btn]").click();
951 cy.get("[data-cy=context-menu]").contains("Copy selected into existing collection").click();
953 cy.get("[data-cy=form-dialog]").contains(destinationCollection.name).click();
955 cy.get("[data-cy=form-submit-btn]").click();
958 cy.goToPath(`/collections/${destinationCollection.uuid}`);
960 cy.get("main").contains(destinationCollection.name).should("exist");
961 cy.get("[data-cy=collection-files-panel]").and("contain", "bar");
965 it("copies selected files into separate collections", () => {
966 cy.createCollection(adminUser.token, {
967 name: `Test Collection ${Math.floor(Math.random() * 999999)}`,
968 owner_uuid: activeUser.user.uuid,
969 preserve_version: true,
970 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo 0:3:bar\n",
971 }).as("sourceCollection");
973 cy.getAll("@sourceCollection").then(function ([sourceCollection]) {
974 // Visit collection, check basic information
975 cy.loginAs(activeUser);
976 cy.goToPath(`/collections/${sourceCollection.uuid}`);
980 .get("[data-cy=collection-files-panel]")
982 cy.get("input[type=checkbox]").first().click();
983 cy.get("input[type=checkbox]").last().click();
986 // Copy to separate collections
987 cy.get("[data-cy=collection-files-panel-options-btn]").click();
988 cy.get("[data-cy=context-menu]").contains("Copy selected into separate collections").click();
989 cy.get("[data-cy=form-dialog]").contains("Projects").click();
990 cy.get("[data-cy=form-submit-btn]").click();
992 // Verify created collections
993 cy.waitForDom().get(".layout-pane-primary", { timeout: 12000 }).contains("Projects").click();
994 cy.get("main").contains(`File copied from collection ${sourceCollection.name}/foo`).click();
995 cy.get("[data-cy=collection-files-panel]").and("contain", "foo");
996 cy.get(".layout-pane-primary").contains("Projects").click();
997 cy.get("main").contains(`File copied from collection ${sourceCollection.name}/bar`).click();
998 cy.get("[data-cy=collection-files-panel]").and("contain", "bar");
1000 // Verify separate collection menu items not present when single file selected
1001 // Wait for dom for collection to re-render
1003 .get("[data-cy=collection-files-panel]")
1005 cy.get("input[type=checkbox]").first().click();
1007 cy.get("[data-cy=collection-files-panel-options-btn]").click();
1008 cy.get("[data-cy=context-menu]").should("not.contain", "Copy selected into separate collections");
1009 cy.get("[data-cy=context-menu]").should("not.contain", "Move selected into separate collections");
1013 it("moves selected files into new collection", () => {
1014 cy.createCollection(adminUser.token, {
1015 name: `Test Collection ${Math.floor(Math.random() * 999999)}`,
1016 owner_uuid: activeUser.user.uuid,
1017 preserve_version: true,
1018 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo 0:3:bar\n",
1022 // Visit collection, check basic information
1023 cy.loginAs(activeUser);
1024 cy.goToPath(`/collections/${this.collection.uuid}`);
1026 cy.get("[data-cy=collection-files-panel]").within(() => {
1027 cy.get("input[type=checkbox]").first().click();
1030 cy.get("[data-cy=collection-files-panel-options-btn]").click();
1031 cy.get("[data-cy=context-menu]").contains("Move selected into new collection").click();
1033 cy.get("[data-cy=form-dialog]").contains("Projects").click();
1035 cy.get("[data-cy=form-submit-btn]").click();
1037 cy.waitForDom().get(".layout-pane-primary", { timeout: 12000 }).contains("Projects").click();
1039 cy.get("main").contains(`Files moved from: ${this.collection.name}`).click();
1040 cy.get("[data-cy=collection-files-panel]").and("contain", "bar");
1044 it("moves selected files into existing collection", () => {
1045 cy.createCollection(adminUser.token, {
1046 name: `Test Collection ${Math.floor(Math.random() * 999999)}`,
1047 owner_uuid: activeUser.user.uuid,
1048 preserve_version: true,
1049 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo 0:3:bar\n",
1050 }).as("sourceCollection");
1052 cy.createCollection(adminUser.token, {
1053 name: `Destination Collection ${Math.floor(Math.random() * 999999)}`,
1054 owner_uuid: activeUser.user.uuid,
1055 preserve_version: true,
1057 }).as("destinationCollection");
1059 cy.getAll("@sourceCollection", "@destinationCollection").then(function ([sourceCollection, destinationCollection]) {
1060 // Visit collection, check basic information
1061 cy.loginAs(activeUser);
1062 cy.goToPath(`/collections/${sourceCollection.uuid}`);
1064 cy.get("[data-cy=collection-files-panel]").within(() => {
1065 cy.get("input[type=checkbox]").first().click();
1068 cy.get("[data-cy=collection-files-panel-options-btn]").click();
1069 cy.get("[data-cy=context-menu]").contains("Move selected into existing collection").click();
1071 cy.get("[data-cy=form-dialog]").contains(destinationCollection.name).click();
1073 cy.get("[data-cy=form-submit-btn]").click();
1076 cy.goToPath(`/collections/${destinationCollection.uuid}`);
1078 cy.get("main").contains(destinationCollection.name).should("exist");
1079 cy.get("[data-cy=collection-files-panel]").and("contain", "bar");
1083 it("moves selected files into separate collections", () => {
1084 cy.createCollection(adminUser.token, {
1085 name: `Test Collection ${Math.floor(Math.random() * 999999)}`,
1086 owner_uuid: activeUser.user.uuid,
1087 preserve_version: true,
1088 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo 0:3:bar\n",
1089 }).as("sourceCollection");
1091 cy.getAll("@sourceCollection").then(function ([sourceCollection]) {
1092 // Visit collection, check basic information
1093 cy.loginAs(activeUser);
1094 cy.goToPath(`/collections/${sourceCollection.uuid}`);
1096 // Select both files
1097 cy.get("[data-cy=collection-files-panel]").within(() => {
1098 cy.get("input[type=checkbox]").first().click();
1099 cy.get("input[type=checkbox]").last().click();
1102 // Copy to separate collections
1103 cy.get("[data-cy=collection-files-panel-options-btn]").click();
1104 cy.get("[data-cy=context-menu]").contains("Move selected into separate collections").click();
1105 cy.get("[data-cy=form-dialog]").contains("Projects").click();
1106 cy.get("[data-cy=form-submit-btn]").click();
1108 // Verify created collections
1109 cy.waitForDom().get(".layout-pane-primary", { timeout: 12000 }).contains("Projects").click();
1110 cy.get("main").contains(`File moved from collection ${sourceCollection.name}/foo`).click();
1111 cy.get("[data-cy=collection-files-panel]").and("contain", "foo");
1112 cy.get(".layout-pane-primary").contains("Projects").click();
1113 cy.get("main").contains(`File moved from collection ${sourceCollection.name}/bar`).click();
1114 cy.get("[data-cy=collection-files-panel]").and("contain", "bar");
1118 it("creates new collection with properties on home project", function () {
1119 cy.loginAs(activeUser);
1120 cy.goToPath(`/projects/${activeUser.user.uuid}`);
1121 cy.get("[data-cy=breadcrumb-first]").should("contain", "Projects");
1122 cy.get("[data-cy=breadcrumb-last]").should("not.exist");
1123 // Create new collection
1124 cy.get("[data-cy=side-panel-button]").click();
1125 cy.get("[data-cy=side-panel-new-collection]").click();
1126 // Name between brackets tests bugfix #17582
1127 const collName = `[Test collection (${Math.floor(999999 * Math.random())})]`;
1129 // Select a storage class.
1130 cy.get("[data-cy=form-dialog]")
1131 .should("contain", "New collection")
1132 .and("contain", "Storage classes")
1133 .and("contain", "default")
1134 .and("contain", "foo")
1135 .and("contain", "bar")
1137 cy.get("[data-cy=parent-field]").within(() => {
1138 cy.get("input").should("have.value", "Home project");
1140 cy.get("[data-cy=name-field]").within(() => {
1141 cy.get("input").type(collName);
1143 cy.get("[data-cy=checkbox-foo]").click();
1147 // Key: Color (IDTAGCOLORS) - Value: Magenta (IDVALCOLORS3)
1148 cy.get("[data-cy=form-dialog]").should("not.contain", "Color: Magenta");
1149 cy.get("[data-cy=resource-properties-form]").within(() => {
1150 cy.get("[data-cy=property-field-key]").within(() => {
1151 cy.get("input").type("Color");
1153 cy.get("[data-cy=property-field-value]").within(() => {
1154 cy.get("input").type("Magenta");
1158 // Confirm proper vocabulary labels are displayed on the UI.
1159 cy.get("[data-cy=form-dialog]").should("contain", "Color: Magenta");
1161 // Value field should not complain about being required just after
1162 // adding a new property. See #19732
1163 cy.get("[data-cy=form-dialog]").should("not.contain", "This field is required");
1165 cy.get("[data-cy=form-submit-btn]").click();
1166 // Confirm that the user was taken to the newly created collection
1167 cy.get("[data-cy=form-dialog]").should("not.exist");
1168 cy.get("[data-cy=breadcrumb-first]").should("contain", "Projects");
1170 cy.get("[data-cy=breadcrumb-last]").should('exist', { timeout: 10000 });
1171 cy.get("[data-cy=breadcrumb-last]").should("contain", collName);
1172 cy.get("[data-cy=collection-info-panel]")
1173 .should("contain", "default")
1174 .and("contain", "foo")
1175 .and("contain", "Color: Magenta")
1176 .and("not.contain", "bar");
1177 // Confirm that the collection's properties has the real values.
1178 cy.doRequest("GET", "/arvados/v1/collections", null, {
1179 filters: `[["name", "=", "${collName}"]]`,
1184 expect(this.collections).to.have.lengthOf(1);
1185 expect(this.collections[0].properties).to.have.property("IDTAGCOLORS", "IDVALCOLORS3");
1189 it("shows responsible person for collection if available", () => {
1190 cy.createCollection(adminUser.token, {
1191 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
1192 owner_uuid: activeUser.user.uuid,
1193 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n",
1194 }).as("testCollection1");
1196 cy.createCollection(adminUser.token, {
1197 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
1198 owner_uuid: adminUser.user.uuid,
1199 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n",
1201 .as("testCollection2")
1202 .then(function (testCollection2) {
1203 cy.shareWith(adminUser.token, activeUser.user.uuid, testCollection2.uuid, "can_write");
1206 cy.getAll("@testCollection1", "@testCollection2").then(function ([testCollection1, testCollection2]) {
1207 cy.loginAs(activeUser);
1209 cy.goToPath(`/collections/${testCollection1.uuid}`);
1210 cy.get("[data-cy=responsible-person-wrapper]").contains(activeUser.user.uuid);
1212 cy.goToPath(`/collections/${testCollection2.uuid}`);
1213 cy.get("[data-cy=responsible-person-wrapper]").contains(adminUser.user.uuid);
1217 describe("file upload", () => {
1219 cy.createCollection(adminUser.token, {
1220 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
1221 owner_uuid: activeUser.user.uuid,
1222 manifest_text: "./subdir 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo\n. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n",
1223 }).as("testCollection1");
1226 it("uploads a file and checks the collection UI to be fresh", () => {
1227 cy.getAll("@testCollection1").then(function ([testCollection1]) {
1228 cy.loginAs(activeUser);
1229 cy.goToPath(`/collections/${testCollection1.uuid}`);
1230 cy.get("[data-cy=upload-button]").click();
1231 cy.get("[data-cy=collection-files-panel]").contains("5mb_a.bin").should("not.exist");
1232 cy.get("[data-cy=collection-file-count]").should("contain", "2");
1233 cy.fixture("files/5mb.bin", "base64").then(content => {
1234 cy.get("[data-cy=drag-and-drop]").upload(content, "5mb_a.bin");
1235 cy.get("[data-cy=form-submit-btn]").click();
1236 cy.get("[data-cy=form-submit-btn]").should("not.exist");
1237 cy.get("[data-cy=collection-files-panel]").contains("5mb_a.bin").should("exist");
1238 cy.get("[data-cy=collection-file-count]").should("contain", "3");
1240 cy.get("[data-cy=collection-files-panel]").contains("subdir").click();
1241 cy.get("[data-cy=upload-button]").click();
1242 cy.fixture("files/5mb.bin", "base64").then(content => {
1243 cy.get("[data-cy=drag-and-drop]").upload(content, "5mb_b.bin");
1244 cy.get("[data-cy=form-submit-btn]").click();
1245 cy.waitForDom().get("[data-cy=form-submit-btn]").should("not.exist");
1246 // subdir gets unselected, I think this is a bug but
1247 // for the time being let's just make sure the test works.
1248 cy.get("[data-cy=collection-files-panel]").contains("subdir").click();
1249 cy.waitForDom().get("[data-cy=collection-files-right-panel]").contains("5mb_b.bin").should("exist");
1255 it("allows to cancel running upload", () => {
1256 cy.getAll("@testCollection1").then(function ([testCollection1]) {
1257 cy.loginAs(activeUser);
1259 cy.goToPath(`/collections/${testCollection1.uuid}`);
1261 cy.get("[data-cy=upload-button]").click();
1263 cy.fixture("files/5mb.bin", "base64").then(content => {
1264 cy.get("[data-cy=drag-and-drop]").upload(content, "5mb_a.bin");
1265 cy.get("[data-cy=drag-and-drop]").upload(content, "5mb_b.bin");
1267 cy.get("[data-cy=form-submit-btn]").click();
1269 cy.get("button").contains("Cancel").click();
1271 cy.get("[data-cy=form-submit-btn]").should("not.exist");
1276 it("allows to cancel single file from the running upload", () => {
1277 cy.getAll("@testCollection1").then(function ([testCollection1]) {
1278 cy.loginAs(activeUser);
1280 cy.goToPath(`/collections/${testCollection1.uuid}`);
1282 cy.get("[data-cy=upload-button]").click();
1284 cy.fixture("files/5mb.bin", "base64").then(content => {
1285 cy.get("[data-cy=drag-and-drop]").upload(content, "5mb_a.bin");
1286 cy.get("[data-cy=drag-and-drop]").upload(content, "5mb_b.bin");
1288 cy.get("[data-cy=form-submit-btn]").click();
1290 cy.get("button[aria-label=Remove]").eq(1).click();
1292 cy.get("[data-cy=form-submit-btn]").should("not.exist");
1294 cy.get("[data-cy=collection-files-panel]").contains("5mb_a.bin").should("exist");
1299 it("allows to cancel all files from the running upload", () => {
1300 cy.getAll("@testCollection1").then(function ([testCollection1]) {
1301 cy.loginAs(activeUser);
1303 cy.goToPath(`/collections/${testCollection1.uuid}`);
1305 // Confirm initial collection state.
1306 cy.get("[data-cy=collection-files-panel]").contains("bar").should("exist");
1307 cy.get("[data-cy=collection-files-panel]").contains("15mb_a.bin").should("not.exist");
1308 cy.get("[data-cy=collection-files-panel]").contains("15mb_b.bin").should("not.exist");
1310 cy.get("[data-cy=upload-button]").click();
1312 cy.fixture("files/15mb.bin", "base64").then(content => {
1313 cy.get("[data-cy=drag-and-drop]").upload(content, "15mb_a.bin");
1314 cy.get("[data-cy=drag-and-drop]").upload(content, "15mb_b.bin");
1316 cy.get("[data-cy=form-submit-btn]").click();
1318 cy.get("button[aria-label=Remove]").should("exist").click({ multiple: true});
1320 cy.get("[data-cy=form-submit-btn]").should("not.exist");
1322 // Confirm final collection state.
1323 cy.get("[data-cy=collection-files-panel]").contains("bar").should("exist");
1324 // The following fails, but doesn't seem to happen
1325 // in the real world. Maybe there's a race between
1326 // the PUT request finishing and the 'Remove' button
1327 // dissapearing, because sometimes just one of the 2
1328 // files gets uploaded.
1329 // Maybe this will be needed to simulate a slow network:
1330 // https://docs.cypress.io/api/commands/intercept#Convenience-functions-1
1331 // cy.get('[data-cy=collection-files-panel]')
1332 // .contains('5mb_a.bin').should('not.exist');
1333 // cy.get('[data-cy=collection-files-panel]')
1334 // .contains('5mb_b.bin').should('not.exist');