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] Add integration test for area, pie, pivot_table, world_map, dual_line, sunburst, sankey, big_number, bubble, box_plot, treemap #5924

Merged
merged 17 commits into from
Oct 3, 2018
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
export default () => describe('Area', () => {
const AREA_FORM_DATA = {
datasource: '2__table',
viz_type: 'area',
slice_id: 48,
granularity_sqla: 'year',
time_grain_sqla: 'P1D',
time_range: '1960-01-01 : now',
metrics: ['sum__SP_POP_TOTL'],
adhoc_filters: [],
groupby: [],
limit: '25',
order_desc: true,
contribution: false,
row_limit: 50000,
show_brush: 'auto',
show_legend: true,
line_interpolation: 'linear',
stacked_style: 'stack',
color_scheme: 'bnbColors',
rich_tooltip: true,
show_controls: false,
x_axis_label: '',
bottom_margin: 'auto',
x_ticks_layout: 'auto',
x_axis_format: 'smart_date',
x_axis_showminmax: false,
y_axis_format: '.3s',
y_log_scale: false,
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(AREA_FORM_DATA);
cy.get('.nv-area').should('have.length', 1);
});

it('should work with group by', () => {
verify({
...AREA_FORM_DATA,
groupby: ['region'],
});
cy.get('.nv-area').should('have.length', 7);
});

it('should work with groupby and filter', () => {
verify({
...AREA_FORM_DATA,
groupby: ['region'],
adhoc_filters: [{
expressionType: 'SIMPLE',
subject: 'region',
operator: 'in',
comparator: ['South Asia', 'North America'],
clause: 'WHERE',
sqlExpression: null,
fromFormData: true,
filterOptionName: 'filter_txje2ikiv6_wxmn0qwd1xo',
}],
});
cy.get('.nv-area').should('have.length', 2);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
export default () => describe('Big Number', () => {
const BIG_NUMBER_FORM_DATA = {
datasource: '2__table',
viz_type: 'big_number',
slice_id: 42,
granularity_sqla: 'year',
time_grain_sqla: 'P1D',
time_range: '2000+:+2014-01-02',
metric: 'sum__SP_POP_TOTL',
adhoc_filters: [],
compare_lag: '10',
compare_suffix: 'over+10Y',
y_axis_format: '.3s',
show_trend_line: true,
start_y_axis_at_zero: true,
color_picker: {
r: 0,
g: 122,
b: 135,
a: 1,
},
};

function verify(formData) {
cy.visitChartByParams(JSON.stringify(formData));
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: '.big_number' });
}

beforeEach(() => {
cy.login();
cy.server();
cy.route('POST', '/superset/explore_json/**').as('getJson');
});

it('should work', () => {
verify(BIG_NUMBER_FORM_DATA);
cy.get('.chart-container .header_line');
cy.get('.chart-container .subheader_line');
cy.get('.chart-container svg path.vx-linepath');
});

it('should work without subheader', () => {
verify({
...BIG_NUMBER_FORM_DATA,
compare_lag: null,
});
cy.get('.chart-container .header_line');
cy.get('.chart-container .subheader_line');
cy.get('.chart-container svg path.vx-linepath');
});

it('should not render trendline when hidden', () => {
verify({
...BIG_NUMBER_FORM_DATA,
show_trend_line: false,
});
cy.get('.chart-container .header_line');
cy.get('.chart-container .subheader_line');
cy.get('.chart-container').then((containers) => {
expect(containers[0].querySelector('svg')).to.equal(null);
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
export default () => describe('Box Plot', () => {
const BOX_PLOT_FORM_DATA = {
datasource: '2__table',
viz_type: 'box_plot',
slice_id: 49,
granularity_sqla: 'year',
time_grain_sqla: 'P1D',
time_range: '1960-01-01+:+now',
metrics: ['sum__SP_POP_TOTL'],
adhoc_filters: [],
groupby: ['region'],
limit: '25',
color_scheme: 'bnbColors',
whisker_options: 'Min/max+(no+outliers)',
};

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', () => {
verify(BOX_PLOT_FORM_DATA);
cy.get('.chart-container svg rect.nv-boxplot-box').should('have.length', 7);
});

it('should work with filter', () => {
verify({
...BOX_PLOT_FORM_DATA,
adhoc_filters: [{
expressionType: 'SIMPLE',
subject: 'region',
operator: '==',
comparator: 'South Asia',
clause: 'WHERE',
sqlExpression: null,
fromFormData: true,
filterOptionName: 'filter_8aqxcf5co1a_x7lm2d1fq0l',
}],
});
cy.get('.chart-container svg rect.nv-boxplot-box').should('have.length', 1);
});

});
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
export default () => describe('Bubble', () => {
const BUBBLE_FORM_DATA = {
datasource: '2__table',
viz_type: 'bubble',
slice_id: 46,
granularity_sqla: 'year',
time_grain_sqla: 'P1D',
time_range: '2011-01-01+:+2011-01-02',
series: 'region',
entity: 'country_name',
x: 'sum__SP_RUR_TOTL_ZS',
y: 'sum__SP_DYN_LE00_IN',
size: 'sum__SP_POP_TOTL',
max_bubble_size: '50',
limit: 0,
color_scheme: 'bnbColors',
show_legend: true,
x_axis_label: '',
left_margin: 'auto',
x_axis_format: '.3s',
x_ticks_layout: 'auto',
x_log_scale: false,
x_axis_showminmax: false,
y_axis_label: '',
bottom_margin: 'auto',
y_axis_format: '.3s',
y_log_scale: false,
y_axis_showminmax: 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', () => {
verify(BUBBLE_FORM_DATA);
cy.get('.chart-container svg circle').should('have.length', 208);
});

it('should work with filter', () => {
verify({
...BUBBLE_FORM_DATA,
adhoc_filters: [{
expressionType: 'SIMPLE',
subject: 'region',
operator: '==',
comparator: 'South+Asia',
clause: 'WHERE',
sqlExpression: null,
fromFormData: true,
filterOptionName: 'filter_b2tfg1rs8y_8kmrcyxvsqd',
}],
});
cy.get('.chart-container svg circle')
.should('have.length', 9)
.then((nodeList) => {
// Check that all circles have same color.
const color = nodeList[0].getAttribute('fill');
const circles = Array.prototype.slice.call(nodeList);
expect(circles.every(c => c.getAttribute('fill') === color)).to.equal(true);
});
});

});
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
export default () => describe('Dual Line', () => {
const DUAL_LINE_FORM_DATA = {
datasource: '3__table',
viz_type: 'dual_line',
slice_id: 58,
granularity_sqla: 'ds',
time_grain_sqla: 'P1D',
time_range: '100+years+ago+:+now',
color_scheme: 'bnbColors',
x_axis_format: 'smart_date',
metric: 'avg__num',
y_axis_format: '.3s',
metric_2: 'sum__num',
y_axis_2_format: '.3s',
adhoc_filters: [],
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', () => {
verify(DUAL_LINE_FORM_DATA);
cy.get('.chart-container svg path.nv-line').should('have.length', 2);
});

it('should work with filter', () => {
verify({
...DUAL_LINE_FORM_DATA,
adhoc_filters: [{
expressionType: 'SIMPLE',
subject: 'gender',
operator: '==',
comparator: 'girl',
clause: 'WHERE',
sqlExpression: null,
fromFormData: true,
filterOptionName: 'filter_1ep6q50g8vk_48jj6qxdems',
}],
});
cy.get('.chart-container svg path.nv-line').should('have.length', 2);
});

});

53 changes: 53 additions & 0 deletions superset/assets/cypress/integration/explore/visualizations/_pie.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
export default () => describe('Pie', () => {
const PIE_FORM_DATA = {
datasource: '3__table',
viz_type: 'pie',
slice_id: 55,
granularity_sqla: 'ds',
time_grain_sqla: 'P1D',
time_range: '100 years ago : now',
metric: 'sum__num',
adhoc_filters: [],
groupby: ['gender'],
row_limit: 50000,
pie_label_type: 'key',
donut: false,
show_legend: true,
show_labels: true,
labels_outside: true,
color_scheme: 'bnbColors',
};

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 with ad-hoc metric', () => {
verify(PIE_FORM_DATA);
cy.get('.chart-container .nv-pie .nv-slice path').should('have.length', 2);
});

it('should work with simple filter', () => {
verify({
...PIE_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 .nv-pie .nv-slice path').should('have.length', 1);
});
});
Loading