18549: Cypress test added
[arvados-workbench2.git] / cypress / integration / search.spec.js
index 05c345c9a8629ecc06f6683d6c9135e5d48c80b5..95e0bc95d341226ff5787e6128c0c548b0430e94 100644 (file)
@@ -46,6 +46,7 @@ describe('Search tests', function() {
         cy.createCollection(adminUser.token, {
             name: colName,
             owner_uuid: activeUser.user.uuid,
+            preserve_version: true,
             manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"})
         .as('originalVersion').then(function() {
             // Change the file name to create a new version.
@@ -71,13 +72,36 @@ describe('Search tests', function() {
             cy.loginAs(activeUser);
             const searchQuery = `${colName} type:arvados#collection`;
             // Search for only collection's current version
-            cy.visit(`/search-results?q=${encodeURIComponent(searchQuery)}`);
+            cy.doSearch(`${searchQuery}`);
             cy.get('[data-cy=search-results]').should('contain', 'head version');
-            cy.get('[data-cy=search-results]').should('not.contain', 'old version');
+            cy.get('[data-cy=search-results]').should('not.contain', 'version 1');
             // ...and then, include old versions.
-            cy.visit(`/search-results?q=${encodeURIComponent(searchQuery + ' is:pastVersion')}`);
+            cy.doSearch(`${searchQuery} is:pastVersion`);
             cy.get('[data-cy=search-results]').should('contain', 'head version');
-            cy.get('[data-cy=search-results]').should('contain', 'old version');
+            cy.get('[data-cy=search-results]').should('contain', 'version 1');
+        });
+    });
+
+    it('can search for old collection versions', function() {
+        const colName = `Collection ${Math.floor(Math.random() * Math.floor(999999))}`;
+
+        // 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,
+            preserve_version: true,
+            manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
+        }).then(function() {
+            cy.loginAs(activeUser);
+
+            cy.doSearch(colName);
+
+            cy.get('[data-cy=search-results]').should('contain', colName);
+
+            cy.get('[data-cy=search-results]').contains(colName).closest('tr').click();
+
+            cy.get('[data-cy=snackbar]').should('contain', `/ Projects / ${colName}`);
         });
     });
 });
\ No newline at end of file