Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cypress] Combine multiple tests under visualizations into single test to save running time #6019

Merged
merged 3 commits into from
Oct 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion superset/assets/cypress.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"baseUrl": "http://localhost:8081",
"videoUploadOnPasses": false,
"ignoreTestFiles": "*.helper.js",
"ignoreTestFiles": [
"_*.js",
"*.helper.js"
],
"projectId": "fbf96q"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
});

});
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
});

});
Original file line number Diff line number Diff line change
@@ -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(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down
15 changes: 15 additions & 0 deletions superset/assets/cypress/integration/explore/visualizations/all.js
Original file line number Diff line number Diff line change
@@ -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();
});
3 changes: 2 additions & 1 deletion superset/assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down