You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by gr...@apache.org on 2018/11/12 05:57:31 UTC
[incubator-superset] branch master updated: [cypress] Test
dashboard save/save_as functions (#6361)
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 1a5ca35 [cypress] Test dashboard save/save_as functions (#6361)
1a5ca35 is described below
commit 1a5ca35a553a92734ebb6a33487cdd7b60fd66ca
Author: Grace Guo <gr...@airbnb.com>
AuthorDate: Sun Nov 11 21:57:23 2018 -0800
[cypress] Test dashboard save/save_as functions (#6361)
---
.../cypress/integration/dashboard/index.test.js | 2 +
.../assets/cypress/integration/dashboard/save.js | 59 ++++++++++++++++++++++
2 files changed, 61 insertions(+)
diff --git a/superset/assets/cypress/integration/dashboard/index.test.js b/superset/assets/cypress/integration/dashboard/index.test.js
index 5db178d..af940d4 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 0000000..c132cd6
--- /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');
+ });
+});