17109: Hopefully fixes several integration test flakyness issues.
[arvados-workbench2.git] / cypress / integration / delete-multiple-files.spec.js
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 describe('Multi-file deletion tests', function () {
6     let activeUser;
7     let adminUser;
8
9     before(function () {
10         cy.getUser('admin', 'Admin', 'User', true, true)
11             .as('adminUser').then(function () {
12                 adminUser = this.adminUser;
13             }
14             );
15         cy.getUser('collectionuser1', 'Collection', 'User', false, true)
16             .as('activeUser').then(function () {
17                 activeUser = this.activeUser;
18             }
19             );
20     });
21
22     beforeEach(function () {
23         cy.clearCookies();
24         cy.clearLocalStorage();
25     });
26
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"
32         })
33             .as('testCollection').then(function () {
34                 cy.loginAs(activeUser);
35                 cy.visit(`/collections/${this.testCollection.uuid}`);
36
37                 cy.get('[data-cy=linear-progress]').should('exist');
38                 cy.get('[data-cy=linear-progress]').should('not.exist');
39
40                 cy.get('[data-cy=collection-files-panel]').within(() => {
41                     cy.get('[type="checkbox"]').first().check();
42                     cy.get('[type="checkbox"]').last().check();
43                 });
44                 cy.get('[data-cy=collection-files-panel-options-btn]').click();
45                 cy.get('[data-cy=context-menu] div').contains('Remove selected').click();
46                 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
47                 cy.get('[data-cy=collection-files-panel]')
48                     .should('not.contain', 'baz')
49                     .and('not.contain', 'bar');
50             });
51     });
52
53     it('deletes all files from non root dir', function () {
54         cy.createCollection(adminUser.token, {
55             name: `Test collection ${Math.floor(Math.random() * 999999)}`,
56             owner_uuid: activeUser.user.uuid,
57             manifest_text: "./subdir 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo\n. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:baz\n"
58         })
59             .as('testCollection').then(function () {
60                 cy.loginAs(activeUser);
61                 cy.visit(`/collections/${this.testCollection.uuid}`);
62
63                 cy.get('[data-cy=linear-progress]').should('exist');
64                 cy.get('[data-cy=linear-progress]').should('not.exist');
65
66                 cy.get('[data-cy=virtual-file-tree] > div > i').first().click();
67                 cy.get('[data-cy=collection-files-panel]')
68                     .should('contain', 'foo');
69
70                 cy.get('[data-cy=collection-files-panel]')
71                     .contains('foo').closest('[data-cy=virtual-file-tree]').find('[type="checkbox"]').click();
72
73                 cy.get('[data-cy=collection-files-panel-options-btn]').click();
74                 cy.get('[data-cy=context-menu] div').contains('Remove selected').click();
75                 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
76
77                 cy.get('[data-cy=collection-files-panel]')
78                     .should('not.contain', 'subdir')
79                     .and('contain', 'baz');
80             });
81     });
82 })