1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 describe('Collection panel tests', function () {
10 cy.getUser('admin', 'Admin', 'User', true, true)
11 .as('adminUser').then(function () {
12 adminUser = this.adminUser;
15 cy.getUser('collectionuser1', 'Collection', 'User', false, true)
16 .as('activeUser').then(function () {
17 activeUser = this.activeUser;
22 beforeEach(function () {
24 cy.clearLocalStorage();
27 it('deletes all files from root dir', function () {
28 cy.createCollection(adminUser.token, {
29 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
30 owner_uuid: activeUser.user.uuid,
31 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:baz\n"
33 .as('testCollection').then(function () {
34 cy.loginAs(activeUser);
35 cy.visit(`/collections/${this.testCollection.uuid}`);
36 cy.get('[data-cy=collection-files-panel]').within(() => {
37 cy.get('[type="checkbox"]').first().check();
38 cy.get('[type="checkbox"]').last().check();
40 cy.get('[data-cy=collection-files-panel-options-btn]').click();
41 cy.get('[data-cy=context-menu] div').contains('Remove selected').click();
42 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
43 cy.get('[data-cy=collection-files-panel]')
44 .should('not.contain', 'baz')
45 .and('not.contain', 'bar');
49 it('deletes all files from non root dir', function () {
50 cy.createCollection(adminUser.token, {
51 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
52 owner_uuid: activeUser.user.uuid,
53 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:baz\n"
55 .as('testCollection').then(function () {
56 cy.loginAs(activeUser);
57 cy.visit(`/collections/${this.testCollection.uuid}`);
59 cy.get('[data-cy=collection-files-panel]')
60 .contains('bar').rightclick({ force: true });
62 cy.get('[data-cy=context-menu]')
66 cy.get('[data-cy=form-dialog]')
67 .should('contain', 'Rename')
69 cy.get('input').type(`{selectall}{backspace}subdir/foo`);
71 cy.get('[data-cy=form-submit-btn]').click();
72 cy.get('[data-cy=collection-files-panel]')
73 .should('not.contain', 'bar')
74 .and('contain', 'subdir');
76 cy.get('[data-cy=virtual-file-tree] > div > i').first().click();
77 cy.get('[data-cy=collection-files-panel]')
78 .should('contain', 'foo');
80 cy.get('[data-cy=collection-files-panel]')
81 .contains('foo').closest('[data-cy=virtual-file-tree]').find('[type="checkbox"]').click();
83 cy.get('[data-cy=collection-files-panel-options-btn]').click();
84 cy.get('[data-cy=context-menu] div').contains('Remove selected').click();
85 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();