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/10/02 18:31:31 UTC

[GitHub] graceguo-supercat closed pull request #6019: [cypress] Combine multiple tests under visualizations into single test to save running time

graceguo-supercat closed pull request #6019: [cypress] Combine multiple tests under visualizations into single test to save running time
URL: https://github.com/apache/incubator-superset/pull/6019
 
 
   

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.json b/superset/assets/cypress.json
index 3dcda85bbc..dee8cf68bc 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 7651c1bd2f..1797df62b7 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 0000000000..c3f758a21e
--- /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 c285f5a933..5d1de687f9 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 0000000000..f6b9adcc34
--- /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 525cc3c76f..6705b770bc 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 90a26d1668..85eef61fd2 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 0000000000..a9010e1b2c
--- /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 54d4ebd206..cdb7d2c418 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",


 

----------------------------------------------------------------
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