- cy.goToPath(`/collections/${this.testCollection.uuid}`);
-
- // Check that name & uuid are correct.
- cy.get('[data-cy=collection-info-panel]')
- .should('contain', this.testCollection.name)
- .and('contain', this.testCollection.uuid)
- .and('not.contain', 'This is an old version');
- // Check for the read-only icon
- cy.get('[data-cy=read-only-icon]').should(`${isWritable ? 'not.' : ''}exist`);
- // Check that both read and write operations are available on
- // the 'More options' menu.
- cy.get('[data-cy=collection-panel-options-btn]')
- .click()
- cy.get('[data-cy=context-menu]')
- .should('contain', 'Add to favorites')
- .and(`${isWritable ? '' : 'not.'}contain`, 'Edit collection');
- cy.get('body').click(); // Collapse the menu avoiding details panel expansion
- cy.get('[data-cy=collection-info-panel]')
- .should('contain', 'someKey: someValue')
- .and('not.contain', 'anotherKey: anotherValue');
- // Check that the file listing show both read & write operations
- cy.waitForDom().get('[data-cy=collection-files-panel]').within(() => {
- cy.get('[data-cy=collection-files-right-panel]', { timeout: 5000 })
- .should('contain', fileName);
- if (isWritable) {
- cy.get('[data-cy=upload-button]')
- .should(`${isWritable ? '' : 'not.'}contain`, 'Upload data');
- }
+ .as("testCollection")
+ .then(function () {
+ // Share the group with active user.
+ cy.createLink(adminUser.token, {
+ name: isWritable ? "can_write" : "can_read",
+ link_class: "permission",
+ head_uuid: this.sharedGroup.uuid,
+ tail_uuid: activeUser.user.uuid,
+ });
+ cy.goToPath(`/collections/${this.testCollection.uuid}`);
+
+ // Check that name & uuid are correct.
+ cy.get("[data-cy=collection-info-panel]")
+ .should("contain", this.testCollection.name)
+ .and("contain", this.testCollection.uuid)
+ .and("not.contain", "This is an old version");
+ // Check for the read-only icon
+ cy.get("[data-cy=read-only-icon]").should(`${isWritable ? "not." : ""}exist`);
+ // Check that both read and write operations are available on
+ // the 'More options' menu.
+ cy.get("[data-cy=collection-panel-options-btn]").click();
+ cy.get("[data-cy=context-menu]")
+ .should("contain", "Add to favorites")
+ .and(`${isWritable ? "" : "not."}contain`, "Edit collection");
+ cy.get("body").click(); // Collapse the menu avoiding details panel expansion
+ cy.get("[data-cy=collection-info-panel]")
+ .should("contain", "someKey: someValue")
+ .and("not.contain", "anotherKey: anotherValue");
+ // Check that the file listing show both read & write operations
+ cy.waitForDom()
+ .get("[data-cy=collection-files-panel]")
+ .within(() => {
+ cy.get("[data-cy=collection-files-right-panel]", { timeout: 5000 }).should("contain", fileName);
+ if (isWritable) {
+ cy.get("[data-cy=upload-button]").should(`${isWritable ? "" : "not."}contain`, "Upload data");
+ }
+ });
+ // Test context menus
+ cy.get("[data-cy=collection-files-panel]").contains(fileName).rightclick();
+ cy.get("[data-cy=context-menu]")
+ .should("contain", "Download")
+ .and("contain", "Open in new tab")
+ .and("contain", "Copy to clipboard")
+ .and(`${isWritable ? "" : "not."}contain`, "Rename")
+ .and(`${isWritable ? "" : "not."}contain`, "Remove");
+ cy.get("body").click(); // Collapse the menu
+ cy.get("[data-cy=collection-files-panel]").contains(subDirName).rightclick();
+ cy.get("[data-cy=context-menu]")
+ .should("not.contain", "Download")
+ .and("contain", "Open in new tab")
+ .and("contain", "Copy to clipboard")
+ .and(`${isWritable ? "" : "not."}contain`, "Rename")
+ .and(`${isWritable ? "" : "not."}contain`, "Remove");
+ cy.get("body").click(); // Collapse the menu
+ // File/dir item 'more options' button
+ cy.get("[data-cy=file-item-options-btn").first().click();
+ cy.get("[data-cy=context-menu]").should(`${isWritable ? "" : "not."}contain`, "Remove");
+ cy.get("body").click(); // Collapse the menu
+ // Hamburger 'more options' menu button
+ cy.get("[data-cy=collection-files-panel-options-btn]").click();
+ cy.get("[data-cy=context-menu]").should("contain", "Select all").click();
+ cy.get("[data-cy=collection-files-panel-options-btn]").click();
+ cy.get("[data-cy=context-menu]").should(`${isWritable ? "" : "not."}contain`, "Remove selected");
+ cy.get("body").click(); // Collapse the menu