16068: Merge branch 'main' of git.arvados.org:arvados-workbench2 into 16068
[arvados-workbench2.git] / cypress / integration / collection.spec.js
index a6146ba2f8823c65270aa57b09dd0b3e42a285b6..568121f119f8c3b5aa500cab491aa4c2f55930d3 100644 (file)
@@ -252,8 +252,8 @@ describe('Collection panel tests', function () {
                             .and('not.contain', 'anotherKey: anotherValue');
                         // Check that the file listing show both read & write operations
                         cy.get('[data-cy=collection-files-panel]').within(() => {
-                            cy.wait(1000);
-                            cy.root().should('contain', fileName);
+                            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');
@@ -334,7 +334,7 @@ describe('Collection panel tests', function () {
                     'bar' // make sure we can go back to the original name as a last step
                 ];
                 eachPair(names, (from, to) => {
-                    cy.get('[data-cy=collection-files-panel]')
+                    cy.waitForDom().get('[data-cy=collection-files-panel]')
                         .contains(`${from}`).rightclick();
                     cy.get('[data-cy=context-menu]')
                         .contains('Rename')
@@ -626,7 +626,7 @@ describe('Collection panel tests', function () {
             });
     });
 
-    it('updates the collection UI contents by using the Refresh button', function () {
+    it('automatically updates the collection UI contents without using the Refresh button', function () {
         const collName = `Test Collection ${Math.floor(Math.random() * 999999)}`;
         const fileName = 'foobar'
 
@@ -647,7 +647,6 @@ describe('Collection panel tests', function () {
                 manifest_text: `. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:${fileName}\n`,
             }).as('updatedCollection');
             cy.getAll('@updatedCollection').then(function ([updatedCollection]) {
-                cy.contains('Refresh').click();
                 expect(updatedCollection.name).to.equal(`${collName + ' updated'}`);
                 cy.get('[data-cy=collection-info-panel]').should('contain', updatedCollection.name);
                 cy.get('[data-cy=collection-files-panel]').should('contain', fileName);
@@ -843,7 +842,7 @@ describe('Collection panel tests', function () {
 
                 cy.get('[data-cy=form-submit-btn]').click();
 
-                cy.get('.layout-pane-primary', { wait: 12000 }).contains('Projects').click();
+                cy.get('.layout-pane-primary', { timeout: 12000 }).contains('Projects').click();
 
                 cy.get('main').contains(`Files extracted from: ${this.collection.name}`).should('exist');
             });
@@ -948,7 +947,7 @@ describe('Collection panel tests', function () {
             cy.createCollection(adminUser.token, {
                 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
                 owner_uuid: activeUser.user.uuid,
-                manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
+                manifest_text: "./subdir 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo\n. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
             }).as('testCollection1');
         });
 
@@ -960,17 +959,25 @@ describe('Collection panel tests', function () {
                     cy.get('[data-cy=upload-button]').click();
                     cy.get('[data-cy=collection-files-panel]')
                         .contains('5mb_a.bin').should('not.exist');
-                    cy.get('[data-cy=collection-file-count]').should('contain', '1');
+                    cy.get('[data-cy=collection-file-count]').should('contain', '2');
                     cy.fixture('files/5mb.bin', 'base64').then(content => {
                         cy.get('[data-cy=drag-and-drop]').upload(content, '5mb_a.bin');
                         cy.get('[data-cy=form-submit-btn]').click();
                         cy.get('[data-cy=form-submit-btn]').should('not.exist');
+                        cy.get('[data-cy=collection-files-panel]')
+                            .contains('5mb_a.bin').should('exist');
+                        cy.get('[data-cy=collection-file-count]').should('contain', '3');
+
+                        cy.get('[data-cy=collection-files-panel]').contains('subdir').click();
+                        cy.get('[data-cy=upload-button]').click();
+                        cy.fixture('files/5mb.bin', 'base64').then(content => {
+                            cy.get('[data-cy=drag-and-drop]').upload(content, '5mb_b.bin');
+                            cy.get('[data-cy=form-submit-btn]').click();
+                            cy.get('[data-cy=form-submit-btn]').should('not.exist');
+                            cy.get('[data-cy=collection-files-right-panel]')
+                                 .contains('5mb_b.bin').should('exist');
+                        });
                     });
-                    // Confirm that the file browser has been updated.
-                    cy.get('[data-cy=collection-files-panel]')
-                        .contains('5mb_a.bin').should('exist');
-                    // Confirm that the collection panel has been updated.
-                    cy.get('[data-cy=collection-file-count]').should('contain', '2');
                 });
         });