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] Combine multiple tests under visualizations into single test to save running time (#6019)
Date Tue, 02 Oct 2018 18:31:53 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 f9344f1  [cypress] Combine multiple tests under visualizations into single test to
save running time (#6019)
f9344f1 is described below

commit f9344f13df19effc744db7c31d29413918923f72
Author: Krist Wongsuphasawat <krist.wongz@gmail.com>
AuthorDate: Tue Oct 2 11:31:29 2018 -0700

    [cypress] Combine multiple tests under visualizations into single test to save running
time (#6019)
    
    * add histogram test
    
    * add compare test
    
    * merge all vis tests under single test
---
 superset/assets/cypress.json                       |  5 +-
 .../{big_number_total.js => _big_number_total.js}  |  2 +-
 .../integration/explore/visualizations/_compare.js | 72 ++++++++++++++++++++++
 .../visualizations/{dist_bar.js => _dist_bar.js}   |  2 +-
 .../explore/visualizations/_histogram.js           | 62 +++++++++++++++++++
 .../explore/visualizations/{line.js => _line.js}   |  2 +-
 .../explore/visualizations/{table.js => _table.js} |  2 +-
 .../integration/explore/visualizations/all.js      | 15 +++++
 superset/assets/package.json                       |  3 +-
 9 files changed, 159 insertions(+), 6 deletions(-)

diff --git a/superset/assets/cypress.json b/superset/assets/cypress.json
index 3dcda85..dee8cf6 100644
--- a/superset/assets/cypress.json
+++ b/superset/assets/cypress.json
@@ -1,6 +1,9 @@
 {
   "baseUrl": "http://localhost:8081",
   "videoUploadOnPasses": false,
-  "ignoreTestFiles": "*.helper.js",
+  "ignoreTestFiles": [
+    "_*.js",
+    "*.helper.js"
+  ],
   "projectId": "fbf96q"
 }
diff --git a/superset/assets/cypress/integration/explore/visualizations/big_number_total.js
b/superset/assets/cypress/integration/explore/visualizations/_big_number_total.js
similarity index 96%
rename from superset/assets/cypress/integration/explore/visualizations/big_number_total.js
rename to superset/assets/cypress/integration/explore/visualizations/_big_number_total.js
index 7651c1b..1797df6 100644
--- a/superset/assets/cypress/integration/explore/visualizations/big_number_total.js
+++ b/superset/assets/cypress/integration/explore/visualizations/_big_number_total.js
@@ -2,7 +2,7 @@ import { FORM_DATA_DEFAULTS, NUM_METRIC } from './shared.helper';
 
 // Big Number Total
 
-describe('Big Number Total', () => {
+export default () => describe('Big Number Total', () => {
   const BIG_NUMBER_DEFAULTS = { ...FORM_DATA_DEFAULTS, viz_type: 'big_number_total' };
 
   beforeEach(() => {
diff --git a/superset/assets/cypress/integration/explore/visualizations/_compare.js b/superset/assets/cypress/integration/explore/visualizations/_compare.js
new file mode 100644
index 0000000..c3f758a
--- /dev/null
+++ b/superset/assets/cypress/integration/explore/visualizations/_compare.js
@@ -0,0 +1,72 @@
+export default () => describe('Compare', () => {
+  const COMPARE_FORM_DATA = {
+    datasource: '3__table',
+    viz_type: 'compare',
+    slice_id: 60,
+    granularity_sqla: 'ds',
+    time_grain_sqla: 'P1D',
+    time_range: '100 years ago : now',
+    metrics: ['count'],
+    adhoc_filters: [],
+    groupby: [],
+    order_desc: true,
+    contribution: false,
+    row_limit: 50000,
+    color_scheme: 'bnbColors',
+    x_axis_label: 'Frequency',
+    bottom_margin: 'auto',
+    x_ticks_layout: 'auto',
+    x_axis_format: 'smart_date',
+    x_axis_showminmax: false,
+    y_axis_label: 'Num',
+    left_margin: 'auto',
+    y_axis_showminmax: false,
+    y_log_scale: false,
+    y_axis_format: '.3s',
+    rolling_type: 'None',
+    comparison_type: 'values',
+    annotation_layers: [],
+  };
+
+  function verify(formData) {
+    cy.visitChartByParams(JSON.stringify(formData));
+    cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' });
+  }
+
+  beforeEach(() => {
+    cy.server();
+    cy.login();
+    cy.route('POST', '/superset/explore_json/**').as('getJson');
+  });
+
+  it('should work without groupby', () => {
+    verify(COMPARE_FORM_DATA);
+    cy.get('.chart-container .nvd3 path.nv-line').should('have.length', 1);
+  });
+
+  it('should with group by', () => {
+    verify({
+      ...COMPARE_FORM_DATA,
+      groupby: ['gender'],
+    });
+    cy.get('.chart-container .nvd3 path.nv-line').should('have.length', 2);
+  });
+
+  it('should work with filter', () => {
+    verify({
+      ...COMPARE_FORM_DATA,
+      adhoc_filters: [{
+        expressionType: 'SIMPLE',
+        subject: 'gender',
+        operator: '==',
+        comparator: 'boy',
+        clause: 'WHERE',
+        sqlExpression: null,
+        fromFormData: true,
+        filterOptionName: 'filter_tqx1en70hh_7nksse7nqic',
+      }],
+    });
+    cy.get('.chart-container .nvd3 path.nv-line').should('have.length', 1);
+  });
+
+});
diff --git a/superset/assets/cypress/integration/explore/visualizations/dist_bar.js b/superset/assets/cypress/integration/explore/visualizations/_dist_bar.js
similarity index 96%
rename from superset/assets/cypress/integration/explore/visualizations/dist_bar.js
rename to superset/assets/cypress/integration/explore/visualizations/_dist_bar.js
index c285f5a..5d1de68 100644
--- a/superset/assets/cypress/integration/explore/visualizations/dist_bar.js
+++ b/superset/assets/cypress/integration/explore/visualizations/_dist_bar.js
@@ -2,7 +2,7 @@ import { FORM_DATA_DEFAULTS, NUM_METRIC } from './shared.helper';
 
 // Dist bar
 
-describe('Distribution bar chart', () => {
+export default () => describe('Distribution bar chart', () => {
   const VIZ_DEFAULTS = { ...FORM_DATA_DEFAULTS, viz_type: 'dist_bar' };
 
   beforeEach(() => {
diff --git a/superset/assets/cypress/integration/explore/visualizations/_histogram.js b/superset/assets/cypress/integration/explore/visualizations/_histogram.js
new file mode 100644
index 0000000..f6b9adc
--- /dev/null
+++ b/superset/assets/cypress/integration/explore/visualizations/_histogram.js
@@ -0,0 +1,62 @@
+export default () => describe('Histogram', () => {
+  const HISTOGRAM_FORM_DATA = {
+    datasource: '3__table',
+    viz_type: 'histogram',
+    slice_id: 60,
+    granularity_sqla: 'ds',
+    time_grain_sqla: 'P1D',
+    time_range: '100 years ago : now',
+    all_columns_x: ['num'],
+    adhoc_filters: [],
+    row_limit: 50000,
+    groupby: [],
+    color_scheme: 'bnbColors',
+    link_length: 5,
+    x_axis_label: 'Frequency',
+    y_axis_label: 'Num',
+    global_opacity: 1,
+    normalized: false,
+  };
+
+  function verify(formData) {
+    cy.visitChartByParams(JSON.stringify(formData));
+    cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' });
+  }
+
+  beforeEach(() => {
+    cy.server();
+    cy.login();
+    cy.route('POST', '/superset/explore_json/**').as('getJson');
+  });
+
+  it('should work without groupby', () => {
+    verify(HISTOGRAM_FORM_DATA);
+    cy.get('.chart-container svg .vx-bar').should('have.length', 6);
+  });
+
+  it('should with group by', () => {
+    verify({
+      ...HISTOGRAM_FORM_DATA,
+      groupby: ['gender'],
+    });
+    cy.get('.chart-container svg .vx-bar').should('have.length', 12);
+  });
+
+  it('should work with filter', () => {
+    verify({
+      ...HISTOGRAM_FORM_DATA,
+      adhoc_filters: [{
+        expressionType: 'SIMPLE',
+        subject: 'gender',
+        operator: '==',
+        comparator: 'boy',
+        clause: 'WHERE',
+        sqlExpression: null,
+        fromFormData: true,
+        filterOptionName: 'filter_tqx1en70hh_7nksse7nqic',
+      }],
+    });
+    cy.get('.chart-container svg .vx-bar').should('have.length', 5);
+  });
+
+});
diff --git a/superset/assets/cypress/integration/explore/visualizations/line.js b/superset/assets/cypress/integration/explore/visualizations/_line.js
similarity index 98%
rename from superset/assets/cypress/integration/explore/visualizations/line.js
rename to superset/assets/cypress/integration/explore/visualizations/_line.js
index 525cc3c..6705b77 100644
--- a/superset/assets/cypress/integration/explore/visualizations/line.js
+++ b/superset/assets/cypress/integration/explore/visualizations/_line.js
@@ -1,6 +1,6 @@
 import { FORM_DATA_DEFAULTS, NUM_METRIC, SIMPLE_FILTER } from './shared.helper';
 
-describe('Line', () => {
+export default () => describe('Line', () => {
   const LINE_CHART_DEFAULTS = { ...FORM_DATA_DEFAULTS, viz_type: 'line' };
 
   beforeEach(() => {
diff --git a/superset/assets/cypress/integration/explore/visualizations/table.js b/superset/assets/cypress/integration/explore/visualizations/_table.js
similarity index 98%
rename from superset/assets/cypress/integration/explore/visualizations/table.js
rename to superset/assets/cypress/integration/explore/visualizations/_table.js
index 90a26d1..85eef61 100644
--- a/superset/assets/cypress/integration/explore/visualizations/table.js
+++ b/superset/assets/cypress/integration/explore/visualizations/_table.js
@@ -2,7 +2,7 @@ import { FORM_DATA_DEFAULTS, NUM_METRIC, SIMPLE_FILTER } from './shared.helper';
 
 // Table
 
-describe('Table chart', () => {
+export default() => describe('Table chart', () => {
   const VIZ_DEFAULTS = { ...FORM_DATA_DEFAULTS, viz_type: 'table' };
 
   beforeEach(() => {
diff --git a/superset/assets/cypress/integration/explore/visualizations/all.js b/superset/assets/cypress/integration/explore/visualizations/all.js
new file mode 100644
index 0000000..a9010e1
--- /dev/null
+++ b/superset/assets/cypress/integration/explore/visualizations/all.js
@@ -0,0 +1,15 @@
+import BigNumberTotalTest from './_big_number_total';
+import CompareTest from './_compare';
+import DistBarTest from './_dist_bar';
+import HistogramTest from './_histogram';
+import LineTest from './_line';
+import TableTest from './_table';
+
+describe('All Visualizations', () => {
+  BigNumberTotalTest();
+  CompareTest();
+  DistBarTest();
+  HistogramTest();
+  LineTest();
+  TableTest();
+});
diff --git a/superset/assets/package.json b/superset/assets/package.json
index 54d4ebd..cdb7d2c 100644
--- a/superset/assets/package.json
+++ b/superset/assets/package.json
@@ -19,7 +19,8 @@
     "lint": "eslint --ignore-path=.eslintignore --ext .js,.jsx .",
     "lint-fix": "eslint --fix --ignore-path=.eslintignore --ext .js,.jsx .",
     "sync-backend": "babel-node --presets env src/syncBackend.js",
-    "cypress": "cypress"
+    "cypress": "cypress",
+    "cypress-debug": "cypress open --config watchForFileChanges=true"
   },
   "repository": {
     "type": "git",


Mime
View raw message