17266: Avoids reloading the app on cypress tests by using search.
authorLucas Di Pentima <lucas@di-pentima.com.ar>
Tue, 26 Jan 2021 14:23:43 +0000 (11:23 -0300)
committerLucas Di Pentima <lucas@di-pentima.com.ar>
Wed, 27 Jan 2021 12:04:45 +0000 (09:04 -0300)
Instead of using visit(url), whenever possible we should use some method
that makes the app do the routing. One way is to use the search bar with
UUIDs, as it will use the route to the proper resource panel.

Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas@di-pentima.com.ar>

cypress/integration/collection-panel.spec.js
cypress/integration/delete-multiple-files.spec.js
cypress/integration/search.spec.js
cypress/integration/side-panel.spec.js
cypress/support/commands.js
src/views-components/search-bar/search-bar-view.tsx

index 424c2bad07bc7ff878be02cb44e7f9ba6e67f860..0669b313c6c10d2cb92b45f859b9ee7d55e42d94 100644 (file)
@@ -28,7 +28,7 @@ describe('Collection panel tests', function() {
         cy.clearLocalStorage();
     });
 
-    it.only('shows collection by URL', function() {
+    it('shows collection by URL', function() {
         cy.loginAs(activeUser);
         [true, false].map(function(isWritable) {
             cy.createGroup(adminUser.token, {
@@ -50,10 +50,7 @@ describe('Collection panel tests', function() {
                         head_uuid: this.sharedGroup.uuid,
                         tail_uuid: activeUser.user.uuid
                     })
-                    cy.visit(`/collections/${this.testCollection.uuid}`);
-
-                    cy.get('[data-cy=linear-progress]').should('exist');
-                    cy.get('[data-cy=linear-progress]').should('not.exist');
+                    cy.doSearch(`${this.testCollection.uuid}`);
 
                     // Check that name & uuid are correct.
                     cy.get('[data-cy=collection-info-panel]')
@@ -143,10 +140,7 @@ describe('Collection panel tests', function() {
             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=linear-progress]').should('exist');
-            cy.get('[data-cy=linear-progress]').should('not.exist');
+            cy.doSearch(`${this.testCollection.uuid}`);
 
             const nameTransitions = [
                 ['bar', '&'],
@@ -183,10 +177,7 @@ describe('Collection panel tests', function() {
             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=linear-progress]').should('exist');
-            cy.get('[data-cy=linear-progress]').should('not.exist');
+            cy.doSearch(`${this.testCollection.uuid}`);
 
             // Rename 'bar' to 'subdir/foo'
             cy.get('[data-cy=collection-files-panel]')
@@ -234,10 +225,7 @@ describe('Collection panel tests', function() {
             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=linear-progress]').should('exist');
-            cy.get('[data-cy=linear-progress]').should('not.exist');
+            cy.doSearch(`${this.testCollection.uuid}`);
 
             const illegalNamesFromUI = [
                 ['.', "Name cannot be '.' or '..'"],
@@ -312,10 +300,7 @@ describe('Collection panel tests', function() {
             });
             // Check the old version displays as what it is.
             cy.loginAs(activeUser)
-            cy.visit(`/collections/${oldVersionUuid}`);
-
-            cy.get('[data-cy=linear-progress]').should('exist');
-            cy.get('[data-cy=linear-progress]').should('not.exist');
+            cy.doSearch(`${oldVersionUuid}`);
 
             cy.get('[data-cy=collection-info-panel]').should('contain', 'This is an old version');
             cy.get('[data-cy=read-only-icon]').should('exist');
@@ -337,10 +322,7 @@ describe('Collection panel tests', function() {
         .as('collection').then(function() {
             // Visit collection, check basic information
             cy.loginAs(activeUser)
-            cy.visit(`/collections/${this.collection.uuid}`);
-
-            cy.get('[data-cy=linear-progress]').should('exist');
-            cy.get('[data-cy=linear-progress]').should('not.exist');
+            cy.doSearch(`${this.collection.uuid}`);
 
             cy.get('[data-cy=collection-info-panel]').should('not.contain', 'This is an old version');
             cy.get('[data-cy=read-only-icon]').should('not.exist');
index 0955f56a036f9aa8aad670c576a74e36d662a9a7..f9e87117d804e42837dad267d85ccc41f55a36b4 100644 (file)
@@ -32,10 +32,7 @@ describe('Multi-file deletion tests', function () {
         })
             .as('testCollection').then(function () {
                 cy.loginAs(activeUser);
-                cy.visit(`/collections/${this.testCollection.uuid}`);
-
-                cy.get('[data-cy=linear-progress]').should('exist');
-                cy.get('[data-cy=linear-progress]').should('not.exist');
+                cy.doSearch(`${this.testCollection.uuid}`);
 
                 cy.get('[data-cy=collection-files-panel]').within(() => {
                     cy.get('[type="checkbox"]').first().check();
@@ -58,10 +55,7 @@ describe('Multi-file deletion tests', function () {
         })
             .as('testCollection').then(function () {
                 cy.loginAs(activeUser);
-                cy.visit(`/collections/${this.testCollection.uuid}`);
-
-                cy.get('[data-cy=linear-progress]').should('exist');
-                cy.get('[data-cy=linear-progress]').should('not.exist');
+                cy.doSearch(`${this.testCollection.uuid}`);
 
                 cy.get('[data-cy=virtual-file-tree] > div > i').first().click();
                 cy.get('[data-cy=collection-files-panel]')
index 06131a2ef09c3966f8e009c661e78aea0fb174f9..8806d12d48fa486fb9ac9107ee956dd50561bb92 100644 (file)
@@ -72,11 +72,11 @@ 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', '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', 'version 1');
         });
index 40f39144ec82e67af3873685e84478bf6d144ed4..fe9d840010350c216a4d7f1e730f9685544cea55 100644 (file)
@@ -30,7 +30,7 @@ describe('Side panel tests', function() {
 
     it('enables the +NEW side panel button on users home project', function() {
         cy.loginAs(activeUser);
-        cy.visit(`/projects/${activeUser.user.uuid}`);
+        cy.doSearch(`${activeUser.user.uuid}`);
         cy.get('[data-cy=side-panel-button]')
             .should('exist')
             .and('not.be.disabled');
@@ -49,7 +49,7 @@ describe('Side panel tests', function() {
                     head_uuid: this.sharedGroup.uuid,
                     tail_uuid: activeUser.user.uuid
                 })
-                cy.visit(`/projects/${this.sharedGroup.uuid}`);
+                cy.doSearch(`${this.sharedGroup.uuid}`);
                 cy.get('[data-cy=side-panel-button]')
                     .should('exist')
                     .and(`${isWritable ? 'not.' : ''}be.disabled`);
@@ -78,7 +78,7 @@ describe('Side panel tests', function() {
 
     it('creates new collection on home project', function() {
         cy.loginAs(activeUser);
-        cy.visit(`/projects/${activeUser.user.uuid}`);
+        cy.doSearch(`${activeUser.user.uuid}`);
         cy.get('[data-cy=breadcrumb-first]').should('contain', 'Projects');
         cy.get('[data-cy=breadcrumb-last]').should('not.exist');
         // Create new collection
@@ -122,7 +122,7 @@ describe('Side panel tests', function() {
         }
 
         cy.loginAs(activeUser);
-        cy.visit(`/projects/${activeUser.user.uuid}`);
+        cy.doSearch(`${activeUser.user.uuid}`);
         cy.get('[data-cy=breadcrumb-first]').should('contain', 'Projects');
         cy.get('[data-cy=breadcrumb-last]').should('not.exist');
         // Create new project
index 216012c4c1251e9b46e3f25dc29da6d5ca7447e4..bba04ba85977bf9a95d34e9792a3fcb435902f5a 100644 (file)
@@ -176,10 +176,14 @@ Cypress.Commands.add(
 Cypress.Commands.add(
     "loginAs", (user) => {
         cy.visit(`/token/?api_token=${user.token}`);
-        cy.get('[data-cy=loading-spinner]').should('exist');
-        cy.get('[data-cy=loading-spinner]').should('not.exist');
         cy.url().should('contain', '/projects/');
         cy.get('div#root').should('contain', 'Arvados Workbench (zzzzz)');
         cy.get('div#root').should('not.contain', 'Your account is inactive');
     }
 )
+
+Cypress.Commands.add(
+    "doSearch", (searchTerm) => {
+        cy.get('[data-cy=searchbar-input-field]').type(`{selectall}${searchTerm}{enter}`);
+    }
+)
\ No newline at end of file
index 20536fd7e1422d2e3771829deb33e897eafed8d2..073aae6e97f8698e9dd19970f2580d2c788a17df 100644 (file)
@@ -177,7 +177,7 @@ export const SearchBarView = compose(connectVocabulary, withStyles(styles))(
                     <Paper className={isPopoverOpen ? classes.containerSearchViewOpened : classes.container} >
                         <form onSubmit={this.handleSubmit}>
                             <Input
-                                data-cy='search-input-field'
+                                data-cy='searchbar-input-field'
                                 className={classes.input}
                                 onChange={this.handleChange}
                                 placeholder="Search"