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 it('shows the appropriate buttons in the toolbar', () => {
32 const msButtonTooltips = [
35 'Copy link to clipboard',
36 'Open with 3rd party client',
46 cy.loginAs(activeUser);
47 const name = `Test collection ${Math.floor(Math.random() * 999999)}`;
48 cy.get("[data-cy=side-panel-button]").click({force: true});
49 cy.get("[data-cy=side-panel-new-collection]").click();
50 cy.get("[data-cy=form-dialog]")
51 .should("contain", "New collection")
53 cy.get("[data-cy=name-field]").within(() => {
54 cy.get("input").type(name);
56 cy.get("[data-cy=form-submit-btn]").click();
58 cy.get("[data-cy=side-panel-tree]").contains("Home Projects").click();
60 cy.get('[data-cy=data-table-row]').contains(name).should('exist').parents('td').click()
62 cy.get('[data-cy=multiselect-button]').should('have.length', msButtonTooltips.length)
63 msButtonTooltips.forEach((tooltip, index) => {
64 cy.get('[data-cy=multiselect-button]').eq(index).parent().should('have.attr', 'aria-label', tooltip)
68 it("allows to download mountain duck config for a collection", () => {
69 cy.createCollection(adminUser.token, {
70 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
71 owner_uuid: activeUser.user.uuid,
72 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n",
75 .then(function (testCollection) {
76 cy.loginAs(activeUser);
77 cy.goToPath(`/collections/${testCollection.uuid}`);
79 cy.get("[data-cy=collection-panel-options-btn]").click();
80 cy.get("[data-cy=context-menu]").contains("Open with 3rd party client").click();
81 cy.get("[data-cy=download-button").click();
83 const filename = path.join(downloadsFolder, `${testCollection.name}.duck`);
85 cy.readFile(filename, { timeout: 15000 })
87 const childrenCollection = Array.prototype.slice.call(Cypress.$(body).find("dict")[0].children);
92 for (i = 0; i < childrenCollection.length; i += j) {
93 map[childrenCollection[i].outerText] = childrenCollection[i + 1].outerText;
96 cy.get("#simple-tabpanel-0")
99 const [host, port] = a.text().split("@")[1].split("/")[0].split(":");
100 expect(map["Protocol"]).to.equal("davs");
101 expect(map["UUID"]).to.equal(testCollection.uuid);
102 expect(map["Username"]).to.equal(activeUser.user.username);
103 expect(map["Port"]).to.equal(port);
104 expect(map["Hostname"]).to.equal(host);
106 expect(map["Path"]).to.equal(`/c=${testCollection.uuid}`);
110 .then(() => cy.task("clearDownload", { filename }));
114 it("attempts to use a preexisting name creating or updating a collection", function () {
115 const name = `Test collection ${Math.floor(Math.random() * 999999)}`;
116 cy.createCollection(adminUser.token, {
118 owner_uuid: activeUser.user.uuid,
119 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n",
121 cy.loginAs(activeUser);
122 cy.goToPath(`/projects/${activeUser.user.uuid}`);
123 cy.get("[data-cy=breadcrumb-first]").should("contain", "Projects");
124 cy.get("[data-cy=breadcrumb-last]").should("not.exist");
125 // Attempt to create new collection with a duplicate name
126 cy.get("[data-cy=side-panel-button]").click();
127 cy.get("[data-cy=side-panel-new-collection]").click();
128 cy.get("[data-cy=form-dialog]")
129 .should("contain", "New collection")
131 cy.get("[data-cy=name-field]").within(() => {
132 cy.get("input").type(name);
134 cy.get("[data-cy=form-submit-btn]").click();
136 // Error message should display, allowing editing the name
137 cy.get("[data-cy=form-dialog]")
139 .and("contain", "Collection with the same name already exists")
141 cy.get("[data-cy=name-field]").within(() => {
142 cy.get("input").type(" renamed");
144 cy.get("[data-cy=form-submit-btn]").click({timeout: 10000});
146 cy.get("[data-cy=form-dialog]").should("not.exist");
147 // Attempt to rename the collection with the duplicate name
148 cy.get("[data-cy=collection-panel-options-btn]").click();
149 cy.get("[data-cy=context-menu]").contains("Edit collection").click();
150 cy.get("[data-cy=form-dialog]")
151 .should("contain", "Edit Collection")
153 cy.get("[data-cy=name-field]").within(() => {
154 cy.get("input").type("{selectall}{backspace}").type(name);
156 cy.get("[data-cy=form-submit-btn]").click();
158 cy.get("[data-cy=form-dialog]").should("exist").and("contain", "Collection with the same name already exists");
161 it("uses the property editor (from edit dialog) with vocabulary terms", function () {
162 cy.createCollection(adminUser.token, {
163 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
164 owner_uuid: activeUser.user.uuid,
165 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n",
167 .as("testCollection")
169 cy.loginAs(activeUser);
170 cy.goToPath(`/collections/${this.testCollection.uuid}`);
172 cy.get("[data-cy=collection-info-panel").should("contain", this.testCollection.name).and("not.contain", "Color: Magenta");
174 cy.get("[data-cy=collection-panel-options-btn]").click();
175 cy.get("[data-cy=context-menu]").contains("Edit collection").click();
176 cy.get("[data-cy=form-dialog]").should("contain", "Properties");
178 // Key: Color (IDTAGCOLORS) - Value: Magenta (IDVALCOLORS3)
179 cy.get("[data-cy=resource-properties-form]").within(() => {
180 cy.get("[data-cy=property-field-key]").within(() => {
181 cy.get("input").type("Color");
183 cy.get("[data-cy=property-field-value]").within(() => {
184 cy.get("input").type("Magenta");
188 // Confirm proper vocabulary labels are displayed on the UI.
189 cy.get("[data-cy=form-dialog]").should("contain", "Color: Magenta");
190 cy.get("[data-cy=form-dialog]").contains("Save").click();
191 cy.get("[data-cy=form-dialog]").should("not.exist");
192 // Confirm proper vocabulary IDs were saved on the backend.
193 cy.doRequest("GET", `/arvados/v1/collections/${this.testCollection.uuid}`)
197 expect(this.collection.properties.IDTAGCOLORS).to.equal("IDVALCOLORS3");
199 // Confirm the property is displayed on the UI.
200 cy.get("[data-cy=collection-info-panel").should("contain", this.testCollection.name).and("contain", "Color: Magenta");
204 it("uses the editor (from details panel) with vocabulary terms", function () {
205 cy.createCollection(adminUser.token, {
206 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
207 owner_uuid: activeUser.user.uuid,
208 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n",
210 .as("testCollection")
212 cy.loginAs(activeUser);
213 cy.goToPath(`/collections/${this.testCollection.uuid}`);
215 cy.get("[data-cy=collection-info-panel")
216 .should("contain", this.testCollection.name)
217 .and("not.contain", "Color: Magenta")
218 .and("not.contain", "Size: S");
219 cy.get("[data-cy=additional-info-icon]").click();
221 cy.get("[data-cy=details-panel]").within(() => {
222 cy.get("[data-cy=details-panel-edit-btn]").click();
224 cy.get("[data-cy=form-dialog").contains("Edit Collection");
226 // Key: Color (IDTAGCOLORS) - Value: Magenta (IDVALCOLORS3)
227 cy.get("[data-cy=resource-properties-form]").within(() => {
228 cy.get("[data-cy=property-field-key]").within(() => {
229 cy.get("input").type("Color");
231 cy.get("[data-cy=property-field-value]").within(() => {
232 cy.get("input").type("Magenta");
236 // Confirm proper vocabulary labels are displayed on the UI.
237 cy.get("[data-cy=form-dialog]").should("contain", "Color: Magenta");
239 // Case-insensitive on-blur auto-selection test
240 // Key: Size (IDTAGSIZES) - Value: Small (IDVALSIZES2)
241 cy.get("[data-cy=resource-properties-form]").within(() => {
242 cy.get("[data-cy=property-field-key]").within(() => {
243 cy.get("input").type("sIzE");
245 cy.get("[data-cy=property-field-value]").within(() => {
246 cy.get("input").type("sMaLL");
248 // Cannot "type()" TAB on Cypress so let's click another field
249 // to trigger the onBlur event.
250 cy.get("[data-cy=property-field-key]").click();
253 // Confirm proper vocabulary labels are displayed on the UI.
254 cy.get("[data-cy=form-dialog]").should("contain", "Size: S");
256 cy.get("[data-cy=form-dialog]").contains("Save").click();
257 cy.get("[data-cy=form-dialog]").should("not.exist");
259 // Confirm proper vocabulary IDs were saved on the backend.
260 cy.doRequest("GET", `/arvados/v1/collections/${this.testCollection.uuid}`)
264 expect(this.collection.properties.IDTAGCOLORS).to.equal("IDVALCOLORS3");
265 expect(this.collection.properties.IDTAGSIZES).to.equal("IDVALSIZES2");
268 // Confirm properties display on the UI.
269 cy.get("[data-cy=collection-info-panel")
270 .should("contain", this.testCollection.name)
271 .and("contain", "Color: Magenta")
272 .and("contain", "Size: S");
276 it("shows collection by URL", function () {
277 cy.loginAs(activeUser);
278 [true, false].map(function (isWritable) {
279 // Using different file names to avoid test flakyness: the second iteration
280 // on this loop may pass an assertion from the first iteration by looking
281 // for the same file name.
282 const fileName = isWritable ? "bar" : "foo";
283 const subDirName = "subdir";
284 cy.createGroup(adminUser.token, {
285 name: "Shared project",
286 group_class: "project",
290 // Creates the collection using the admin token so we can set up
291 // a bogus manifest text without block signatures.
292 cy.doRequest("GET", "/arvados/v1/config", null, null)
294 .should(clusterConfig => {
295 expect(clusterConfig.Collections, "clusterConfig").to.have.property("TrustAllContent", true);
296 expect(clusterConfig.Services, "clusterConfig").to.have.property("WebDAV").have.property("ExternalURL");
297 expect(clusterConfig.Services, "clusterConfig").to.have.property("WebDAVDownload").have.property("ExternalURL");
299 clusterConfig.Services.WebDAV.ExternalURL !== ""
300 ? clusterConfig.Services.WebDAV.ExternalURL
301 : clusterConfig.Services.WebDAVDownload.ExternalURL;
302 expect(inlineUrl).to.not.contain("*");
304 .createCollection(adminUser.token, {
305 name: "Test collection",
306 owner_uuid: this.sharedGroup.uuid,
307 properties: { someKey: "someValue" },
308 manifest_text: `. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:${fileName}\n./${subDirName} 37b51d194a7513e45b56f6524f2d51f2+3 0:3:${fileName}\n`,
310 .as("testCollection")
312 // Share the group with active user.
313 cy.createLink(adminUser.token, {
314 name: isWritable ? "can_write" : "can_read",
315 link_class: "permission",
316 head_uuid: this.sharedGroup.uuid,
317 tail_uuid: activeUser.user.uuid,
319 cy.goToPath(`/collections/${this.testCollection.uuid}`);
321 // Check that name & uuid are correct.
322 cy.get("[data-cy=collection-info-panel]")
323 .should("contain", this.testCollection.name)
324 .and("contain", this.testCollection.uuid)
325 .and("not.contain", "This is an old version");
326 // Check for the read-only icon
327 cy.get("[data-cy=read-only-icon]").should(`${isWritable ? "not." : ""}exist`);
328 // Check that both read and write operations are available on
329 // the 'More options' menu.
330 cy.get("[data-cy=collection-panel-options-btn]").click();
331 cy.get("[data-cy=context-menu]")
332 .should("contain", "Add to favorites")
333 .and(`${isWritable ? "" : "not."}contain`, "Edit collection");
334 cy.get("body").click(); // Collapse the menu avoiding details panel expansion
335 cy.get("[data-cy=collection-info-panel]")
336 .should("contain", "someKey: someValue")
337 .and("not.contain", "anotherKey: anotherValue");
338 // Check that the file listing show both read & write operations
340 .get("[data-cy=collection-files-panel]")
342 cy.get("[data-cy=collection-files-right-panel]", { timeout: 5000 }).should("contain", fileName);
344 cy.get("[data-cy=upload-button]").should(`${isWritable ? "" : "not."}contain`, "Upload data");
347 // Test context menus
348 cy.get("[data-cy=collection-files-panel]").contains(fileName).rightclick();
349 cy.get("[data-cy=context-menu]")
350 .should("contain", "Download")
351 .and("contain", "Open in new tab")
352 .and("contain", "Copy link to clipboard")
353 .and(`${isWritable ? "" : "not."}contain`, "Rename")
354 .and(`${isWritable ? "" : "not."}contain`, "Remove");
355 cy.get("body").click(); // Collapse the menu
356 cy.get("[data-cy=collection-files-panel]").contains(subDirName).rightclick();
357 cy.get("[data-cy=context-menu]")
358 .should("not.contain", "Download")
359 .and("contain", "Open in new tab")
360 .and("contain", "Copy link to clipboard")
361 .and(`${isWritable ? "" : "not."}contain`, "Rename")
362 .and(`${isWritable ? "" : "not."}contain`, "Remove");
363 cy.get("body").click(); // Collapse the menu
364 // File/dir item 'more options' button
365 cy.get("[data-cy=file-item-options-btn").first().click();
366 cy.get("[data-cy=context-menu]").should(`${isWritable ? "" : "not."}contain`, "Remove");
367 cy.get("body").click(); // Collapse the menu
368 // Hamburger 'more options' menu button
369 cy.get("[data-cy=collection-files-panel-options-btn]").click();
370 cy.get("[data-cy=context-menu]").should("contain", "Select all").click();
371 cy.get("[data-cy=collection-files-panel-options-btn]").click();
372 cy.get("[data-cy=context-menu]").should(`${isWritable ? "" : "not."}contain`, "Remove selected");
373 cy.get("body").click(); // Collapse the menu
379 it("renames a file using valid names", function () {
380 function eachPair(lst, func) {
381 for (var i = 0; i < lst.length - 1; i++) {
382 func(lst[i], lst[i + 1]);
385 // Creates the collection using the admin token so we can set up
386 // a bogus manifest text without block signatures.
387 cy.createCollection(adminUser.token, {
388 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
389 owner_uuid: activeUser.user.uuid,
390 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n",
392 .as("testCollection")
394 cy.loginAs(activeUser);
395 cy.goToPath(`/collections/${this.testCollection.uuid}`);
398 "bar", // initial name already set
405 "some name with whitespaces",
407 "is this name legal? I hope it is",
415 "G%C3%BCnter's%20file.pdf",
417 "bar", // make sure we can go back to the original name as a last step
419 cy.intercept({ method: "PUT", url: "**/arvados/v1/collections/*" }).as("renameRequest");
420 eachPair(names, (from, to) => {
421 cy.waitForDom().get("[data-cy=collection-files-panel]").contains(`${from}`).rightclick();
422 cy.get("[data-cy=context-menu]").contains("Rename").click();
423 cy.get("[data-cy=form-dialog]")
424 .should("contain", "Rename")
426 cy.get("input").type("{selectall}{backspace}").type(to, { parseSpecialCharSequences: false });
428 cy.get("[data-cy=form-submit-btn]").click();
429 cy.wait("@renameRequest");
430 cy.get("[data-cy=collection-files-panel]").should("not.contain", `${from}`).and("contain", `${to}`);
435 it("renames a file to a different directory", function () {
436 // Creates the collection using the admin token so we can set up
437 // a bogus manifest text without block signatures.
438 cy.createCollection(adminUser.token, {
439 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
440 owner_uuid: activeUser.user.uuid,
441 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n",
443 .as("testCollection")
445 cy.loginAs(activeUser);
446 cy.goToPath(`/collections/${this.testCollection.uuid}`);
448 ["subdir", "G%C3%BCnter's%20file", "table%&?*2"].forEach(subdir => {
449 cy.waitForDom().get("[data-cy=collection-files-panel]").contains("bar").rightclick();
450 cy.get("[data-cy=context-menu]").contains("Rename").click();
451 cy.get("[data-cy=form-dialog]")
452 .should("contain", "Rename")
454 cy.get("input").type(`{selectall}{backspace}${subdir}/foo`);
456 cy.get("[data-cy=form-submit-btn]").click();
457 cy.get("[data-cy=collection-files-panel]").should("not.contain", "bar").and("contain", subdir);
458 cy.get("[data-cy=collection-files-panel]").contains(subdir).click();
460 // Rename 'subdir/foo' to 'bar'
462 cy.get("[data-cy=collection-files-panel]").contains("foo").rightclick();
463 cy.get("[data-cy=context-menu]").contains("Rename").click();
464 cy.get("[data-cy=form-dialog]")
465 .should("contain", "Rename")
467 cy.get("input").should("have.value", `${subdir}/foo`).type(`{selectall}{backspace}bar`);
469 cy.get("[data-cy=form-submit-btn]").click();
471 // need to wait for dialog to dismiss
472 cy.get("[data-cy=form-dialog]").should("not.exist");
474 cy.waitForDom().get("[data-cy=collection-files-panel]").contains("Home").click();
477 cy.get("[data-cy=collection-files-panel]")
478 .should("contain", subdir) // empty dir kept
479 .and("contain", "bar");
481 cy.get("[data-cy=collection-files-panel]").contains(subdir).rightclick();
482 cy.get("[data-cy=context-menu]").contains("Remove").click();
483 cy.get("[data-cy=confirmation-dialog-ok-btn]").click();
484 cy.get("[data-cy=form-dialog]").should("not.exist");
489 it("shows collection owner", () => {
490 cy.createCollection(adminUser.token, {
491 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
492 owner_uuid: activeUser.user.uuid,
493 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n",
495 .as("testCollection")
496 .then(testCollection => {
497 cy.loginAs(activeUser);
498 cy.goToPath(`/collections/${testCollection.uuid}`);
500 cy.get("[data-cy=collection-info-panel]").contains(`Collection User`);
504 it("tries to rename a file with illegal names", function () {
505 // Creates the collection using the admin token so we can set up
506 // a bogus manifest text without block signatures.
507 cy.createCollection(adminUser.token, {
508 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
509 owner_uuid: activeUser.user.uuid,
510 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n",
512 .as("testCollection")
514 cy.loginAs(activeUser);
515 cy.goToPath(`/collections/${this.testCollection.uuid}`);
517 const illegalNamesFromUI = [
518 [".", "Name cannot be '.' or '..'"],
519 ["..", "Name cannot be '.' or '..'"],
520 ["", "This field is required"],
521 [" ", "Leading/trailing whitespaces not allowed"],
522 [" foo", "Leading/trailing whitespaces not allowed"],
523 ["foo ", "Leading/trailing whitespaces not allowed"],
524 ["//foo", "Empty dir name not allowed"],
526 illegalNamesFromUI.forEach(([name, errMsg]) => {
527 cy.get("[data-cy=collection-files-panel]").contains("bar").rightclick();
528 cy.get("[data-cy=context-menu]").contains("Rename").click();
529 cy.get("[data-cy=form-dialog]")
530 .should("contain", "Rename")
532 cy.get("input").type(`{selectall}{backspace}${name}`);
534 cy.get("[data-cy=form-dialog]")
535 .should("contain", "Rename")
537 cy.contains(`${errMsg}`);
539 cy.get("[data-cy=form-cancel-btn]").click();
544 it("can correctly display old versions", function () {
545 const colName = `Versioned Collection ${Math.floor(Math.random() * 999999)}`;
547 let oldVersionUuid = "";
548 // Make sure no other collections with this name exist
549 cy.doRequest("GET", "/arvados/v1/collections", null, {
550 filters: `[["name", "=", "${colName}"]]`,
551 include_old_versions: true,
556 expect(this.collections).to.be.empty;
558 // Creates the collection using the admin token so we can set up
559 // a bogus manifest text without block signatures.
560 cy.createCollection(adminUser.token, {
562 owner_uuid: activeUser.user.uuid,
563 preserve_version: true,
564 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n",
566 .as("originalVersion")
568 // Change the file name to create a new version.
569 cy.updateCollection(adminUser.token, this.originalVersion.uuid, {
570 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo\n",
572 colUuid = this.originalVersion.uuid;
574 // Confirm that there are 2 versions of the collection
575 cy.doRequest("GET", "/arvados/v1/collections", null, {
576 filters: `[["name", "=", "${colName}"]]`,
577 include_old_versions: true,
582 expect(this.collections).to.have.lengthOf(2);
583 this.collections.map(function (aCollection) {
584 expect(aCollection.current_version_uuid).to.equal(colUuid);
585 if (aCollection.uuid !== aCollection.current_version_uuid) {
586 oldVersionUuid = aCollection.uuid;
589 // Check the old version displays as what it is.
590 cy.loginAs(activeUser);
591 cy.goToPath(`/collections/${oldVersionUuid}`);
593 cy.get("[data-cy=collection-info-panel]").should("contain", "This is an old version");
594 cy.get("[data-cy=read-only-icon]").should("exist");
595 cy.get("[data-cy=collection-info-panel]").should("contain", colName);
596 cy.get("[data-cy=collection-files-panel]").should("contain", "bar");
600 it("views & edits storage classes data", function () {
601 const colName = `Test Collection ${Math.floor(Math.random() * 999999)}`;
602 cy.createCollection(adminUser.token, {
604 owner_uuid: activeUser.user.uuid,
605 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:some-file\n",
609 expect(this.collection.storage_classes_desired).to.deep.equal(["default"]);
611 cy.loginAs(activeUser);
612 cy.goToPath(`/collections/${this.collection.uuid}`);
614 // Initial check: it should show the 'default' storage class
615 cy.get("[data-cy=collection-info-panel]")
616 .should("contain", "Storage classes")
617 .and("contain", "default")
618 .and("not.contain", "foo")
619 .and("not.contain", "bar");
620 // Edit collection: add storage class 'foo'
621 cy.get("[data-cy=collection-panel-options-btn]").click();
622 cy.get("[data-cy=context-menu]").contains("Edit collection").click();
623 cy.get("[data-cy=form-dialog]")
624 .should("contain", "Edit Collection")
625 .and("contain", "Storage classes")
626 .and("contain", "default")
627 .and("contain", "foo")
628 .and("contain", "bar")
630 cy.get("[data-cy=checkbox-foo]").click();
632 cy.get("[data-cy=form-submit-btn]").click();
633 cy.get("[data-cy=collection-info-panel]").should("contain", "default").and("contain", "foo").and("not.contain", "bar");
634 cy.doRequest("GET", `/arvados/v1/collections/${this.collection.uuid}`)
636 .as("updatedCollection")
638 expect(this.updatedCollection.storage_classes_desired).to.deep.equal(["default", "foo"]);
640 // Edit collection: remove storage class 'default'
641 cy.get("[data-cy=collection-panel-options-btn]").click();
642 cy.get("[data-cy=context-menu]").contains("Edit collection").click();
643 cy.get("[data-cy=form-dialog]")
644 .should("contain", "Edit Collection")
645 .and("contain", "Storage classes")
646 .and("contain", "default")
647 .and("contain", "foo")
648 .and("contain", "bar")
650 cy.get("[data-cy=checkbox-default]").click();
652 cy.get("[data-cy=form-submit-btn]").click();
653 cy.get("[data-cy=collection-info-panel]").should("not.contain", "default").and("contain", "foo").and("not.contain", "bar");
654 cy.doRequest("GET", `/arvados/v1/collections/${this.collection.uuid}`)
656 .as("updatedCollection")
658 expect(this.updatedCollection.storage_classes_desired).to.deep.equal(["foo"]);
663 it("moves a collection to a different project", function () {
664 const collName = `Test Collection ${Math.floor(Math.random() * 999999)}`;
665 const projName = `Test Project ${Math.floor(Math.random() * 999999)}`;
666 const fileName = `Test_File_${Math.floor(Math.random() * 999999)}`;
668 cy.createCollection(adminUser.token, {
670 owner_uuid: activeUser.user.uuid,
671 manifest_text: `. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:${fileName}\n`,
672 }).as("testCollection");
673 cy.createGroup(adminUser.token, {
675 group_class: "project",
676 owner_uuid: activeUser.user.uuid,
677 }).as("testProject");
679 cy.getAll("@testCollection", "@testProject").then(function ([testCollection, testProject]) {
680 cy.loginAs(activeUser);
681 cy.goToPath(`/collections/${testCollection.uuid}`);
682 cy.get("[data-cy=collection-files-panel]").should("contain", fileName);
683 cy.get("[data-cy=collection-info-panel]").should("not.contain", projName).and("not.contain", testProject.uuid);
684 cy.get("[data-cy=collection-panel-options-btn]").click();
685 cy.get("[data-cy=context-menu]").contains("Move to").click();
686 cy.get("[data-cy=form-dialog]")
687 .should("contain", "Move to")
689 // must use .then to avoid selecting instead of expanding https://github.com/cypress-io/cypress/issues/5529
690 cy.get("[data-cy=projects-tree-home-tree-picker]")
692 .then(el => el.click());
693 cy.get("[data-cy=projects-tree-home-tree-picker]").contains(projName).click();
695 cy.get("[data-cy=form-submit-btn]").click();
696 cy.get("[data-cy=snackbar]").contains("Collection has been moved");
697 cy.get("[data-cy=collection-info-panel]").contains(projName).and("contain", testProject.uuid);
698 // Double check that the collection is in the project
699 cy.goToPath(`/projects/${testProject.uuid}`);
700 cy.waitForDom().get("[data-cy=project-panel]").should("contain", collName);
704 it("automatically updates the collection UI contents without using the Refresh button", function () {
705 const collName = `Test Collection ${Math.floor(Math.random() * 999999)}`;
707 cy.createCollection(adminUser.token, {
709 owner_uuid: activeUser.user.uuid,
710 }).as("testCollection");
712 cy.getAll("@testCollection").then(function ([testCollection]) {
713 cy.loginAs(activeUser);
715 const files = ["foobar", "anotherFile", "", "finalName"];
717 cy.goToPath(`/collections/${testCollection.uuid}`);
718 cy.get("[data-cy=collection-files-panel]").should("contain", "This collection is empty");
719 cy.get("[data-cy=collection-files-panel]").should("not.contain", files[0]);
720 cy.get("[data-cy=collection-info-panel]").should("contain", collName);
722 files.map((fileName, i, files) => {
723 cy.updateCollection(adminUser.token, testCollection.uuid, {
724 name: `${collName + " updated"}`,
725 manifest_text: fileName ? `. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:${fileName}\n` : "",
726 }).as("updatedCollection");
727 cy.getAll("@updatedCollection").then(function ([updatedCollection]) {
728 expect(updatedCollection.name).to.equal(`${collName + " updated"}`);
729 cy.get("[data-cy=collection-info-panel]").should("contain", updatedCollection.name);
731 ? cy.get("[data-cy=collection-files-panel]").should("contain", fileName)
732 : cy.get("[data-cy=collection-files-panel]").should("not.contain", files[i - 1]);
738 it("makes a copy of an existing collection", function () {
739 const collName = `Test Collection ${Math.floor(Math.random() * 999999)}`;
740 const copyName = `Copy of: ${collName}`;
742 cy.createCollection(adminUser.token, {
744 owner_uuid: activeUser.user.uuid,
745 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:some-file\n",
749 cy.loginAs(activeUser);
750 cy.goToPath(`/collections/${this.collection.uuid}`);
751 cy.get("[data-cy=collection-files-panel]").should("contain", "some-file");
752 cy.get("[data-cy=collection-panel-options-btn]").click();
753 cy.get("[data-cy=context-menu]").contains("Make a copy").click();
754 cy.get("[data-cy=form-dialog]")
755 .should("contain", "Make a copy")
757 cy.get("[data-cy=projects-tree-home-tree-picker]").contains("Projects").click();
758 cy.get("[data-cy=form-submit-btn]").click();
760 cy.get("[data-cy=snackbar]").contains("Collection has been copied.");
761 cy.get("[data-cy=snackbar-goto-action]").click();
762 cy.get("[data-cy=project-panel]").contains(copyName).click();
763 cy.get("[data-cy=collection-files-panel]").should("contain", "some-file");
767 it("uses the collection version browser to view a previous version", function () {
768 const colName = `Test Collection ${Math.floor(Math.random() * 999999)}`;
770 // Creates the collection using the admin token so we can set up
771 // a bogus manifest text without block signatures.
772 cy.createCollection(adminUser.token, {
774 owner_uuid: activeUser.user.uuid,
775 preserve_version: true,
776 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo 0:3:bar\n",
780 // Visit collection, check basic information
781 cy.loginAs(activeUser);
782 cy.goToPath(`/collections/${this.collection.uuid}`);
784 cy.get("[data-cy=collection-info-panel]").should("not.contain", "This is an old version");
785 cy.get("[data-cy=read-only-icon]").should("not.exist");
786 cy.get("[data-cy=collection-version-number]").should("contain", "1");
787 cy.get("[data-cy=collection-info-panel]").should("contain", colName);
788 cy.get("[data-cy=collection-files-panel]").should("contain", "foo").and("contain", "bar");
790 // Modify collection, expect version number change
791 cy.get("[data-cy=collection-files-panel]").contains("foo").rightclick();
792 cy.get("[data-cy=context-menu]").contains("Remove").click();
793 cy.get("[data-cy=confirmation-dialog]").should("contain", "Removing file");
794 cy.get("[data-cy=confirmation-dialog-ok-btn]").click();
795 cy.get("[data-cy=collection-version-number]").should("contain", "2");
796 cy.get("[data-cy=collection-files-panel]").should("not.contain", "foo").and("contain", "bar");
798 // Click on version number, check version browser. Click on past version.
799 cy.get("[data-cy=collection-version-browser]").should("not.exist");
800 cy.get("[data-cy=collection-version-number]").contains("2").click();
801 cy.get("[data-cy=collection-version-browser]")
802 .should("contain", "Nr")
803 .and("contain", "Size")
804 .and("contain", "Date")
806 // Version 1: 6 bytes in size
807 cy.get("[data-cy=collection-version-browser-select-1]")
808 .should("contain", "1")
809 .and("contain", "6 B")
810 .and("contain", adminUser.user.full_name);
811 // Version 2: 3 bytes in size (one file removed)
812 cy.get("[data-cy=collection-version-browser-select-2]")
813 .should("contain", "2")
814 .and("contain", "3 B")
815 .and("contain", activeUser.user.full_name);
816 cy.get("[data-cy=collection-version-browser-select-3]").should("not.exist");
817 cy.get("[data-cy=collection-version-browser-select-1]").click();
819 cy.get("[data-cy=collection-info-panel]").should("contain", "This is an old version");
820 cy.get("[data-cy=read-only-icon]").should("exist");
821 cy.get("[data-cy=collection-version-number]").should("contain", "1");
822 cy.get("[data-cy=collection-info-panel]").should("contain", colName);
823 cy.get("[data-cy=collection-files-panel]").should("contain", "foo").and("contain", "bar");
825 // Check that only old collection action are available on context menu
826 cy.get("[data-cy=collection-panel-options-btn]").click();
827 cy.get("[data-cy=context-menu]").should("contain", "Restore version").and("not.contain", "Add to favorites");
828 cy.get("body").click(); // Collapse the menu avoiding details panel expansion
830 // Click on "head version" link, confirm that it's the latest version.
831 cy.get("[data-cy=collection-info-panel]").contains("head version").click();
832 cy.get("[data-cy=collection-info-panel]").should("not.contain", "This is an old version");
833 cy.get("[data-cy=read-only-icon]").should("not.exist");
834 cy.get("[data-cy=collection-version-number]").should("contain", "2");
835 cy.get("[data-cy=collection-info-panel]").should("contain", colName);
836 cy.get("[data-cy=collection-files-panel]").should("not.contain", "foo").and("contain", "bar");
838 // Check that old collection action isn't available on context menu
839 cy.get("[data-cy=collection-panel-options-btn]").click();
840 cy.get("[data-cy=context-menu]").should("not.contain", "Restore version");
841 cy.get("body").click(); // Collapse the menu avoiding details panel expansion
843 // Make another change, confirm new version.
844 cy.get("[data-cy=collection-panel-options-btn]").click();
845 cy.get("[data-cy=context-menu]").contains("Edit collection").click();
846 cy.get("[data-cy=form-dialog]")
847 .should("contain", "Edit Collection")
850 cy.get("input").first().type(" renamed");
852 cy.get("[data-cy=form-submit-btn]").click();
853 cy.get("[data-cy=collection-info-panel]").should("not.contain", "This is an old version");
854 cy.get("[data-cy=read-only-icon]").should("not.exist");
855 cy.get("[data-cy=collection-version-number]").should("contain", "3");
856 cy.get("[data-cy=collection-info-panel]").should("contain", colName + " renamed");
857 cy.get("[data-cy=collection-files-panel]").should("not.contain", "foo").and("contain", "bar");
858 cy.get("[data-cy=collection-version-browser-select-3]").should("contain", "3").and("contain", "3 B");
860 // Check context menus on version browser
862 cy.get("[data-cy=collection-version-browser-select-3]").rightclick();
863 cy.get("[data-cy=context-menu]")
864 .should("contain", "Add to favorites")
865 .and("contain", "Make a copy")
866 .and("contain", "Edit collection");
867 cy.get("body").click();
868 // (and now an old version...)
869 cy.get("[data-cy=collection-version-browser-select-1]").rightclick();
870 cy.get("[data-cy=context-menu]")
871 .should("not.contain", "Add to favorites")
872 .and("contain", "Make a copy")
873 .and("not.contain", "Edit collection");
874 cy.get("body").click();
876 // Restore first version
877 cy.get("[data-cy=collection-version-browser]").within(() => {
878 cy.get("[data-cy=collection-version-browser-select-1]").click();
880 cy.get("[data-cy=collection-panel-options-btn]").click();
881 cy.get("[data-cy=context-menu]").contains("Restore version").click();
882 cy.get("[data-cy=confirmation-dialog]").should("contain", "Restore version");
883 cy.get("[data-cy=confirmation-dialog-ok-btn]").click();
884 cy.get("[data-cy=collection-info-panel]").should("not.contain", "This is an old version");
885 cy.get("[data-cy=collection-version-number]").should("contain", "4");
886 cy.get("[data-cy=collection-info-panel]").should("contain", colName);
887 cy.get("[data-cy=collection-files-panel]").should("contain", "foo").and("contain", "bar");
891 it("copies selected files into new collection", () => {
892 cy.createCollection(adminUser.token, {
893 name: `Test Collection ${Math.floor(Math.random() * 999999)}`,
894 owner_uuid: activeUser.user.uuid,
895 preserve_version: true,
896 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo 0:3:bar\n",
900 // Visit collection, check basic information
901 cy.loginAs(activeUser);
902 cy.goToPath(`/collections/${this.collection.uuid}`);
904 cy.get("[data-cy=collection-files-panel]").within(() => {
905 cy.get("input[type=checkbox]").first().click();
908 cy.get("[data-cy=collection-files-panel-options-btn]").click();
909 cy.get("[data-cy=context-menu]").contains("Copy selected into new collection").click();
911 cy.get("[data-cy=form-dialog]").contains("Projects").click();
913 cy.get("[data-cy=form-submit-btn]").click();
915 cy.waitForDom().get(".layout-pane-primary", { timeout: 12000 }).contains("Projects").click();
917 cy.waitForDom().get("main").contains(`Files extracted from: ${this.collection.name}`).click();
918 cy.get("[data-cy=collection-files-panel]").and("contain", "bar");
922 it("copies selected files into existing collection", () => {
923 cy.createCollection(adminUser.token, {
924 name: `Test Collection ${Math.floor(Math.random() * 999999)}`,
925 owner_uuid: activeUser.user.uuid,
926 preserve_version: true,
927 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo 0:3:bar\n",
928 }).as("sourceCollection");
930 cy.createCollection(adminUser.token, {
931 name: `Destination Collection ${Math.floor(Math.random() * 999999)}`,
932 owner_uuid: activeUser.user.uuid,
933 preserve_version: true,
935 }).as("destinationCollection");
937 cy.getAll("@sourceCollection", "@destinationCollection").then(function ([sourceCollection, destinationCollection]) {
938 // Visit collection, check basic information
939 cy.loginAs(activeUser);
940 cy.goToPath(`/collections/${sourceCollection.uuid}`);
942 cy.get("[data-cy=collection-files-panel]").within(() => {
943 cy.get("input[type=checkbox]").first().click();
946 cy.get("[data-cy=collection-files-panel-options-btn]").click();
947 cy.get("[data-cy=context-menu]").contains("Copy selected into existing collection").click();
949 cy.get("[data-cy=form-dialog]").contains(destinationCollection.name).click();
951 cy.get("[data-cy=form-submit-btn]").click();
954 cy.goToPath(`/collections/${destinationCollection.uuid}`);
956 cy.get("main").contains(destinationCollection.name).should("exist");
957 cy.get("[data-cy=collection-files-panel]").and("contain", "bar");
961 it("copies selected files into separate collections", () => {
962 cy.createCollection(adminUser.token, {
963 name: `Test Collection ${Math.floor(Math.random() * 999999)}`,
964 owner_uuid: activeUser.user.uuid,
965 preserve_version: true,
966 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo 0:3:bar\n",
967 }).as("sourceCollection");
969 cy.getAll("@sourceCollection").then(function ([sourceCollection]) {
970 // Visit collection, check basic information
971 cy.loginAs(activeUser);
972 cy.goToPath(`/collections/${sourceCollection.uuid}`);
976 .get("[data-cy=collection-files-panel]")
978 cy.get("input[type=checkbox]").first().click();
979 cy.get("input[type=checkbox]").last().click();
982 // Copy to separate collections
983 cy.get("[data-cy=collection-files-panel-options-btn]").click();
984 cy.get("[data-cy=context-menu]").contains("Copy selected into separate collections").click();
985 cy.get("[data-cy=form-dialog]").contains("Projects").click();
986 cy.get("[data-cy=form-submit-btn]").click();
988 // Verify created collections
989 cy.waitForDom().get(".layout-pane-primary", { timeout: 12000 }).contains("Projects").click();
990 cy.get("main").contains(`File copied from collection ${sourceCollection.name}/foo`).click();
991 cy.get("[data-cy=collection-files-panel]").and("contain", "foo");
992 cy.get(".layout-pane-primary").contains("Projects").click();
993 cy.get("main").contains(`File copied from collection ${sourceCollection.name}/bar`).click();
994 cy.get("[data-cy=collection-files-panel]").and("contain", "bar");
996 // Verify separate collection menu items not present when single file selected
997 // Wait for dom for collection to re-render
999 .get("[data-cy=collection-files-panel]")
1001 cy.get("input[type=checkbox]").first().click();
1003 cy.get("[data-cy=collection-files-panel-options-btn]").click();
1004 cy.get("[data-cy=context-menu]").should("not.contain", "Copy selected into separate collections");
1005 cy.get("[data-cy=context-menu]").should("not.contain", "Move selected into separate collections");
1009 it("moves selected files into new collection", () => {
1010 cy.createCollection(adminUser.token, {
1011 name: `Test Collection ${Math.floor(Math.random() * 999999)}`,
1012 owner_uuid: activeUser.user.uuid,
1013 preserve_version: true,
1014 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo 0:3:bar\n",
1018 // Visit collection, check basic information
1019 cy.loginAs(activeUser);
1020 cy.goToPath(`/collections/${this.collection.uuid}`);
1022 cy.get("[data-cy=collection-files-panel]").within(() => {
1023 cy.get("input[type=checkbox]").first().click();
1026 cy.get("[data-cy=collection-files-panel-options-btn]").click();
1027 cy.get("[data-cy=context-menu]").contains("Move selected into new collection").click();
1029 cy.get("[data-cy=form-dialog]").contains("Projects").click();
1031 cy.get("[data-cy=form-submit-btn]").click();
1033 cy.waitForDom().get(".layout-pane-primary", { timeout: 12000 }).contains("Projects").click();
1035 cy.get("main").contains(`Files moved from: ${this.collection.name}`).click();
1036 cy.get("[data-cy=collection-files-panel]").and("contain", "bar");
1040 it("moves selected files into existing collection", () => {
1041 cy.createCollection(adminUser.token, {
1042 name: `Test Collection ${Math.floor(Math.random() * 999999)}`,
1043 owner_uuid: activeUser.user.uuid,
1044 preserve_version: true,
1045 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo 0:3:bar\n",
1046 }).as("sourceCollection");
1048 cy.createCollection(adminUser.token, {
1049 name: `Destination Collection ${Math.floor(Math.random() * 999999)}`,
1050 owner_uuid: activeUser.user.uuid,
1051 preserve_version: true,
1053 }).as("destinationCollection");
1055 cy.getAll("@sourceCollection", "@destinationCollection").then(function ([sourceCollection, destinationCollection]) {
1056 // Visit collection, check basic information
1057 cy.loginAs(activeUser);
1058 cy.goToPath(`/collections/${sourceCollection.uuid}`);
1060 cy.get("[data-cy=collection-files-panel]").within(() => {
1061 cy.get("input[type=checkbox]").first().click();
1064 cy.get("[data-cy=collection-files-panel-options-btn]").click();
1065 cy.get("[data-cy=context-menu]").contains("Move selected into existing collection").click();
1067 cy.get("[data-cy=form-dialog]").contains(destinationCollection.name).click();
1069 cy.get("[data-cy=form-submit-btn]").click();
1072 cy.goToPath(`/collections/${destinationCollection.uuid}`);
1074 cy.get("main").contains(destinationCollection.name).should("exist");
1075 cy.get("[data-cy=collection-files-panel]").and("contain", "bar");
1079 it("moves selected files into separate collections", () => {
1080 cy.createCollection(adminUser.token, {
1081 name: `Test Collection ${Math.floor(Math.random() * 999999)}`,
1082 owner_uuid: activeUser.user.uuid,
1083 preserve_version: true,
1084 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo 0:3:bar\n",
1085 }).as("sourceCollection");
1087 cy.getAll("@sourceCollection").then(function ([sourceCollection]) {
1088 // Visit collection, check basic information
1089 cy.loginAs(activeUser);
1090 cy.goToPath(`/collections/${sourceCollection.uuid}`);
1092 // Select both files
1093 cy.get("[data-cy=collection-files-panel]").within(() => {
1094 cy.get("input[type=checkbox]").first().click();
1095 cy.get("input[type=checkbox]").last().click();
1098 // Copy to separate collections
1099 cy.get("[data-cy=collection-files-panel-options-btn]").click();
1100 cy.get("[data-cy=context-menu]").contains("Move selected into separate collections").click();
1101 cy.get("[data-cy=form-dialog]").contains("Projects").click();
1102 cy.get("[data-cy=form-submit-btn]").click();
1104 // Verify created collections
1105 cy.waitForDom().get(".layout-pane-primary", { timeout: 12000 }).contains("Projects").click();
1106 cy.get("main").contains(`File moved from collection ${sourceCollection.name}/foo`).click();
1107 cy.get("[data-cy=collection-files-panel]").and("contain", "foo");
1108 cy.get(".layout-pane-primary").contains("Projects").click();
1109 cy.get("main").contains(`File moved from collection ${sourceCollection.name}/bar`).click();
1110 cy.get("[data-cy=collection-files-panel]").and("contain", "bar");
1114 it("creates new collection with properties on home project", function () {
1115 cy.loginAs(activeUser);
1116 cy.goToPath(`/projects/${activeUser.user.uuid}`);
1117 cy.get("[data-cy=breadcrumb-first]").should("contain", "Projects");
1118 cy.get("[data-cy=breadcrumb-last]").should("not.exist");
1119 // Create new collection
1120 cy.get("[data-cy=side-panel-button]").click();
1121 cy.get("[data-cy=side-panel-new-collection]").click();
1122 // Name between brackets tests bugfix #17582
1123 const collName = `[Test collection (${Math.floor(999999 * Math.random())})]`;
1125 // Select a storage class.
1126 cy.get("[data-cy=form-dialog]")
1127 .should("contain", "New collection")
1128 .and("contain", "Storage classes")
1129 .and("contain", "default")
1130 .and("contain", "foo")
1131 .and("contain", "bar")
1133 cy.get("[data-cy=parent-field]").within(() => {
1134 cy.get("input").should("have.value", "Home project");
1136 cy.get("[data-cy=name-field]").within(() => {
1137 cy.get("input").type(collName);
1139 cy.get("[data-cy=checkbox-foo]").click();
1143 // Key: Color (IDTAGCOLORS) - Value: Magenta (IDVALCOLORS3)
1144 cy.get("[data-cy=form-dialog]").should("not.contain", "Color: Magenta");
1145 cy.get("[data-cy=resource-properties-form]").within(() => {
1146 cy.get("[data-cy=property-field-key]").within(() => {
1147 cy.get("input").type("Color");
1149 cy.get("[data-cy=property-field-value]").within(() => {
1150 cy.get("input").type("Magenta");
1154 // Confirm proper vocabulary labels are displayed on the UI.
1155 cy.get("[data-cy=form-dialog]").should("contain", "Color: Magenta");
1157 // Value field should not complain about being required just after
1158 // adding a new property. See #19732
1159 cy.get("[data-cy=form-dialog]").should("not.contain", "This field is required");
1161 cy.get("[data-cy=form-submit-btn]").click();
1162 // Confirm that the user was taken to the newly created collection
1163 cy.get("[data-cy=form-dialog]").should("not.exist");
1164 cy.get("[data-cy=breadcrumb-first]").should("contain", "Projects");
1166 cy.get("[data-cy=breadcrumb-last]").should('exist', { timeout: 10000 });
1167 cy.get("[data-cy=breadcrumb-last]").should("contain", collName);
1168 cy.get("[data-cy=collection-info-panel]")
1169 .should("contain", "default")
1170 .and("contain", "foo")
1171 .and("contain", "Color: Magenta")
1172 .and("not.contain", "bar");
1173 // Confirm that the collection's properties has the real values.
1174 cy.doRequest("GET", "/arvados/v1/collections", null, {
1175 filters: `[["name", "=", "${collName}"]]`,
1180 expect(this.collections).to.have.lengthOf(1);
1181 expect(this.collections[0].properties).to.have.property("IDTAGCOLORS", "IDVALCOLORS3");
1185 it("shows responsible person for collection if available", () => {
1186 cy.createCollection(adminUser.token, {
1187 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
1188 owner_uuid: activeUser.user.uuid,
1189 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n",
1190 }).as("testCollection1");
1192 cy.createCollection(adminUser.token, {
1193 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
1194 owner_uuid: adminUser.user.uuid,
1195 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n",
1197 .as("testCollection2")
1198 .then(function (testCollection2) {
1199 cy.shareWith(adminUser.token, activeUser.user.uuid, testCollection2.uuid, "can_write");
1202 cy.getAll("@testCollection1", "@testCollection2").then(function ([testCollection1, testCollection2]) {
1203 cy.loginAs(activeUser);
1205 cy.goToPath(`/collections/${testCollection1.uuid}`);
1206 cy.get("[data-cy=responsible-person-wrapper]").contains(activeUser.user.uuid);
1208 cy.goToPath(`/collections/${testCollection2.uuid}`);
1209 cy.get("[data-cy=responsible-person-wrapper]").contains(adminUser.user.uuid);
1213 describe("file upload", () => {
1215 cy.createCollection(adminUser.token, {
1216 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
1217 owner_uuid: activeUser.user.uuid,
1218 manifest_text: "./subdir 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo\n. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n",
1219 }).as("testCollection1");
1222 it("uploads a file and checks the collection UI to be fresh", () => {
1223 cy.getAll("@testCollection1").then(function ([testCollection1]) {
1224 cy.loginAs(activeUser);
1225 cy.goToPath(`/collections/${testCollection1.uuid}`);
1226 cy.get("[data-cy=upload-button]").click();
1227 cy.get("[data-cy=collection-files-panel]").contains("5mb_a.bin").should("not.exist");
1228 cy.get("[data-cy=collection-file-count]").should("contain", "2");
1229 cy.fixture("files/5mb.bin", "base64").then(content => {
1230 cy.get("[data-cy=drag-and-drop]").upload(content, "5mb_a.bin");
1231 cy.get("[data-cy=form-submit-btn]").click();
1232 cy.get("[data-cy=form-submit-btn]").should("not.exist");
1233 cy.get("[data-cy=collection-files-panel]").contains("5mb_a.bin").should("exist");
1234 cy.get("[data-cy=collection-file-count]").should("contain", "3");
1236 cy.get("[data-cy=collection-files-panel]").contains("subdir").click();
1237 cy.get("[data-cy=upload-button]").click();
1238 cy.fixture("files/5mb.bin", "base64").then(content => {
1239 cy.get("[data-cy=drag-and-drop]").upload(content, "5mb_b.bin");
1240 cy.get("[data-cy=form-submit-btn]").click();
1241 cy.waitForDom().get("[data-cy=form-submit-btn]").should("not.exist");
1242 // subdir gets unselected, I think this is a bug but
1243 // for the time being let's just make sure the test works.
1244 cy.get("[data-cy=collection-files-panel]").contains("subdir").click();
1245 cy.waitForDom().get("[data-cy=collection-files-right-panel]").contains("5mb_b.bin").should("exist");
1251 it("allows to cancel running upload", () => {
1252 cy.getAll("@testCollection1").then(function ([testCollection1]) {
1253 cy.loginAs(activeUser);
1255 cy.goToPath(`/collections/${testCollection1.uuid}`);
1257 cy.get("[data-cy=upload-button]").click();
1259 cy.fixture("files/5mb.bin", "base64").then(content => {
1260 cy.get("[data-cy=drag-and-drop]").upload(content, "5mb_a.bin");
1261 cy.get("[data-cy=drag-and-drop]").upload(content, "5mb_b.bin");
1263 cy.get("[data-cy=form-submit-btn]").click();
1265 cy.get("button").contains("Cancel").click();
1267 cy.get("[data-cy=form-submit-btn]").should("not.exist");
1272 it("allows to cancel single file from the running upload", () => {
1273 cy.getAll("@testCollection1").then(function ([testCollection1]) {
1274 cy.loginAs(activeUser);
1276 cy.goToPath(`/collections/${testCollection1.uuid}`);
1278 cy.get("[data-cy=upload-button]").click();
1280 cy.fixture("files/5mb.bin", "base64").then(content => {
1281 cy.get("[data-cy=drag-and-drop]").upload(content, "5mb_a.bin");
1282 cy.get("[data-cy=drag-and-drop]").upload(content, "5mb_b.bin");
1284 cy.get("[data-cy=form-submit-btn]").click();
1286 cy.get("button[aria-label=Remove]").eq(1).click();
1288 cy.get("[data-cy=form-submit-btn]").should("not.exist");
1290 cy.get("[data-cy=collection-files-panel]").contains("5mb_a.bin").should("exist");
1295 it("allows to cancel all files from the running upload", () => {
1296 cy.getAll("@testCollection1").then(function ([testCollection1]) {
1297 cy.loginAs(activeUser);
1299 cy.goToPath(`/collections/${testCollection1.uuid}`);
1301 // Confirm initial collection state.
1302 cy.get("[data-cy=collection-files-panel]").contains("bar").should("exist");
1303 cy.get("[data-cy=collection-files-panel]").contains("15mb_a.bin").should("not.exist");
1304 cy.get("[data-cy=collection-files-panel]").contains("15mb_b.bin").should("not.exist");
1306 cy.get("[data-cy=upload-button]").click();
1308 cy.fixture("files/15mb.bin", "base64").then(content => {
1309 cy.get("[data-cy=drag-and-drop]").upload(content, "15mb_a.bin");
1310 cy.get("[data-cy=drag-and-drop]").upload(content, "15mb_b.bin");
1312 cy.get("[data-cy=form-submit-btn]").click();
1314 cy.get("button[aria-label=Remove]").should("exist").click({ multiple: true});
1316 cy.get("[data-cy=form-submit-btn]").should("not.exist");
1318 // Confirm final collection state.
1319 cy.get("[data-cy=collection-files-panel]").contains("bar").should("exist");
1320 // The following fails, but doesn't seem to happen
1321 // in the real world. Maybe there's a race between
1322 // the PUT request finishing and the 'Remove' button
1323 // dissapearing, because sometimes just one of the 2
1324 // files gets uploaded.
1325 // Maybe this will be needed to simulate a slow network:
1326 // https://docs.cypress.io/api/commands/intercept#Convenience-functions-1
1327 // cy.get('[data-cy=collection-files-panel]')
1328 // .contains('5mb_a.bin').should('not.exist');
1329 // cy.get('[data-cy=collection-files-panel]')
1330 // .contains('5mb_b.bin').should('not.exist');