15685: Merge branch 'master' into 15685-file-renaming-empty-name
authorLucas Di Pentima <lucas@di-pentima.com.ar>
Fri, 6 Nov 2020 16:01:44 +0000 (13:01 -0300)
committerLucas Di Pentima <lucas@di-pentima.com.ar>
Fri, 6 Nov 2020 16:01:44 +0000 (13:01 -0300)
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas@di-pentima.com.ar>

1  2 
cypress/integration/collection-panel.spec.js
cypress/integration/login.spec.js

index 19a28c88b97e228129f37535d1bb8053c0137e4d,404d1c5b04f7ec2b2a17729908b0e6f0130dc60e..466d7433323a24c7a67e6856d791085667c4cf17
@@@ -118,59 -128,53 +128,109 @@@ describe('Collection panel tests', func
          })
      })
  
 -        const colName = `Versioned Collection ${Math.floor(Math.random() * Math.floor(999999))}`;
 +    it('renames a file', function() {
 +        // Creates the collection using the admin token so we can set up
 +        // a bogus manifest text without block signatures.
 +        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"})
 +        .as('testCollection').then(function() {
 +            cy.loginAs(activeUser);
 +            cy.visit(`/collections/${this.testCollection.uuid}`);
 +            cy.get('[data-cy=collection-files-panel]')
 +                .contains('bar').rightclick();
 +            cy.get('[data-cy=context-menu]')
 +                .contains('Rename')
 +                .click();
 +            cy.get('[data-cy=form-dialog]')
 +                .should('contain', 'Rename')
 +                .within(() => {
 +                    cy.get('input').type('{backspace}{backspace}{backspace}foo');
 +                });
 +            cy.get('[data-cy=form-submit-btn]').click();
 +            cy.get('[data-cy=collection-files-panel]')
 +                .should('not.contain', 'bar')
 +                .and('contain', 'foo');
 +        });
 +    });
 +
 +    it('tries to rename a file with an illegal name', function() {
 +        // Creates the collection using the admin token so we can set up
 +        // a bogus manifest text without block signatures.
 +        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"})
 +        .as('testCollection').then(function() {
 +            cy.loginAs(activeUser);
 +            cy.visit(`/collections/${this.testCollection.uuid}`);
 +            cy.get('[data-cy=collection-files-panel]')
 +                .contains('bar').rightclick();
 +            cy.get('[data-cy=context-menu]')
 +                .contains('Rename')
 +                .click();
 +            cy.get('[data-cy=form-dialog]')
 +                .should('contain', 'Rename')
 +                .within(() => {
 +                    cy.get('input').type('{backspace}{backspace}{backspace}');
 +                });
 +            cy.get('[data-cy=form-submit-btn]').click();
 +            cy.get('[data-cy=form-dialog]')
 +                .should('contain', 'Rename')
 +                .within(() => {
 +                    cy.contains('Could not rename');
 +                });
 +        });
 +    });
++
+     it('can correctly display old versions', function() {
++        const colName = `Versioned Collection ${Math.floor(Math.random() * 999999)}`;
+         let colUuid = '';
+         let oldVersionUuid = '';
+         // Make sure no other collections with this name exist
+         cy.doRequest('GET', '/arvados/v1/collections', null, {
+             filters: `[["name", "=", "${colName}"]]`,
+             include_old_versions: true
+         })
+         .its('body.items').as('collections')
+         .then(function() {
+             expect(this.collections).to.be.empty;
+         });
+         // Creates the collection using the admin token so we can set up
+         // a bogus manifest text without block signatures.
+         cy.createCollection(adminUser.token, {
+             name: colName,
+             owner_uuid: activeUser.user.uuid,
+             manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"})
+         .as('originalVersion').then(function() {
+             // Change the file name to create a new version.
+             cy.updateCollection(adminUser.token, this.originalVersion.uuid, {
+                 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo\n"
+             })
+             colUuid = this.originalVersion.uuid;
+         });
+         // Confirm that there are 2 versions of the collection
+         cy.doRequest('GET', '/arvados/v1/collections', null, {
+             filters: `[["name", "=", "${colName}"]]`,
+             include_old_versions: true
+         })
+         .its('body.items').as('collections')
+         .then(function() {
+             expect(this.collections).to.have.lengthOf(2);
+             this.collections.map(function(aCollection) {
+                 expect(aCollection.current_version_uuid).to.equal(colUuid);
+                 if (aCollection.uuid !== aCollection.current_version_uuid) {
+                     oldVersionUuid = aCollection.uuid;
+                 }
+             });
+             // Check the old version displays as what it is.
+             cy.loginAs(activeUser)
+             cy.visit(`/collections/${oldVersionUuid}`);
+             cy.get('[data-cy=collection-info-panel]').should('contain', 'This is an old version');
+             cy.get('[data-cy=read-only-icon]').should('exist');
+             cy.get('[data-cy=collection-info-panel]').should('contain', colName);
+             cy.get('[data-cy=collection-files-panel]').should('contain', 'bar');
+         });
+     });
  })
Simple merge