superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From grace...@apache.org
Subject [incubator-superset] branch master updated: [cypress] Update dashboard test to remove 10s timeout (#5957)
Date Thu, 27 Sep 2018 18:05:02 GMT
This is an automated email from the ASF dual-hosted git repository.

graceguo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 0cc0996  [cypress] Update dashboard test to remove 10s timeout (#5957)
0cc0996 is described below

commit 0cc0996e92c48c5e4518bcc56e028b819ae2b0c8
Author: Krist Wongsuphasawat <krist.wongz@gmail.com>
AuthorDate: Thu Sep 27 11:04:55 2018 -0700

    [cypress] Update dashboard test to remove 10s timeout (#5957)
    
    * Fix dashboard test instead of using fixed 10s timeout
    
    * resolve lint issues
---
 .../integration/dashboard/dashboard_tests.js       | 36 ++++++++++++----------
 1 file changed, 20 insertions(+), 16 deletions(-)

diff --git a/superset/assets/cypress/integration/dashboard/dashboard_tests.js b/superset/assets/cypress/integration/dashboard/dashboard_tests.js
index 31ce704..ed2ac08 100644
--- a/superset/assets/cypress/integration/dashboard/dashboard_tests.js
+++ b/superset/assets/cypress/integration/dashboard/dashboard_tests.js
@@ -2,24 +2,28 @@ describe('Load dashboard', () => {
   it('Load birth names dashboard', () => {
     cy.server();
     cy.login();
-
+    // go to the dashboard and get list of slices first
     cy.visit('/superset/dashboard/births');
-
-    cy.route('POST', '/superset/explore_json/**').as('getJson');
-    cy.wait(10000, ['@getJson']);
-
-    let sliceData;
-
-    cy.get('@getJson.all').then((xhrs) => {
-      sliceData = xhrs;
-      xhrs.forEach((data) => {
-        expect(data.status).to.eq(200);
-        expect(data.response.body).to.have.property('error', null);
-        cy.get(`#slice-container-${data.response.body.form_data.slice_id}`);
+    cy.get('#app').then((data) => {
+      const bootstrapData = JSON.parse(data[0].dataset.bootstrap);
+      const slices = bootstrapData.dashboard_data.slices;
+      // then define routes and create alias for each requests
+      const aliases = slices.map((slice) => {
+        const alias = `getJson_${slice.slice_id}`;
+        cy.route('POST', `/superset/explore_json/?form_data={"slice_id":${slice.slice_id}}`).as(alias);
+        return `@${alias}`;
       });
-      cy.get('#app').then((data) => {
-        const bootstrapData = JSON.parse(data[0].dataset.bootstrap);
-        expect(bootstrapData.dashboard_data.slices.length).to.eq(sliceData.length);
+      // reload the dashboard again with all routes watched.
+      cy.visit('/superset/dashboard/births');
+      // wait for all requests to complete
+      cy.wait(aliases);
+      // verify one-by-one
+      aliases.forEach((alias) => {
+        cy.get(alias).then((xhr) => {
+          expect(xhr.status).to.eq(200);
+          expect(xhr.response.body).to.have.property('error', null);
+          cy.get(`#slice-container-${xhr.response.body.form_data.slice_id}`);
+        });
       });
     });
   });


Mime
View raw message