1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 const path = require("path");
7 describe("Collection panel tests", function () {
13 // Only set up common users once. These aren't set up as aliases because
14 // aliases are cleaned up after every test. Also it doesn't make sense
15 // to set the same users on beforeEach() over and over again, so we
16 // separate a little from Cypress' 'Best Practices' here.
17 cy.getUser("admin", "Admin", "User", true, true)
20 adminUser = this.adminUser;
22 cy.getUser("collectionuser1", "Collection", "User", false, true)
25 activeUser = this.activeUser;
27 downloadsFolder = Cypress.config("downloadsFolder");
30 beforeEach(function () {
32 cy.clearLocalStorage();
35 it('shows the appropriate buttons in the toolbar', () => {
37 const msButtonTooltips = [
46 'Open with 3rd party client',
51 cy.loginAs(activeUser);
52 const name = `Test collection ${Math.floor(Math.random() * 999999)}`;
53 cy.get("[data-cy=side-panel-button]").click({force: true});
54 cy.get("[data-cy=side-panel-new-collection]").click();
55 cy.get("[data-cy=form-dialog]")
56 .should("contain", "New collection")
58 cy.get("[data-cy=name-field]").within(() => {
59 cy.get("input").type(name);
61 cy.get("[data-cy=form-submit-btn]").click();
63 cy.get("[data-cy=side-panel-tree]").contains("Home Projects").click();
65 cy.get('[data-cy=data-table-row]').contains(name).should('exist').parent().parent().parent().parent().click()
67 cy.get('[data-cy=multiselect-button]').should('have.length', msButtonTooltips.length)
68 for (let i = 0; i < msButtonTooltips.length; i++) {
69 cy.get('[data-cy=multiselect-button]').eq(i).trigger('mouseover');
70 cy.get('body').contains(msButtonTooltips[i]).should('exist')
71 cy.get('[data-cy=multiselect-button]').eq(i).trigger('mouseout');
75 it("allows to download mountain duck config for a collection", () => {
76 cy.createCollection(adminUser.token, {
77 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
78 owner_uuid: activeUser.user.uuid,
79 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n",
82 .then(function (testCollection) {
83 cy.loginAs(activeUser);
84 cy.goToPath(`/collections/${testCollection.uuid}`);
86 cy.get("[data-cy=collection-panel-options-btn]").click();
87 cy.get("[data-cy=context-menu]").contains("Open with 3rd party client").click();
88 cy.get("[data-cy=download-button").click();
90 const filename = path.join(downloadsFolder, `${testCollection.name}.duck`);
92 cy.readFile(filename, { timeout: 15000 })
94 const childrenCollection = Array.prototype.slice.call(Cypress.$(body).find("dict")[0].children);
99 for (i = 0; i < childrenCollection.length; i += j) {
100 map[childrenCollection[i].outerText] = childrenCollection[i + 1].outerText;
103 cy.get("#simple-tabpanel-0")
106 const [host, port] = a.text().split("@")[1].split("/")[0].split(":");
107 expect(map["Protocol"]).to.equal("davs");
108 expect(map["UUID"]).to.equal(testCollection.uuid);
109 expect(map["Username"]).to.equal(activeUser.user.username);
110 expect(map["Port"]).to.equal(port);
111 expect(map["Hostname"]).to.equal(host);
113 expect(map["Path"]).to.equal(`/c=${testCollection.uuid}`);
117 .then(() => cy.task("clearDownload", { filename }));
121 it("attempts to use a preexisting name creating or updating a collection", function () {
122 const name = `Test collection ${Math.floor(Math.random() * 999999)}`;
123 cy.createCollection(adminUser.token, {
125 owner_uuid: activeUser.user.uuid,
126 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n",
128 cy.loginAs(activeUser);
129 cy.goToPath(`/projects/${activeUser.user.uuid}`);
130 cy.get("[data-cy=breadcrumb-first]").should("contain", "Projects");
131 cy.get("[data-cy=breadcrumb-last]").should("not.exist");
132 // Attempt to create new collection with a duplicate name
133 cy.get("[data-cy=side-panel-button]").click();
134 cy.get("[data-cy=side-panel-new-collection]").click();
135 cy.get("[data-cy=form-dialog]")
136 .should("contain", "New collection")
138 cy.get("[data-cy=name-field]").within(() => {
139 cy.get("input").type(name);
141 cy.get("[data-cy=form-submit-btn]").click();
143 // Error message should display, allowing editing the name
144 cy.get("[data-cy=form-dialog]")
146 .and("contain", "Collection with the same name already exists")
148 cy.get("[data-cy=name-field]").within(() => {
149 cy.get("input").type(" renamed");
151 cy.get("[data-cy=form-submit-btn]").click();
153 cy.get("[data-cy=form-dialog]").should("not.exist");
154 // Attempt to rename the collection with the duplicate name
155 cy.get("[data-cy=collection-panel-options-btn]").click();
156 cy.get("[data-cy=context-menu]").contains("Edit collection").click();
157 cy.get("[data-cy=form-dialog]")
158 .should("contain", "Edit Collection")
160 cy.get("[data-cy=name-field]").within(() => {
161 cy.get("input").type("{selectall}{backspace}").type(name);
163 cy.get("[data-cy=form-submit-btn]").click();
165 cy.get("[data-cy=form-dialog]").should("exist").and("contain", "Collection with the same name already exists");
170 it("uses the property editor (from edit dialog) with vocabulary terms", function () {
171 cy.createCollection(adminUser.token, {
172 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
173 owner_uuid: activeUser.user.uuid,
174 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n",
176 .as("testCollection")
178 cy.loginAs(activeUser);
179 cy.goToPath(`/collections/${this.testCollection.uuid}`);
181 cy.get("[data-cy=collection-info-panel").should("contain", this.testCollection.name).and("not.contain", "Color: Magenta");
183 cy.get("[data-cy=collection-panel-options-btn]").click();
184 cy.get("[data-cy=context-menu]").contains("Edit collection").click();
185 cy.get("[data-cy=form-dialog]").should("contain", "Properties");
187 // Key: Color (IDTAGCOLORS) - Value: Magenta (IDVALCOLORS3)
188 cy.get("[data-cy=resource-properties-form]").within(() => {
189 cy.get("[data-cy=property-field-key]").within(() => {
190 cy.get("input").type("Color");
192 cy.get("[data-cy=property-field-value]").within(() => {
193 cy.get("input").type("Magenta");
197 // Confirm proper vocabulary labels are displayed on the UI.
198 cy.get("[data-cy=form-dialog]").should("contain", "Color: Magenta");
199 cy.get("[data-cy=form-dialog]").contains("Save").click();
200 cy.get("[data-cy=form-dialog]").should("not.exist");
201 // Confirm proper vocabulary IDs were saved on the backend.
202 cy.doRequest("GET", `/arvados/v1/collections/${this.testCollection.uuid}`)
206 expect(this.collection.properties.IDTAGCOLORS).to.equal("IDVALCOLORS3");
208 // Confirm the property is displayed on the UI.
209 cy.get("[data-cy=collection-info-panel").should("contain", this.testCollection.name).and("contain", "Color: Magenta");
215 it("uses the editor (from details panel) with vocabulary terms", function () {
216 cy.createCollection(adminUser.token, {
217 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
218 owner_uuid: activeUser.user.uuid,
219 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n",
221 .as("testCollection")
223 cy.loginAs(activeUser);
224 cy.goToPath(`/collections/${this.testCollection.uuid}`);
226 cy.get("[data-cy=collection-info-panel")
227 .should("contain", this.testCollection.name)
228 .and("not.contain", "Color: Magenta")
229 .and("not.contain", "Size: S");
230 cy.get("[data-cy=additional-info-icon]").click();
232 cy.get("[data-cy=details-panel]").within(() => {
233 cy.get("[data-cy=details-panel-edit-btn]").click();
235 cy.get("[data-cy=form-dialog").contains("Edit Collection");
237 // Key: Color (IDTAGCOLORS) - Value: Magenta (IDVALCOLORS3)
238 cy.get("[data-cy=resource-properties-form]").within(() => {
239 cy.get("[data-cy=property-field-key]").within(() => {
240 cy.get("input").type("Color");
242 cy.get("[data-cy=property-field-value]").within(() => {
243 cy.get("input").type("Magenta");
247 // Confirm proper vocabulary labels are displayed on the UI.
248 cy.get("[data-cy=form-dialog]").should("contain", "Color: Magenta");
250 // Case-insensitive on-blur auto-selection test
251 // Key: Size (IDTAGSIZES) - Value: Small (IDVALSIZES2)
252 cy.get("[data-cy=resource-properties-form]").within(() => {
253 cy.get("[data-cy=property-field-key]").within(() => {
254 cy.get("input").type("sIzE");
256 cy.get("[data-cy=property-field-value]").within(() => {
257 cy.get("input").type("sMaLL");
259 // Cannot "type()" TAB on Cypress so let's click another field
260 // to trigger the onBlur event.
261 cy.get("[data-cy=property-field-key]").click();
264 // Confirm proper vocabulary labels are displayed on the UI.
265 cy.get("[data-cy=form-dialog]").should("contain", "Size: S");
267 cy.get("[data-cy=form-dialog]").contains("Save").click();
268 cy.get("[data-cy=form-dialog]").should("not.exist");
270 // Confirm proper vocabulary IDs were saved on the backend.
271 cy.doRequest("GET", `/arvados/v1/collections/${this.testCollection.uuid}`)
275 expect(this.collection.properties.IDTAGCOLORS).to.equal("IDVALCOLORS3");
276 expect(this.collection.properties.IDTAGSIZES).to.equal("IDVALSIZES2");
279 // Confirm properties display on the UI.
280 cy.get("[data-cy=collection-info-panel")
281 .should("contain", this.testCollection.name)
282 .and("contain", "Color: Magenta")
283 .and("contain", "Size: S");
287 it("shows collection by URL", function () {
288 cy.loginAs(activeUser);
289 [true, false].map(function (isWritable) {
290 // Using different file names to avoid test flakyness: the second iteration
291 // on this loop may pass an assertion from the first iteration by looking
292 // for the same file name.
293 const fileName = isWritable ? "bar" : "foo";
294 const subDirName = "subdir";
295 cy.createGroup(adminUser.token, {
296 name: "Shared project",
297 group_class: "project",
301 // Creates the collection using the admin token so we can set up
302 // a bogus manifest text without block signatures.
303 cy.doRequest("GET", "/arvados/v1/config", null, null)
305 .should(clusterConfig => {
306 expect(clusterConfig.Collections, "clusterConfig").to.have.property("TrustAllContent", true);
307 expect(clusterConfig.Services, "clusterConfig").to.have.property("WebDAV").have.property("ExternalURL");
308 expect(clusterConfig.Services, "clusterConfig").to.have.property("WebDAVDownload").have.property("ExternalURL");
310 clusterConfig.Services.WebDAV.ExternalURL !== ""
311 ? clusterConfig.Services.WebDAV.ExternalURL
312 : clusterConfig.Services.WebDAVDownload.ExternalURL;
313 expect(inlineUrl).to.not.contain("*");
315 .createCollection(adminUser.token, {
316 name: "Test collection",
317 owner_uuid: this.sharedGroup.uuid,
318 properties: { someKey: "someValue" },
319 manifest_text: `. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:${fileName}\n./${subDirName} 37b51d194a7513e45b56f6524f2d51f2+3 0:3:${fileName}\n`,
321 .as("testCollection")
323 // Share the group with active user.
324 cy.createLink(adminUser.token, {
325 name: isWritable ? "can_write" : "can_read",
326 link_class: "permission",
327 head_uuid: this.sharedGroup.uuid,
328 tail_uuid: activeUser.user.uuid,
330 cy.goToPath(`/collections/${this.testCollection.uuid}`);
332 // Check that name & uuid are correct.
333 cy.get("[data-cy=collection-info-panel]")
334 .should("contain", this.testCollection.name)
335 .and("contain", this.testCollection.uuid)
336 .and("not.contain", "This is an old version");
337 // Check for the read-only icon
338 cy.get("[data-cy=read-only-icon]").should(`${isWritable ? "not." : ""}exist`);
339 // Check that both read and write operations are available on
340 // the 'More options' menu.
341 cy.get("[data-cy=collection-panel-options-btn]").click();
342 cy.get("[data-cy=context-menu]")
343 .should("contain", "Add to favorites")
344 .and(`${isWritable ? "" : "not."}contain`, "Edit collection");
345 cy.get("body").click(); // Collapse the menu avoiding details panel expansion
346 cy.get("[data-cy=collection-info-panel]")
347 .should("contain", "someKey: someValue")
348 .and("not.contain", "anotherKey: anotherValue");
349 // Check that the file listing show both read & write operations
351 .get("[data-cy=collection-files-panel]")
353 cy.get("[data-cy=collection-files-right-panel]", { timeout: 5000 }).should("contain", fileName);
355 cy.get("[data-cy=upload-button]").should(`${isWritable ? "" : "not."}contain`, "Upload data");
358 // Test context menus
359 cy.get("[data-cy=collection-files-panel]").contains(fileName).rightclick();
360 cy.get("[data-cy=context-menu]")
361 .should("contain", "Download")
362 .and("contain", "Open in new tab")
363 .and("contain", "Copy to clipboard")
364 .and(`${isWritable ? "" : "not."}contain`, "Rename")
365 .and(`${isWritable ? "" : "not."}contain`, "Remove");
366 cy.get("body").click(); // Collapse the menu
367 cy.get("[data-cy=collection-files-panel]").contains(subDirName).rightclick();
368 cy.get("[data-cy=context-menu]")
369 .should("not.contain", "Download")
370 .and("contain", "Open in new tab")
371 .and("contain", "Copy to clipboard")
372 .and(`${isWritable ? "" : "not."}contain`, "Rename")
373 .and(`${isWritable ? "" : "not."}contain`, "Remove");
374 cy.get("body").click(); // Collapse the menu
375 // File/dir item 'more options' button
376 cy.get("[data-cy=file-item-options-btn").first().click();
377 cy.get("[data-cy=context-menu]").should(`${isWritable ? "" : "not."}contain`, "Remove");
378 cy.get("body").click(); // Collapse the menu
379 // Hamburger 'more options' menu button
380 cy.get("[data-cy=collection-files-panel-options-btn]").click();
381 cy.get("[data-cy=context-menu]").should("contain", "Select all").click();
382 cy.get("[data-cy=collection-files-panel-options-btn]").click();
383 cy.get("[data-cy=context-menu]").should(`${isWritable ? "" : "not."}contain`, "Remove selected");
384 cy.get("body").click(); // Collapse the menu
390 it("renames a file using valid names", function () {
391 function eachPair(lst, func) {
392 for (var i = 0; i < lst.length - 1; i++) {
393 func(lst[i], lst[i + 1]);
396 // Creates the collection using the admin token so we can set up
397 // a bogus manifest text without block signatures.
398 cy.createCollection(adminUser.token, {
399 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
400 owner_uuid: activeUser.user.uuid,
401 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n",
403 .as("testCollection")
405 cy.loginAs(activeUser);
406 cy.goToPath(`/collections/${this.testCollection.uuid}`);
409 "bar", // initial name already set
416 "some name with whitespaces",
418 "is this name legal? I hope it is",
426 "G%C3%BCnter's%20file.pdf",
428 "bar", // make sure we can go back to the original name as a last step
430 cy.intercept({ method: "PUT", url: "**/arvados/v1/collections/*" }).as("renameRequest");
431 eachPair(names, (from, to) => {
432 cy.waitForDom().get("[data-cy=collection-files-panel]").contains(`${from}`).rightclick();
433 cy.get("[data-cy=context-menu]").contains("Rename").click();
434 cy.get("[data-cy=form-dialog]")
435 .should("contain", "Rename")
437 cy.get("input").type("{selectall}{backspace}").type(to, { parseSpecialCharSequences: false });
439 cy.get("[data-cy=form-submit-btn]").click();
440 cy.wait("@renameRequest");
441 cy.get("[data-cy=collection-files-panel]").should("not.contain", `${from}`).and("contain", `${to}`);
446 it("renames a file to a different directory", function () {
447 // Creates the collection using the admin token so we can set up
448 // a bogus manifest text without block signatures.
449 cy.createCollection(adminUser.token, {
450 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
451 owner_uuid: activeUser.user.uuid,
452 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n",
454 .as("testCollection")
456 cy.loginAs(activeUser);
457 cy.goToPath(`/collections/${this.testCollection.uuid}`);
459 ["subdir", "G%C3%BCnter's%20file", "table%&?*2"].forEach(subdir => {
460 cy.waitForDom().get("[data-cy=collection-files-panel]").contains("bar").rightclick();
461 cy.get("[data-cy=context-menu]").contains("Rename").click();
462 cy.get("[data-cy=form-dialog]")
463 .should("contain", "Rename")
465 cy.get("input").type(`{selectall}{backspace}${subdir}/foo`);
467 cy.get("[data-cy=form-submit-btn]").click();
468 cy.get("[data-cy=collection-files-panel]").should("not.contain", "bar").and("contain", subdir);
469 cy.get("[data-cy=collection-files-panel]").contains(subdir).click();
471 // Rename 'subdir/foo' to 'bar'
473 cy.get("[data-cy=collection-files-panel]").contains("foo").rightclick();
474 cy.get("[data-cy=context-menu]").contains("Rename").click();
475 cy.get("[data-cy=form-dialog]")
476 .should("contain", "Rename")
478 cy.get("input").should("have.value", `${subdir}/foo`).type(`{selectall}{backspace}bar`);
480 cy.get("[data-cy=form-submit-btn]").click();
482 // need to wait for dialog to dismiss
483 cy.get("[data-cy=form-dialog]").should("not.exist");
485 cy.waitForDom().get("[data-cy=collection-files-panel]").contains("Home").click();
488 cy.get("[data-cy=collection-files-panel]")
489 .should("contain", subdir) // empty dir kept
490 .and("contain", "bar");
492 cy.get("[data-cy=collection-files-panel]").contains(subdir).rightclick();
493 cy.get("[data-cy=context-menu]").contains("Remove").click();
494 cy.get("[data-cy=confirmation-dialog-ok-btn]").click();
495 cy.get("[data-cy=form-dialog]").should("not.exist");
500 it("shows collection owner", () => {
501 cy.createCollection(adminUser.token, {
502 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
503 owner_uuid: activeUser.user.uuid,
504 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n",
506 .as("testCollection")
507 .then(testCollection => {
508 cy.loginAs(activeUser);
509 cy.goToPath(`/collections/${testCollection.uuid}`);
511 cy.get("[data-cy=collection-info-panel]").contains(`Collection User`);
515 it("tries to rename a file with illegal names", function () {
516 // Creates the collection using the admin token so we can set up
517 // a bogus manifest text without block signatures.
518 cy.createCollection(adminUser.token, {
519 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
520 owner_uuid: activeUser.user.uuid,
521 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n",
523 .as("testCollection")
525 cy.loginAs(activeUser);
526 cy.goToPath(`/collections/${this.testCollection.uuid}`);
528 const illegalNamesFromUI = [
529 [".", "Name cannot be '.' or '..'"],
530 ["..", "Name cannot be '.' or '..'"],
531 ["", "This field is required"],
532 [" ", "Leading/trailing whitespaces not allowed"],
533 [" foo", "Leading/trailing whitespaces not allowed"],
534 ["foo ", "Leading/trailing whitespaces not allowed"],
535 ["//foo", "Empty dir name not allowed"],
537 illegalNamesFromUI.forEach(([name, errMsg]) => {
538 cy.get("[data-cy=collection-files-panel]").contains("bar").rightclick();
539 cy.get("[data-cy=context-menu]").contains("Rename").click();
540 cy.get("[data-cy=form-dialog]")
541 .should("contain", "Rename")
543 cy.get("input").type(`{selectall}{backspace}${name}`);
545 cy.get("[data-cy=form-dialog]")
546 .should("contain", "Rename")
548 cy.contains(`${errMsg}`);
550 cy.get("[data-cy=form-cancel-btn]").click();
555 it("can correctly display old versions", function () {
556 const colName = `Versioned Collection ${Math.floor(Math.random() * 999999)}`;
558 let oldVersionUuid = "";
559 // Make sure no other collections with this name exist
560 cy.doRequest("GET", "/arvados/v1/collections", null, {
561 filters: `[["name", "=", "${colName}"]]`,
562 include_old_versions: true,
567 expect(this.collections).to.be.empty;
569 // Creates the collection using the admin token so we can set up
570 // a bogus manifest text without block signatures.
571 cy.createCollection(adminUser.token, {
573 owner_uuid: activeUser.user.uuid,
574 preserve_version: true,
575 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n",
577 .as("originalVersion")
579 // Change the file name to create a new version.
580 cy.updateCollection(adminUser.token, this.originalVersion.uuid, {
581 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo\n",
583 colUuid = this.originalVersion.uuid;
585 // Confirm that there are 2 versions of the collection
586 cy.doRequest("GET", "/arvados/v1/collections", null, {
587 filters: `[["name", "=", "${colName}"]]`,
588 include_old_versions: true,
593 expect(this.collections).to.have.lengthOf(2);
594 this.collections.map(function (aCollection) {
595 expect(aCollection.current_version_uuid).to.equal(colUuid);
596 if (aCollection.uuid !== aCollection.current_version_uuid) {
597 oldVersionUuid = aCollection.uuid;
600 // Check the old version displays as what it is.
601 cy.loginAs(activeUser);
602 cy.goToPath(`/collections/${oldVersionUuid}`);
604 cy.get("[data-cy=collection-info-panel]").should("contain", "This is an old version");
605 cy.get("[data-cy=read-only-icon]").should("exist");
606 cy.get("[data-cy=collection-info-panel]").should("contain", colName);
607 cy.get("[data-cy=collection-files-panel]").should("contain", "bar");
611 it("views & edits storage classes data", function () {
612 const colName = `Test Collection ${Math.floor(Math.random() * 999999)}`;
613 cy.createCollection(adminUser.token, {
615 owner_uuid: activeUser.user.uuid,
616 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:some-file\n",
620 expect(this.collection.storage_classes_desired).to.deep.equal(["default"]);
622 cy.loginAs(activeUser);
623 cy.goToPath(`/collections/${this.collection.uuid}`);
625 // Initial check: it should show the 'default' storage class
626 cy.get("[data-cy=collection-info-panel]")
627 .should("contain", "Storage classes")
628 .and("contain", "default")
629 .and("not.contain", "foo")
630 .and("not.contain", "bar");
631 // Edit collection: add storage class 'foo'
632 cy.get("[data-cy=collection-panel-options-btn]").click();
633 cy.get("[data-cy=context-menu]").contains("Edit collection").click();
634 cy.get("[data-cy=form-dialog]")
635 .should("contain", "Edit Collection")
636 .and("contain", "Storage classes")
637 .and("contain", "default")
638 .and("contain", "foo")
639 .and("contain", "bar")
641 cy.get("[data-cy=checkbox-foo]").click();
643 cy.get("[data-cy=form-submit-btn]").click();
644 cy.get("[data-cy=collection-info-panel]").should("contain", "default").and("contain", "foo").and("not.contain", "bar");
645 cy.doRequest("GET", `/arvados/v1/collections/${this.collection.uuid}`)
647 .as("updatedCollection")
649 expect(this.updatedCollection.storage_classes_desired).to.deep.equal(["default", "foo"]);
651 // Edit collection: remove storage class 'default'
652 cy.get("[data-cy=collection-panel-options-btn]").click();
653 cy.get("[data-cy=context-menu]").contains("Edit collection").click();
654 cy.get("[data-cy=form-dialog]")
655 .should("contain", "Edit Collection")
656 .and("contain", "Storage classes")
657 .and("contain", "default")
658 .and("contain", "foo")
659 .and("contain", "bar")
661 cy.get("[data-cy=checkbox-default]").click();
663 cy.get("[data-cy=form-submit-btn]").click();
664 cy.get("[data-cy=collection-info-panel]").should("not.contain", "default").and("contain", "foo").and("not.contain", "bar");
665 cy.doRequest("GET", `/arvados/v1/collections/${this.collection.uuid}`)
667 .as("updatedCollection")
669 expect(this.updatedCollection.storage_classes_desired).to.deep.equal(["foo"]);
674 it("moves a collection to a different project", function () {
675 const collName = `Test Collection ${Math.floor(Math.random() * 999999)}`;
676 const projName = `Test Project ${Math.floor(Math.random() * 999999)}`;
677 const fileName = `Test_File_${Math.floor(Math.random() * 999999)}`;
679 cy.createCollection(adminUser.token, {
681 owner_uuid: activeUser.user.uuid,
682 manifest_text: `. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:${fileName}\n`,
683 }).as("testCollection");
684 cy.createGroup(adminUser.token, {
686 group_class: "project",
687 owner_uuid: activeUser.user.uuid,
688 }).as("testProject");
690 cy.getAll("@testCollection", "@testProject").then(function ([testCollection, testProject]) {
691 cy.loginAs(activeUser);
692 cy.goToPath(`/collections/${testCollection.uuid}`);
693 cy.get("[data-cy=collection-files-panel]").should("contain", fileName);
694 cy.get("[data-cy=collection-info-panel]").should("not.contain", projName).and("not.contain", testProject.uuid);
695 cy.get("[data-cy=collection-panel-options-btn]").click();
696 cy.get("[data-cy=context-menu]").contains("Move to").click();
697 cy.get("[data-cy=form-dialog]")
698 .should("contain", "Move to")
700 // must use .then to avoid selecting instead of expanding https://github.com/cypress-io/cypress/issues/5529
701 cy.get("[data-cy=projects-tree-home-tree-picker]")
703 .then(el => el.click());
704 cy.get("[data-cy=projects-tree-home-tree-picker]").contains(projName).click();
706 cy.get("[data-cy=form-submit-btn]").click();
707 cy.get("[data-cy=snackbar]").contains("Collection has been moved");
708 cy.get("[data-cy=collection-info-panel]").contains(projName).and("contain", testProject.uuid);
709 // Double check that the collection is in the project
710 cy.goToPath(`/projects/${testProject.uuid}`);
711 cy.waitForDom().get("[data-cy=project-panel]").should("contain", collName);
715 it("automatically updates the collection UI contents without using the Refresh button", function () {
716 const collName = `Test Collection ${Math.floor(Math.random() * 999999)}`;
718 cy.createCollection(adminUser.token, {
720 owner_uuid: activeUser.user.uuid,
721 }).as("testCollection");
723 cy.getAll("@testCollection").then(function ([testCollection]) {
724 cy.loginAs(activeUser);
726 const files = ["foobar", "anotherFile", "", "finalName"];
728 cy.goToPath(`/collections/${testCollection.uuid}`);
729 cy.get("[data-cy=collection-files-panel]").should("contain", "This collection is empty");
730 cy.get("[data-cy=collection-files-panel]").should("not.contain", files[0]);
731 cy.get("[data-cy=collection-info-panel]").should("contain", collName);
733 files.map((fileName, i, files) => {
734 cy.updateCollection(adminUser.token, testCollection.uuid, {
735 name: `${collName + " updated"}`,
736 manifest_text: fileName ? `. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:${fileName}\n` : "",
737 }).as("updatedCollection");
738 cy.getAll("@updatedCollection").then(function ([updatedCollection]) {
739 expect(updatedCollection.name).to.equal(`${collName + " updated"}`);
740 cy.get("[data-cy=collection-info-panel]").should("contain", updatedCollection.name);
742 ? cy.get("[data-cy=collection-files-panel]").should("contain", fileName)
743 : cy.get("[data-cy=collection-files-panel]").should("not.contain", files[i - 1]);
749 it("makes a copy of an existing collection", function () {
750 const collName = `Test Collection ${Math.floor(Math.random() * 999999)}`;
751 const copyName = `Copy of: ${collName}`;
753 cy.createCollection(adminUser.token, {
755 owner_uuid: activeUser.user.uuid,
756 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:some-file\n",
760 cy.loginAs(activeUser);
761 cy.goToPath(`/collections/${this.collection.uuid}`);
762 cy.get("[data-cy=collection-files-panel]").should("contain", "some-file");
763 cy.get("[data-cy=collection-panel-options-btn]").click();
764 cy.get("[data-cy=context-menu]").contains("Make a copy").click();
765 cy.get("[data-cy=form-dialog]")
766 .should("contain", "Make a copy")
768 cy.get("[data-cy=projects-tree-home-tree-picker]").contains("Projects").click();
769 cy.get("[data-cy=form-submit-btn]").click();
771 cy.get("[data-cy=snackbar]").contains("Collection has been copied.");
772 cy.get("[data-cy=snackbar-goto-action]").click();
773 cy.get("[data-cy=project-panel]").contains(copyName).click();
774 cy.get("[data-cy=collection-files-panel]").should("contain", "some-file");
778 it("uses the collection version browser to view a previous version", function () {
779 const colName = `Test Collection ${Math.floor(Math.random() * 999999)}`;
781 // Creates the collection using the admin token so we can set up
782 // a bogus manifest text without block signatures.
783 cy.createCollection(adminUser.token, {
785 owner_uuid: activeUser.user.uuid,
786 preserve_version: true,
787 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo 0:3:bar\n",
791 // Visit collection, check basic information
792 cy.loginAs(activeUser);
793 cy.goToPath(`/collections/${this.collection.uuid}`);
795 cy.get("[data-cy=collection-info-panel]").should("not.contain", "This is an old version");
796 cy.get("[data-cy=read-only-icon]").should("not.exist");
797 cy.get("[data-cy=collection-version-number]").should("contain", "1");
798 cy.get("[data-cy=collection-info-panel]").should("contain", colName);
799 cy.get("[data-cy=collection-files-panel]").should("contain", "foo").and("contain", "bar");
801 // Modify collection, expect version number change
802 cy.get("[data-cy=collection-files-panel]").contains("foo").rightclick();
803 cy.get("[data-cy=context-menu]").contains("Remove").click();
804 cy.get("[data-cy=confirmation-dialog]").should("contain", "Removing file");
805 cy.get("[data-cy=confirmation-dialog-ok-btn]").click();
806 cy.get("[data-cy=collection-version-number]").should("contain", "2");
807 cy.get("[data-cy=collection-files-panel]").should("not.contain", "foo").and("contain", "bar");
809 // Click on version number, check version browser. Click on past version.
810 cy.get("[data-cy=collection-version-browser]").should("not.exist");
811 cy.get("[data-cy=collection-version-number]").contains("2").click();
812 cy.get("[data-cy=collection-version-browser]")
813 .should("contain", "Nr")
814 .and("contain", "Size")
815 .and("contain", "Date")
817 // Version 1: 6 bytes in size
818 cy.get("[data-cy=collection-version-browser-select-1]")
819 .should("contain", "1")
820 .and("contain", "6 B")
821 .and("contain", adminUser.user.full_name);
822 // Version 2: 3 bytes in size (one file removed)
823 cy.get("[data-cy=collection-version-browser-select-2]")
824 .should("contain", "2")
825 .and("contain", "3 B")
826 .and("contain", activeUser.user.full_name);
827 cy.get("[data-cy=collection-version-browser-select-3]").should("not.exist");
828 cy.get("[data-cy=collection-version-browser-select-1]").click();
830 cy.get("[data-cy=collection-info-panel]").should("contain", "This is an old version");
831 cy.get("[data-cy=read-only-icon]").should("exist");
832 cy.get("[data-cy=collection-version-number]").should("contain", "1");
833 cy.get("[data-cy=collection-info-panel]").should("contain", colName);
834 cy.get("[data-cy=collection-files-panel]").should("contain", "foo").and("contain", "bar");
836 // Check that only old collection action are available on context menu
837 cy.get("[data-cy=collection-panel-options-btn]").click();
838 cy.get("[data-cy=context-menu]").should("contain", "Restore version").and("not.contain", "Add to favorites");
839 cy.get("body").click(); // Collapse the menu avoiding details panel expansion
841 // Click on "head version" link, confirm that it's the latest version.
842 cy.get("[data-cy=collection-info-panel]").contains("head version").click();
843 cy.get("[data-cy=collection-info-panel]").should("not.contain", "This is an old version");
844 cy.get("[data-cy=read-only-icon]").should("not.exist");
845 cy.get("[data-cy=collection-version-number]").should("contain", "2");
846 cy.get("[data-cy=collection-info-panel]").should("contain", colName);
847 cy.get("[data-cy=collection-files-panel]").should("not.contain", "foo").and("contain", "bar");
849 // Check that old collection action isn't available on context menu
850 cy.get("[data-cy=collection-panel-options-btn]").click();
851 cy.get("[data-cy=context-menu]").should("not.contain", "Restore version");
852 cy.get("body").click(); // Collapse the menu avoiding details panel expansion
854 // Make another change, confirm new version.
855 cy.get("[data-cy=collection-panel-options-btn]").click();
856 cy.get("[data-cy=context-menu]").contains("Edit collection").click();
857 cy.get("[data-cy=form-dialog]")
858 .should("contain", "Edit Collection")
861 cy.get("input").first().type(" renamed");
863 cy.get("[data-cy=form-submit-btn]").click();
864 cy.get("[data-cy=collection-info-panel]").should("not.contain", "This is an old version");
865 cy.get("[data-cy=read-only-icon]").should("not.exist");
866 cy.get("[data-cy=collection-version-number]").should("contain", "3");
867 cy.get("[data-cy=collection-info-panel]").should("contain", colName + " renamed");
868 cy.get("[data-cy=collection-files-panel]").should("not.contain", "foo").and("contain", "bar");
869 cy.get("[data-cy=collection-version-browser-select-3]").should("contain", "3").and("contain", "3 B");
871 // Check context menus on version browser
873 cy.get("[data-cy=collection-version-browser-select-3]").rightclick();
874 cy.get("[data-cy=context-menu]")
875 .should("contain", "Add to favorites")
876 .and("contain", "Make a copy")
877 .and("contain", "Edit collection");
878 cy.get("body").click();
879 // (and now an old version...)
880 cy.get("[data-cy=collection-version-browser-select-1]").rightclick();
881 cy.get("[data-cy=context-menu]")
882 .should("not.contain", "Add to favorites")
883 .and("contain", "Make a copy")
884 .and("not.contain", "Edit collection");
885 cy.get("body").click();
887 // Restore first version
888 cy.get("[data-cy=collection-version-browser]").within(() => {
889 cy.get("[data-cy=collection-version-browser-select-1]").click();
891 cy.get("[data-cy=collection-panel-options-btn]").click();
892 cy.get("[data-cy=context-menu]").contains("Restore version").click();
893 cy.get("[data-cy=confirmation-dialog]").should("contain", "Restore version");
894 cy.get("[data-cy=confirmation-dialog-ok-btn]").click();
895 cy.get("[data-cy=collection-info-panel]").should("not.contain", "This is an old version");
896 cy.get("[data-cy=collection-version-number]").should("contain", "4");
897 cy.get("[data-cy=collection-info-panel]").should("contain", colName);
898 cy.get("[data-cy=collection-files-panel]").should("contain", "foo").and("contain", "bar");
902 it("copies selected files into new collection", () => {
903 cy.createCollection(adminUser.token, {
904 name: `Test Collection ${Math.floor(Math.random() * 999999)}`,
905 owner_uuid: activeUser.user.uuid,
906 preserve_version: true,
907 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo 0:3:bar\n",
911 // Visit collection, check basic information
912 cy.loginAs(activeUser);
913 cy.goToPath(`/collections/${this.collection.uuid}`);
915 cy.get("[data-cy=collection-files-panel]").within(() => {
916 cy.get("input[type=checkbox]").first().click();
919 cy.get("[data-cy=collection-files-panel-options-btn]").click();
920 cy.get("[data-cy=context-menu]").contains("Copy selected into new collection").click();
922 cy.get("[data-cy=form-dialog]").contains("Projects").click();
924 cy.get("[data-cy=form-submit-btn]").click();
926 cy.waitForDom().get(".layout-pane-primary", { timeout: 12000 }).contains("Projects").click();
928 cy.waitForDom().get("main").contains(`Files extracted from: ${this.collection.name}`).click();
929 cy.get("[data-cy=collection-files-panel]").and("contain", "bar");
933 it("copies selected files into existing collection", () => {
934 cy.createCollection(adminUser.token, {
935 name: `Test Collection ${Math.floor(Math.random() * 999999)}`,
936 owner_uuid: activeUser.user.uuid,
937 preserve_version: true,
938 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo 0:3:bar\n",
939 }).as("sourceCollection");
941 cy.createCollection(adminUser.token, {
942 name: `Destination Collection ${Math.floor(Math.random() * 999999)}`,
943 owner_uuid: activeUser.user.uuid,
944 preserve_version: true,
946 }).as("destinationCollection");
948 cy.getAll("@sourceCollection", "@destinationCollection").then(function ([sourceCollection, destinationCollection]) {
949 // Visit collection, check basic information
950 cy.loginAs(activeUser);
951 cy.goToPath(`/collections/${sourceCollection.uuid}`);
953 cy.get("[data-cy=collection-files-panel]").within(() => {
954 cy.get("input[type=checkbox]").first().click();
957 cy.get("[data-cy=collection-files-panel-options-btn]").click();
958 cy.get("[data-cy=context-menu]").contains("Copy selected into existing collection").click();
960 cy.get("[data-cy=form-dialog]").contains(destinationCollection.name).click();
962 cy.get("[data-cy=form-submit-btn]").click();
965 cy.goToPath(`/collections/${destinationCollection.uuid}`);
967 cy.get("main").contains(destinationCollection.name).should("exist");
968 cy.get("[data-cy=collection-files-panel]").and("contain", "bar");
972 it("copies selected files into separate collections", () => {
973 cy.createCollection(adminUser.token, {
974 name: `Test Collection ${Math.floor(Math.random() * 999999)}`,
975 owner_uuid: activeUser.user.uuid,
976 preserve_version: true,
977 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo 0:3:bar\n",
978 }).as("sourceCollection");
980 cy.getAll("@sourceCollection").then(function ([sourceCollection]) {
981 // Visit collection, check basic information
982 cy.loginAs(activeUser);
983 cy.goToPath(`/collections/${sourceCollection.uuid}`);
987 .get("[data-cy=collection-files-panel]")
989 cy.get("input[type=checkbox]").first().click();
990 cy.get("input[type=checkbox]").last().click();
993 // Copy to separate collections
994 cy.get("[data-cy=collection-files-panel-options-btn]").click();
995 cy.get("[data-cy=context-menu]").contains("Copy selected into separate collections").click();
996 cy.get("[data-cy=form-dialog]").contains("Projects").click();
997 cy.get("[data-cy=form-submit-btn]").click();
999 // Verify created collections
1000 cy.waitForDom().get(".layout-pane-primary", { timeout: 12000 }).contains("Projects").click();
1001 cy.get("main").contains(`File copied from collection ${sourceCollection.name}/foo`).click();
1002 cy.get("[data-cy=collection-files-panel]").and("contain", "foo");
1003 cy.get(".layout-pane-primary").contains("Projects").click();
1004 cy.get("main").contains(`File copied from collection ${sourceCollection.name}/bar`).click();
1005 cy.get("[data-cy=collection-files-panel]").and("contain", "bar");
1007 // Verify separate collection menu items not present when single file selected
1008 // Wait for dom for collection to re-render
1010 .get("[data-cy=collection-files-panel]")
1012 cy.get("input[type=checkbox]").first().click();
1014 cy.get("[data-cy=collection-files-panel-options-btn]").click();
1015 cy.get("[data-cy=context-menu]").should("not.contain", "Copy selected into separate collections");
1016 cy.get("[data-cy=context-menu]").should("not.contain", "Move selected into separate collections");
1020 it("moves selected files into new collection", () => {
1021 cy.createCollection(adminUser.token, {
1022 name: `Test Collection ${Math.floor(Math.random() * 999999)}`,
1023 owner_uuid: activeUser.user.uuid,
1024 preserve_version: true,
1025 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo 0:3:bar\n",
1029 // Visit collection, check basic information
1030 cy.loginAs(activeUser);
1031 cy.goToPath(`/collections/${this.collection.uuid}`);
1033 cy.get("[data-cy=collection-files-panel]").within(() => {
1034 cy.get("input[type=checkbox]").first().click();
1037 cy.get("[data-cy=collection-files-panel-options-btn]").click();
1038 cy.get("[data-cy=context-menu]").contains("Move selected into new collection").click();
1040 cy.get("[data-cy=form-dialog]").contains("Projects").click();
1042 cy.get("[data-cy=form-submit-btn]").click();
1044 cy.waitForDom().get(".layout-pane-primary", { timeout: 12000 }).contains("Projects").click();
1046 cy.get("main").contains(`Files moved from: ${this.collection.name}`).click();
1047 cy.get("[data-cy=collection-files-panel]").and("contain", "bar");
1051 it("moves selected files into existing collection", () => {
1052 cy.createCollection(adminUser.token, {
1053 name: `Test Collection ${Math.floor(Math.random() * 999999)}`,
1054 owner_uuid: activeUser.user.uuid,
1055 preserve_version: true,
1056 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo 0:3:bar\n",
1057 }).as("sourceCollection");
1059 cy.createCollection(adminUser.token, {
1060 name: `Destination Collection ${Math.floor(Math.random() * 999999)}`,
1061 owner_uuid: activeUser.user.uuid,
1062 preserve_version: true,
1064 }).as("destinationCollection");
1066 cy.getAll("@sourceCollection", "@destinationCollection").then(function ([sourceCollection, destinationCollection]) {
1067 // Visit collection, check basic information
1068 cy.loginAs(activeUser);
1069 cy.goToPath(`/collections/${sourceCollection.uuid}`);
1071 cy.get("[data-cy=collection-files-panel]").within(() => {
1072 cy.get("input[type=checkbox]").first().click();
1075 cy.get("[data-cy=collection-files-panel-options-btn]").click();
1076 cy.get("[data-cy=context-menu]").contains("Move selected into existing collection").click();
1078 cy.get("[data-cy=form-dialog]").contains(destinationCollection.name).click();
1080 cy.get("[data-cy=form-submit-btn]").click();
1083 cy.goToPath(`/collections/${destinationCollection.uuid}`);
1085 cy.get("main").contains(destinationCollection.name).should("exist");
1086 cy.get("[data-cy=collection-files-panel]").and("contain", "bar");
1090 it("moves selected files into separate collections", () => {
1091 cy.createCollection(adminUser.token, {
1092 name: `Test Collection ${Math.floor(Math.random() * 999999)}`,
1093 owner_uuid: activeUser.user.uuid,
1094 preserve_version: true,
1095 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo 0:3:bar\n",
1096 }).as("sourceCollection");
1098 cy.getAll("@sourceCollection").then(function ([sourceCollection]) {
1099 // Visit collection, check basic information
1100 cy.loginAs(activeUser);
1101 cy.goToPath(`/collections/${sourceCollection.uuid}`);
1103 // Select both files
1104 cy.get("[data-cy=collection-files-panel]").within(() => {
1105 cy.get("input[type=checkbox]").first().click();
1106 cy.get("input[type=checkbox]").last().click();
1109 // Copy to separate collections
1110 cy.get("[data-cy=collection-files-panel-options-btn]").click();
1111 cy.get("[data-cy=context-menu]").contains("Move selected into separate collections").click();
1112 cy.get("[data-cy=form-dialog]").contains("Projects").click();
1113 cy.get("[data-cy=form-submit-btn]").click();
1115 // Verify created collections
1116 cy.waitForDom().get(".layout-pane-primary", { timeout: 12000 }).contains("Projects").click();
1117 cy.get("main").contains(`File moved from collection ${sourceCollection.name}/foo`).click();
1118 cy.get("[data-cy=collection-files-panel]").and("contain", "foo");
1119 cy.get(".layout-pane-primary").contains("Projects").click();
1120 cy.get("main").contains(`File moved from collection ${sourceCollection.name}/bar`).click();
1121 cy.get("[data-cy=collection-files-panel]").and("contain", "bar");
1125 it("creates new collection with properties on home project", function () {
1126 cy.loginAs(activeUser);
1127 cy.goToPath(`/projects/${activeUser.user.uuid}`);
1128 cy.get("[data-cy=breadcrumb-first]").should("contain", "Projects");
1129 cy.get("[data-cy=breadcrumb-last]").should("not.exist");
1130 // Create new collection
1131 cy.get("[data-cy=side-panel-button]").click();
1132 cy.get("[data-cy=side-panel-new-collection]").click();
1133 // Name between brackets tests bugfix #17582
1134 const collName = `[Test collection (${Math.floor(999999 * Math.random())})]`;
1136 // Select a storage class.
1137 cy.get("[data-cy=form-dialog]")
1138 .should("contain", "New collection")
1139 .and("contain", "Storage classes")
1140 .and("contain", "default")
1141 .and("contain", "foo")
1142 .and("contain", "bar")
1144 cy.get("[data-cy=parent-field]").within(() => {
1145 cy.get("input").should("have.value", "Home project");
1147 cy.get("[data-cy=name-field]").within(() => {
1148 cy.get("input").type(collName);
1150 cy.get("[data-cy=checkbox-foo]").click();
1154 // Key: Color (IDTAGCOLORS) - Value: Magenta (IDVALCOLORS3)
1155 cy.get("[data-cy=form-dialog]").should("not.contain", "Color: Magenta");
1156 cy.get("[data-cy=resource-properties-form]").within(() => {
1157 cy.get("[data-cy=property-field-key]").within(() => {
1158 cy.get("input").type("Color");
1160 cy.get("[data-cy=property-field-value]").within(() => {
1161 cy.get("input").type("Magenta");
1165 // Confirm proper vocabulary labels are displayed on the UI.
1166 cy.get("[data-cy=form-dialog]").should("contain", "Color: Magenta");
1168 // Value field should not complain about being required just after
1169 // adding a new property. See #19732
1170 cy.get("[data-cy=form-dialog]").should("not.contain", "This field is required");
1172 cy.get("[data-cy=form-submit-btn]").click();
1173 // Confirm that the user was taken to the newly created collection
1174 cy.get("[data-cy=form-dialog]").should("not.exist");
1175 cy.get("[data-cy=breadcrumb-first]").should("contain", "Projects");
1176 cy.get("[data-cy=breadcrumb-last]").should("contain", collName);
1177 cy.get("[data-cy=collection-info-panel]")
1178 .should("contain", "default")
1179 .and("contain", "foo")
1180 .and("contain", "Color: Magenta")
1181 .and("not.contain", "bar");
1182 // Confirm that the collection's properties has the real values.
1183 cy.doRequest("GET", "/arvados/v1/collections", null, {
1184 filters: `[["name", "=", "${collName}"]]`,
1189 expect(this.collections).to.have.lengthOf(1);
1190 expect(this.collections[0].properties).to.have.property("IDTAGCOLORS", "IDVALCOLORS3");
1194 it("shows responsible person for collection if available", () => {
1195 cy.createCollection(adminUser.token, {
1196 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
1197 owner_uuid: activeUser.user.uuid,
1198 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n",
1199 }).as("testCollection1");
1201 cy.createCollection(adminUser.token, {
1202 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
1203 owner_uuid: adminUser.user.uuid,
1204 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n",
1206 .as("testCollection2")
1207 .then(function (testCollection2) {
1208 cy.shareWith(adminUser.token, activeUser.user.uuid, testCollection2.uuid, "can_write");
1211 cy.getAll("@testCollection1", "@testCollection2").then(function ([testCollection1, testCollection2]) {
1212 cy.loginAs(activeUser);
1214 cy.goToPath(`/collections/${testCollection1.uuid}`);
1215 cy.get("[data-cy=responsible-person-wrapper]").contains(activeUser.user.uuid);
1217 cy.goToPath(`/collections/${testCollection2.uuid}`);
1218 cy.get("[data-cy=responsible-person-wrapper]").contains(adminUser.user.uuid);
1222 describe("file upload", () => {
1224 cy.createCollection(adminUser.token, {
1225 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
1226 owner_uuid: activeUser.user.uuid,
1227 manifest_text: "./subdir 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo\n. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n",
1228 }).as("testCollection1");
1231 it("uploads a file and checks the collection UI to be fresh", () => {
1232 cy.getAll("@testCollection1").then(function ([testCollection1]) {
1233 cy.loginAs(activeUser);
1234 cy.goToPath(`/collections/${testCollection1.uuid}`);
1235 cy.get("[data-cy=upload-button]").click();
1236 cy.get("[data-cy=collection-files-panel]").contains("5mb_a.bin").should("not.exist");
1237 cy.get("[data-cy=collection-file-count]").should("contain", "2");
1238 cy.fixture("files/5mb.bin", "base64").then(content => {
1239 cy.get("[data-cy=drag-and-drop]").upload(content, "5mb_a.bin");
1240 cy.get("[data-cy=form-submit-btn]").click();
1241 cy.get("[data-cy=form-submit-btn]").should("not.exist");
1242 cy.get("[data-cy=collection-files-panel]").contains("5mb_a.bin").should("exist");
1243 cy.get("[data-cy=collection-file-count]").should("contain", "3");
1245 cy.get("[data-cy=collection-files-panel]").contains("subdir").click();
1246 cy.get("[data-cy=upload-button]").click();
1247 cy.fixture("files/5mb.bin", "base64").then(content => {
1248 cy.get("[data-cy=drag-and-drop]").upload(content, "5mb_b.bin");
1249 cy.get("[data-cy=form-submit-btn]").click();
1250 cy.waitForDom().get("[data-cy=form-submit-btn]").should("not.exist");
1251 // subdir gets unselected, I think this is a bug but
1252 // for the time being let's just make sure the test works.
1253 cy.get("[data-cy=collection-files-panel]").contains("subdir").click();
1254 cy.waitForDom().get("[data-cy=collection-files-right-panel]").contains("5mb_b.bin").should("exist");
1260 it("allows to cancel running upload", () => {
1261 cy.getAll("@testCollection1").then(function ([testCollection1]) {
1262 cy.loginAs(activeUser);
1264 cy.goToPath(`/collections/${testCollection1.uuid}`);
1266 cy.get("[data-cy=upload-button]").click();
1268 cy.fixture("files/5mb.bin", "base64").then(content => {
1269 cy.get("[data-cy=drag-and-drop]").upload(content, "5mb_a.bin");
1270 cy.get("[data-cy=drag-and-drop]").upload(content, "5mb_b.bin");
1272 cy.get("[data-cy=form-submit-btn]").click();
1274 cy.get("button").contains("Cancel").click();
1276 cy.get("[data-cy=form-submit-btn]").should("not.exist");
1281 it("allows to cancel single file from the running upload", () => {
1282 cy.getAll("@testCollection1").then(function ([testCollection1]) {
1283 cy.loginAs(activeUser);
1285 cy.goToPath(`/collections/${testCollection1.uuid}`);
1287 cy.get("[data-cy=upload-button]").click();
1289 cy.fixture("files/5mb.bin", "base64").then(content => {
1290 cy.get("[data-cy=drag-and-drop]").upload(content, "5mb_a.bin");
1291 cy.get("[data-cy=drag-and-drop]").upload(content, "5mb_b.bin");
1293 cy.get("[data-cy=form-submit-btn]").click();
1295 cy.get("button[aria-label=Remove]").eq(1).click();
1297 cy.get("[data-cy=form-submit-btn]").should("not.exist");
1299 cy.get("[data-cy=collection-files-panel]").contains("5mb_a.bin").should("exist");
1304 it("allows to cancel all files from the running upload", () => {
1305 cy.getAll("@testCollection1").then(function ([testCollection1]) {
1306 cy.loginAs(activeUser);
1308 cy.goToPath(`/collections/${testCollection1.uuid}`);
1310 // Confirm initial collection state.
1311 cy.get("[data-cy=collection-files-panel]").contains("bar").should("exist");
1312 cy.get("[data-cy=collection-files-panel]").contains("5mb_a.bin").should("not.exist");
1313 cy.get("[data-cy=collection-files-panel]").contains("5mb_b.bin").should("not.exist");
1315 cy.get("[data-cy=upload-button]").click();
1317 cy.fixture("files/5mb.bin", "base64").then(content => {
1318 cy.get("[data-cy=drag-and-drop]").upload(content, "5mb_a.bin");
1319 cy.get("[data-cy=drag-and-drop]").upload(content, "5mb_b.bin");
1321 cy.get("[data-cy=form-submit-btn]").click();
1323 cy.get("button[aria-label=Remove]").should("exist");
1324 cy.get("button[aria-label=Remove]").click({ multiple: true, force: true });
1326 cy.get("[data-cy=form-submit-btn]").should("not.exist");
1328 // Confirm final collection state.
1329 cy.get("[data-cy=collection-files-panel]").contains("bar").should("exist");
1330 // The following fails, but doesn't seem to happen
1331 // in the real world. Maybe there's a race between
1332 // the PUT request finishing and the 'Remove' button
1333 // dissapearing, because sometimes just one of the 2
1334 // files gets uploaded.
1335 // Maybe this will be needed to simulate a slow network:
1336 // https://docs.cypress.io/api/commands/intercept#Convenience-functions-1
1337 // cy.get('[data-cy=collection-files-panel]')
1338 // .contains('5mb_a.bin').should('not.exist');
1339 // cy.get('[data-cy=collection-files-panel]')
1340 // .contains('5mb_b.bin').should('not.exist');