16719: Adds integration test for old collection version display.
authorLucas Di Pentima <lucas@di-pentima.com.ar>
Thu, 15 Oct 2020 16:45:09 +0000 (13:45 -0300)
committerLucas Di Pentima <lucas@di-pentima.com.ar>
Thu, 15 Oct 2020 16:45:09 +0000 (13:45 -0300)
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas@di-pentima.com.ar>

cypress/integration/collection-panel.spec.js
cypress/support/commands.js
tools/arvados_config.yml

index c14101d8c15ed94f3f895942797efb7ae5782f14..414d7e3ed40d12e91ba8155e888e4eab700a74ed 100644 (file)
@@ -54,7 +54,8 @@ describe('Collection panel tests', function() {
                     // Check that name & uuid are correct.
                     cy.get('[data-cy=collection-info-panel]')
                         .should('contain', this.testCollection.name)
                     // Check that name & uuid are correct.
                     cy.get('[data-cy=collection-info-panel]')
                         .should('contain', this.testCollection.name)
-                        .and('contain', this.testCollection.uuid);
+                        .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
                     // 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
@@ -117,4 +118,54 @@ describe('Collection panel tests', function() {
             })
         })
     })
             })
         })
     })
+
+    it('can correctly display old versions', function() {
+        const colName = `Versioned Collection ${Math.floor(Math.random() * Math.floor(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');
+        });
+    });
 })
 })
index fd5139981fc421cf4304548c8c9980841b273710..228e1cabb14e3b68fe43705add938c03cc45bb0d 100644 (file)
@@ -125,6 +125,14 @@ Cypress.Commands.add(
     }
 )
 
     }
 )
 
+Cypress.Commands.add(
+    "updateCollection", (token, uuid, data) => {
+        return cy.updateResource(token, 'collections', uuid, {
+            collection: JSON.stringify(data)
+        })
+    }
+)
+
 Cypress.Commands.add(
     "createResource", (token, suffix, data) => {
         return cy.doRequest('POST', '/arvados/v1/'+suffix, data, null, token, true)
 Cypress.Commands.add(
     "createResource", (token, suffix, data) => {
         return cy.doRequest('POST', '/arvados/v1/'+suffix, data, null, token, true)
@@ -145,6 +153,16 @@ Cypress.Commands.add(
     }
 )
 
     }
 )
 
+Cypress.Commands.add(
+    "updateResource", (token, suffix, uuid, data) => {
+        return cy.doRequest('PUT', '/arvados/v1/'+suffix+'/'+uuid, data, null, token, true)
+        .its('body').as('resource')
+        .then(function() {
+            return this.resource;
+        })
+    }
+)
+
 Cypress.Commands.add(
     "loginAs", (user) => {
         cy.visit(`/token/?api_token=${user.token}`);
 Cypress.Commands.add(
     "loginAs", (user) => {
         cy.visit(`/token/?api_token=${user.token}`);
index 8882eac2e48378ebbe1bdb81b862991995d1611b..b533156de067fb0ac20aec0b63e5bb531b6637e3 100644 (file)
@@ -7,6 +7,8 @@ Clusters:
     TLS:
       Insecure: true
     Collections:
     TLS:
       Insecure: true
     Collections:
+      CollectionVersioning: true
+      PreserveVersionIfIdle: 0s
       BlobSigningKey: zfhgfenhffzltr9dixws36j1yhksjoll2grmku38mi7yxd66h5j4q9w4jzanezacp8s6q0ro3hxakfye02152hncy6zml2ed0uc
       TrustAllContent: true
       ForwardSlashNameSubstitution: /
       BlobSigningKey: zfhgfenhffzltr9dixws36j1yhksjoll2grmku38mi7yxd66h5j4q9w4jzanezacp8s6q0ro3hxakfye02152hncy6zml2ed0uc
       TrustAllContent: true
       ForwardSlashNameSubstitution: /