You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2018/11/12 05:57:25 UTC

[GitHub] graceguo-supercat closed pull request #6361: [cypress] Test dashboard save/save_as functions

graceguo-supercat closed pull request #6361: [cypress] Test dashboard save/save_as functions
URL: https://github.com/apache/incubator-superset/pull/6361
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/superset/assets/cypress/integration/dashboard/index.test.js b/superset/assets/cypress/integration/dashboard/index.test.js
index 5db178d7d2..af940d4884 100644
--- a/superset/assets/cypress/integration/dashboard/index.test.js
+++ b/superset/assets/cypress/integration/dashboard/index.test.js
@@ -3,6 +3,7 @@ import DashboardEditModeTest from './edit_mode';
 import DashboardFavStarTest from './fav_star';
 import DashboardFilterTest from './filter';
 import DashboardLoadTest from './load';
+import DashboardSaveTest from './save';
 
 describe('Dashboard', () => {
   DashboardControlsTest();
@@ -10,4 +11,5 @@ describe('Dashboard', () => {
   DashboardFavStarTest();
   DashboardFilterTest();
   DashboardLoadTest();
+  DashboardSaveTest();
 });
diff --git a/superset/assets/cypress/integration/dashboard/save.js b/superset/assets/cypress/integration/dashboard/save.js
new file mode 100644
index 0000000000..c132cd65db
--- /dev/null
+++ b/superset/assets/cypress/integration/dashboard/save.js
@@ -0,0 +1,59 @@
+import readResponseBlob from '../../utils/readResponseBlob';
+import { WORLD_HEALTH_DASHBOARD } from './dashboard.helper';
+
+export default () => describe('save', () => {
+  let dashboardId;
+  let boxplotChartId;
+
+  beforeEach(() => {
+    cy.server();
+    cy.login();
+    cy.visit(WORLD_HEALTH_DASHBOARD);
+
+    cy.get('#app').then((data) => {
+      const bootstrapData = JSON.parse(data[0].dataset.bootstrap);
+      const dashboard = bootstrapData.dashboard_data;
+      dashboardId = dashboard.id;
+      boxplotChartId = dashboard.slices.find(slice => (slice.form_data.viz_type === 'box_plot')).slice_id;
+
+      cy.route('POST', `/superset/copy_dash/${dashboardId}/`).as('copyRequest');
+    });
+
+    cy.get('#save-dash-split-button').trigger('click', { force: true });
+    cy.contains('Save as').trigger('click', { force: true });
+    cy.get('.modal-footer').contains('Save').trigger('click', { force: true });
+  });
+
+  it('should save as new dashboard', () => {
+    cy.wait('@copyRequest').then((xhr) => {
+      expect(xhr.status).to.eq(200);
+
+      readResponseBlob(xhr.response.body).then((json) => {
+        expect(json.id).to.be.gt(dashboardId);
+      });
+    });
+  });
+
+  it('should save/overwrite dashboard', () => {
+    cy.wait('@copyRequest');
+
+    // should have box_plot chart
+    const boxplotRequest = `/superset/explore_json/?form_data={"slice_id":${boxplotChartId}}`;
+    cy.route('POST', boxplotRequest).as('boxplotRequest');
+    cy.wait('@boxplotRequest');
+    cy.get('.grid-container .box_plot').should('be.exist');
+
+    // remove box_plot chart from dashboard
+    cy.get('.dashboard-header').contains('Edit dashboard').trigger('click', { force: true });
+    cy.get('.fa.fa-trash').last().trigger('click', { force: true });
+    cy.get('.grid-container .box_plot').should('not.exist');
+
+    cy.route('POST', '/superset/save_dash/**/').as('saveRequest');
+    cy.get('.dashboard-header').contains('Save changes').trigger('click', { force: true });
+
+    // go back to view mode
+    cy.wait('@saveRequest');
+    cy.get('.dashboard-header').contains('Edit dashboard');
+    cy.get('.grid-container .box_plot').should('not.exist');
+  });
+});


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org