mirror of
https://github.com/apache/superset.git
synced 2026-04-26 19:44:58 +00:00
build: upgrade Cypress and re-enable visualization tests (#10158)
This commit is contained in:
@@ -1,115 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import readResponseBlob from '../../../utils/readResponseBlob';
|
||||
|
||||
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', () => {
|
||||
cy.visitChartByParams(
|
||||
JSON.stringify({
|
||||
...AREA_FORM_DATA,
|
||||
groupby: ['region'],
|
||||
adhoc_filters: [
|
||||
{
|
||||
expressionType: 'SIMPLE',
|
||||
subject: 'region',
|
||||
operator: 'in',
|
||||
comparator: ['South Asia', 'North America'],
|
||||
clause: 'WHERE',
|
||||
sqlExpression: null,
|
||||
filterOptionName: 'filter_txje2ikiv6_wxmn0qwd1xo',
|
||||
},
|
||||
],
|
||||
}),
|
||||
);
|
||||
|
||||
cy.wait('@getJson').then(async xhr => {
|
||||
cy.verifyResponseCodes(xhr);
|
||||
|
||||
const responseBody = await readResponseBlob(xhr.response.body);
|
||||
|
||||
// Make sure data is sorted correctly
|
||||
const firstRow = responseBody.data[0].values;
|
||||
const secondRow = responseBody.data[1].values;
|
||||
expect(firstRow[firstRow.length - 1].y).to.be.greaterThan(
|
||||
secondRow[secondRow.length - 1].y,
|
||||
);
|
||||
cy.verifySliceContainer('svg');
|
||||
});
|
||||
cy.get('.nv-area').should('have.length', 2);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,114 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import readResponseBlob from '../../../utils/readResponseBlob';
|
||||
|
||||
describe('Visualization > 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', () => {
|
||||
cy.visitChartByParams(
|
||||
JSON.stringify({
|
||||
...AREA_FORM_DATA,
|
||||
groupby: ['region'],
|
||||
adhoc_filters: [
|
||||
{
|
||||
expressionType: 'SIMPLE',
|
||||
subject: 'region',
|
||||
operator: 'in',
|
||||
comparator: ['South Asia', 'North America'],
|
||||
clause: 'WHERE',
|
||||
sqlExpression: null,
|
||||
filterOptionName: 'filter_txje2ikiv6_wxmn0qwd1xo',
|
||||
},
|
||||
],
|
||||
}),
|
||||
);
|
||||
|
||||
cy.wait('@getJson').then(async xhr => {
|
||||
cy.verifyResponseCodes(xhr);
|
||||
|
||||
const responseBody = await readResponseBlob(xhr.response.body);
|
||||
|
||||
// Make sure data is sorted correctly
|
||||
const firstRow = responseBody.data[0].values;
|
||||
const secondRow = responseBody.data[1].values;
|
||||
expect(firstRow[firstRow.length - 1].y).to.be.greaterThan(
|
||||
secondRow[secondRow.length - 1].y,
|
||||
);
|
||||
cy.verifySliceContainer('svg');
|
||||
});
|
||||
cy.get('.nv-area').should('have.length', 2);
|
||||
});
|
||||
});
|
||||
@@ -1,83 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
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').should('not.exist');
|
||||
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 svg').should('not.exist');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
describe('Visualization > Big Number with Trendline', () => {
|
||||
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').should('not.exist');
|
||||
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 svg').should('not.exist');
|
||||
});
|
||||
});
|
||||
@@ -1,86 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { FORM_DATA_DEFAULTS, NUM_METRIC } from './shared.helper';
|
||||
import readResponseBlob from '../../../utils/readResponseBlob';
|
||||
|
||||
// Big Number Total
|
||||
|
||||
export default () =>
|
||||
describe('Big Number Total', () => {
|
||||
const BIG_NUMBER_DEFAULTS = {
|
||||
...FORM_DATA_DEFAULTS,
|
||||
viz_type: 'big_number_total',
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
cy.login();
|
||||
cy.server();
|
||||
cy.route('POST', '/superset/explore_json/**').as('getJson');
|
||||
});
|
||||
|
||||
it('Test big number chart with adhoc metric', () => {
|
||||
const formData = { ...BIG_NUMBER_DEFAULTS, metric: NUM_METRIC };
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({
|
||||
waitAlias: '@getJson',
|
||||
querySubstring: NUM_METRIC.label,
|
||||
});
|
||||
});
|
||||
|
||||
it('Test big number chart with simple filter', () => {
|
||||
const filters = [
|
||||
{
|
||||
expressionType: 'SIMPLE',
|
||||
subject: 'name',
|
||||
operator: 'in',
|
||||
comparator: ['Aaron', 'Amy', 'Andrea'],
|
||||
clause: 'WHERE',
|
||||
sqlExpression: null,
|
||||
filterOptionName: 'filter_4y6teao56zs_ebjsvwy48c',
|
||||
},
|
||||
];
|
||||
|
||||
const formData = {
|
||||
...BIG_NUMBER_DEFAULTS,
|
||||
metric: 'count',
|
||||
adhoc_filters: filters,
|
||||
};
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({ waitAlias: '@getJson' });
|
||||
});
|
||||
|
||||
it('Test big number chart ignores groupby', () => {
|
||||
const formData = {
|
||||
...BIG_NUMBER_DEFAULTS,
|
||||
metric: NUM_METRIC,
|
||||
groupby: ['state'],
|
||||
};
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.wait(['@getJson']).then(async xhr => {
|
||||
cy.verifyResponseCodes(xhr);
|
||||
cy.verifySliceContainer();
|
||||
|
||||
const responseBody = await readResponseBlob(xhr.response.body);
|
||||
expect(responseBody.query).not.contains(formData.groupby[0]);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,85 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { FORM_DATA_DEFAULTS, NUM_METRIC } from './shared.helper';
|
||||
import readResponseBlob from '../../../utils/readResponseBlob';
|
||||
|
||||
// Big Number Total
|
||||
|
||||
describe('Visualization > Big Number Total', () => {
|
||||
const BIG_NUMBER_DEFAULTS = {
|
||||
...FORM_DATA_DEFAULTS,
|
||||
viz_type: 'big_number_total',
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
cy.login();
|
||||
cy.server();
|
||||
cy.route('POST', '/superset/explore_json/**').as('getJson');
|
||||
});
|
||||
|
||||
it('Test big number chart with adhoc metric', () => {
|
||||
const formData = { ...BIG_NUMBER_DEFAULTS, metric: NUM_METRIC };
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({
|
||||
waitAlias: '@getJson',
|
||||
querySubstring: NUM_METRIC.label,
|
||||
});
|
||||
});
|
||||
|
||||
it('Test big number chart with simple filter', () => {
|
||||
const filters = [
|
||||
{
|
||||
expressionType: 'SIMPLE',
|
||||
subject: 'name',
|
||||
operator: 'in',
|
||||
comparator: ['Aaron', 'Amy', 'Andrea'],
|
||||
clause: 'WHERE',
|
||||
sqlExpression: null,
|
||||
filterOptionName: 'filter_4y6teao56zs_ebjsvwy48c',
|
||||
},
|
||||
];
|
||||
|
||||
const formData = {
|
||||
...BIG_NUMBER_DEFAULTS,
|
||||
metric: 'count',
|
||||
adhoc_filters: filters,
|
||||
};
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({ waitAlias: '@getJson' });
|
||||
});
|
||||
|
||||
it('Test big number chart ignores groupby', () => {
|
||||
const formData = {
|
||||
...BIG_NUMBER_DEFAULTS,
|
||||
metric: NUM_METRIC,
|
||||
groupby: ['state'],
|
||||
};
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.wait(['@getJson']).then(async xhr => {
|
||||
cy.verifyResponseCodes(xhr);
|
||||
cy.verifySliceContainer();
|
||||
|
||||
const responseBody = await readResponseBlob(xhr.response.body);
|
||||
expect(responseBody.query).not.contains(formData.groupby[0]);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,75 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
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,
|
||||
filterOptionName: 'filter_8aqxcf5co1a_x7lm2d1fq0l',
|
||||
},
|
||||
],
|
||||
});
|
||||
cy.get('.chart-container svg rect.nv-boxplot-box').should(
|
||||
'have.length',
|
||||
1,
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,68 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
describe('Visualization > 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.vx-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,
|
||||
filterOptionName: 'filter_8aqxcf5co1a_x7lm2d1fq0l',
|
||||
},
|
||||
],
|
||||
});
|
||||
cy.get('.chart-container svg rect.vx-boxplot-box').should('have.length', 1);
|
||||
});
|
||||
});
|
||||
@@ -1,92 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
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,
|
||||
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,
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,95 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
describe('Visualization > 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);
|
||||
// number of circles = 214 rows
|
||||
cy.get('.chart-container svg .nv-point-clips circle').should(
|
||||
'have.length',
|
||||
214,
|
||||
);
|
||||
});
|
||||
|
||||
it('should work with filter', () => {
|
||||
verify({
|
||||
...BUBBLE_FORM_DATA,
|
||||
adhoc_filters: [
|
||||
{
|
||||
expressionType: 'SIMPLE',
|
||||
subject: 'region',
|
||||
operator: '==',
|
||||
comparator: 'South+Asia',
|
||||
clause: 'WHERE',
|
||||
sqlExpression: null,
|
||||
filterOptionName: 'filter_b2tfg1rs8y_8kmrcyxvsqd',
|
||||
},
|
||||
],
|
||||
});
|
||||
cy.get('.chart-container svg .nv-point-clips circle')
|
||||
.should('have.length', 8)
|
||||
.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,
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,91 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
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,
|
||||
filterOptionName: 'filter_tqx1en70hh_7nksse7nqic',
|
||||
},
|
||||
],
|
||||
});
|
||||
cy.get('.chart-container .nvd3 path.nv-line').should('have.length', 1);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,90 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
describe('Visualization > 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,
|
||||
filterOptionName: 'filter_tqx1en70hh_7nksse7nqic',
|
||||
},
|
||||
],
|
||||
});
|
||||
cy.get('.chart-container .nvd3 path.nv-line').should('have.length', 1);
|
||||
});
|
||||
});
|
||||
@@ -1,84 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { FORM_DATA_DEFAULTS, NUM_METRIC } from './shared.helper';
|
||||
|
||||
// Dist bar
|
||||
|
||||
export default () =>
|
||||
describe('Distribution bar chart', () => {
|
||||
const VIZ_DEFAULTS = { ...FORM_DATA_DEFAULTS, viz_type: 'dist_bar' };
|
||||
|
||||
beforeEach(() => {
|
||||
cy.login();
|
||||
cy.server();
|
||||
cy.route('POST', '/superset/explore_json/**').as('getJson');
|
||||
});
|
||||
|
||||
it('Test dist bar with adhoc metric', () => {
|
||||
const formData = {
|
||||
...VIZ_DEFAULTS,
|
||||
metrics: NUM_METRIC,
|
||||
groupby: ['state'],
|
||||
};
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({
|
||||
waitAlias: '@getJson',
|
||||
querySubstring: NUM_METRIC.label,
|
||||
chartSelector: 'svg',
|
||||
});
|
||||
});
|
||||
|
||||
it('Test dist bar with series', () => {
|
||||
const formData = {
|
||||
...VIZ_DEFAULTS,
|
||||
metrics: NUM_METRIC,
|
||||
groupby: ['state'],
|
||||
columns: ['gender'],
|
||||
};
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' });
|
||||
});
|
||||
|
||||
it('Test dist bar with row limit', () => {
|
||||
const formData = {
|
||||
...VIZ_DEFAULTS,
|
||||
metrics: NUM_METRIC,
|
||||
groupby: ['state'],
|
||||
row_limit: 10,
|
||||
};
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' });
|
||||
});
|
||||
|
||||
it('Test dist bar with contribution', () => {
|
||||
const formData = {
|
||||
...VIZ_DEFAULTS,
|
||||
metrics: NUM_METRIC,
|
||||
groupby: ['state'],
|
||||
columns: ['gender'],
|
||||
contribution: true,
|
||||
};
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' });
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,81 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { FORM_DATA_DEFAULTS, NUM_METRIC } from './shared.helper';
|
||||
|
||||
describe('Visualization > Distribution bar chart', () => {
|
||||
const VIZ_DEFAULTS = { ...FORM_DATA_DEFAULTS, viz_type: 'dist_bar' };
|
||||
|
||||
beforeEach(() => {
|
||||
cy.login();
|
||||
cy.server();
|
||||
cy.route('POST', '/superset/explore_json/**').as('getJson');
|
||||
});
|
||||
|
||||
it('should work with adhoc metric', () => {
|
||||
const formData = {
|
||||
...VIZ_DEFAULTS,
|
||||
metrics: NUM_METRIC,
|
||||
groupby: ['state'],
|
||||
};
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({
|
||||
waitAlias: '@getJson',
|
||||
querySubstring: NUM_METRIC.label,
|
||||
chartSelector: 'svg',
|
||||
});
|
||||
});
|
||||
|
||||
it('should work with series', () => {
|
||||
const formData = {
|
||||
...VIZ_DEFAULTS,
|
||||
metrics: NUM_METRIC,
|
||||
groupby: ['state'],
|
||||
columns: ['gender'],
|
||||
};
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' });
|
||||
});
|
||||
|
||||
it('should work with row limit', () => {
|
||||
const formData = {
|
||||
...VIZ_DEFAULTS,
|
||||
metrics: NUM_METRIC,
|
||||
groupby: ['state'],
|
||||
row_limit: 10,
|
||||
};
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' });
|
||||
});
|
||||
|
||||
it('should work with contribution', () => {
|
||||
const formData = {
|
||||
...VIZ_DEFAULTS,
|
||||
metrics: NUM_METRIC,
|
||||
groupby: ['state'],
|
||||
columns: ['gender'],
|
||||
contribution: true,
|
||||
};
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' });
|
||||
});
|
||||
});
|
||||
@@ -1,71 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
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,
|
||||
filterOptionName: 'filter_1ep6q50g8vk_48jj6qxdems',
|
||||
},
|
||||
],
|
||||
});
|
||||
cy.get('.chart-container svg path.nv-line').should('have.length', 2);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,70 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
describe('Visualization > 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: 'sum__num',
|
||||
y_axis_format: '.3s',
|
||||
metric_2: 'count',
|
||||
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,
|
||||
filterOptionName: 'filter_1ep6q50g8vk_48jj6qxdems',
|
||||
},
|
||||
],
|
||||
});
|
||||
cy.get('.chart-container svg path.nv-line').should('have.length', 2);
|
||||
});
|
||||
});
|
||||
@@ -1,43 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { FORM_DATA_DEFAULTS } from './shared.helper';
|
||||
|
||||
export default () =>
|
||||
describe('FilterBox', () => {
|
||||
const VIZ_DEFAULTS = { ...FORM_DATA_DEFAULTS, viz_type: 'filter_box' };
|
||||
|
||||
function verify(formData) {
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({ waitAlias: '@getJson' });
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
cy.server();
|
||||
cy.login();
|
||||
cy.route('POST', '/superset/explore_json/**').as('getJson');
|
||||
});
|
||||
|
||||
it('should work with default date filter', () => {
|
||||
verify(VIZ_DEFAULTS);
|
||||
// Filter box should default to having a date filter with no filter selected
|
||||
cy.get('div.filter_box').within(() => {
|
||||
cy.get('span').contains('No filter');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,81 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
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,
|
||||
filterOptionName: 'filter_tqx1en70hh_7nksse7nqic',
|
||||
},
|
||||
],
|
||||
});
|
||||
cy.get('.chart-container svg .vx-bar').should('have.length', 5);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,88 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
describe('Visualization > 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, // number of bins
|
||||
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',
|
||||
HISTOGRAM_FORM_DATA.link_length,
|
||||
);
|
||||
});
|
||||
|
||||
it('should work with group by', () => {
|
||||
verify({
|
||||
...HISTOGRAM_FORM_DATA,
|
||||
groupby: ['gender'],
|
||||
});
|
||||
cy.get('.chart-container svg .vx-bar').should(
|
||||
'have.length',
|
||||
HISTOGRAM_FORM_DATA.link_length * 2,
|
||||
);
|
||||
});
|
||||
|
||||
it('should work with filter and update num bins', () => {
|
||||
const numBins = 2;
|
||||
verify({
|
||||
...HISTOGRAM_FORM_DATA,
|
||||
link_length: numBins,
|
||||
adhoc_filters: [
|
||||
{
|
||||
expressionType: 'SIMPLE',
|
||||
subject: 'state',
|
||||
operator: '==',
|
||||
comparator: 'CA',
|
||||
clause: 'WHERE',
|
||||
sqlExpression: null,
|
||||
filterOptionName: 'filter_tqx1en70hh_7nksse7nqic',
|
||||
},
|
||||
],
|
||||
});
|
||||
cy.get('.chart-container svg .vx-bar').should('have.length', numBins);
|
||||
});
|
||||
});
|
||||
@@ -1,57 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import AreaTest from './area';
|
||||
import BigNumberTest from './big_number';
|
||||
import BigNumberTotalTest from './big_number_total';
|
||||
import BubbleTest from './bubble';
|
||||
import CompareTest from './compare';
|
||||
import DistBarTest from './dist_bar';
|
||||
import DualLineTest from './dual_line';
|
||||
import FilterBox from './filter_box';
|
||||
import HistogramTest from './histogram';
|
||||
import LineTest from './line';
|
||||
import PieTest from './pie';
|
||||
import PivotTableTest from './pivot_table';
|
||||
import SankeyTest from './sankey';
|
||||
import SunburstTest from './sunburst';
|
||||
import TableTest from './table';
|
||||
import TimeTableTest from './time_table';
|
||||
import TreemapTest from './treemap';
|
||||
import WorldMapTest from './world_map';
|
||||
|
||||
describe('All Visualizations', () => {
|
||||
AreaTest();
|
||||
BigNumberTest();
|
||||
BigNumberTotalTest();
|
||||
BubbleTest();
|
||||
CompareTest();
|
||||
DistBarTest();
|
||||
DualLineTest();
|
||||
FilterBox();
|
||||
HistogramTest();
|
||||
LineTest();
|
||||
PieTest();
|
||||
PivotTableTest();
|
||||
SankeyTest();
|
||||
SunburstTest();
|
||||
TableTest();
|
||||
TimeTableTest();
|
||||
TreemapTest();
|
||||
WorldMapTest();
|
||||
});
|
||||
@@ -1,258 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { FORM_DATA_DEFAULTS, NUM_METRIC, SIMPLE_FILTER } from './shared.helper';
|
||||
|
||||
export default () =>
|
||||
describe('Line', () => {
|
||||
const LINE_CHART_DEFAULTS = { ...FORM_DATA_DEFAULTS, viz_type: 'line' };
|
||||
|
||||
beforeEach(() => {
|
||||
cy.login();
|
||||
cy.server();
|
||||
cy.route('POST', '/superset/explore_json/**').as('getJson');
|
||||
});
|
||||
|
||||
it('Test line chart with adhoc metric', () => {
|
||||
const formData = { ...LINE_CHART_DEFAULTS, metrics: [NUM_METRIC] };
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' });
|
||||
});
|
||||
|
||||
it('Test line chart with groupby', () => {
|
||||
const metrics = ['count'];
|
||||
const groupby = ['gender'];
|
||||
|
||||
const formData = { ...LINE_CHART_DEFAULTS, metrics, groupby };
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' });
|
||||
});
|
||||
|
||||
it('Test line chart with simple filter', () => {
|
||||
const metrics = ['count'];
|
||||
const filters = [SIMPLE_FILTER];
|
||||
|
||||
const formData = {
|
||||
...LINE_CHART_DEFAULTS,
|
||||
metrics,
|
||||
adhoc_filters: filters,
|
||||
};
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' });
|
||||
});
|
||||
|
||||
it('Test line chart with series limit sort asc', () => {
|
||||
const formData = {
|
||||
...LINE_CHART_DEFAULTS,
|
||||
metrics: [NUM_METRIC],
|
||||
limit: 10,
|
||||
groupby: ['name'],
|
||||
timeseries_limit_metric: NUM_METRIC,
|
||||
};
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' });
|
||||
});
|
||||
|
||||
it('Test line chart with series limit sort desc', () => {
|
||||
const formData = {
|
||||
...LINE_CHART_DEFAULTS,
|
||||
metrics: [NUM_METRIC],
|
||||
limit: 10,
|
||||
groupby: ['name'],
|
||||
timeseries_limit_metric: NUM_METRIC,
|
||||
order_desc: true,
|
||||
};
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' });
|
||||
});
|
||||
|
||||
it('Test line chart with rolling avg', () => {
|
||||
const metrics = [NUM_METRIC];
|
||||
|
||||
const formData = {
|
||||
...LINE_CHART_DEFAULTS,
|
||||
metrics,
|
||||
rolling_type: 'mean',
|
||||
rolling_periods: 10,
|
||||
};
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' });
|
||||
});
|
||||
|
||||
it('Test line chart with time shift 1 year', () => {
|
||||
const metrics = [NUM_METRIC];
|
||||
|
||||
const formData = {
|
||||
...LINE_CHART_DEFAULTS,
|
||||
metrics,
|
||||
time_compare: ['1+year'],
|
||||
comparison_type: 'values',
|
||||
groupby: ['gender'],
|
||||
};
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' });
|
||||
|
||||
// Offset color should match original line color
|
||||
cy.get('.nv-legend-text')
|
||||
.contains('boy')
|
||||
.siblings()
|
||||
.first()
|
||||
.should('have.attr', 'style')
|
||||
.then(style => {
|
||||
cy.get('.nv-legend-text')
|
||||
.contains('boy, 1 year offset')
|
||||
.siblings()
|
||||
.first()
|
||||
.should('have.attr', 'style')
|
||||
.and('eq', style);
|
||||
});
|
||||
|
||||
cy.get('.nv-legend-text')
|
||||
.contains('girl')
|
||||
.siblings()
|
||||
.first()
|
||||
.should('have.attr', 'style')
|
||||
.then(style => {
|
||||
cy.get('.nv-legend-text')
|
||||
.contains('girl, 1 year offset')
|
||||
.siblings()
|
||||
.first()
|
||||
.should('have.attr', 'style')
|
||||
.and('eq', style);
|
||||
});
|
||||
});
|
||||
|
||||
it('Test line chart with time shift yoy', () => {
|
||||
const metrics = [NUM_METRIC];
|
||||
|
||||
const formData = {
|
||||
...LINE_CHART_DEFAULTS,
|
||||
metrics,
|
||||
time_compare: ['1+year'],
|
||||
comparison_type: 'ratio',
|
||||
};
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' });
|
||||
});
|
||||
|
||||
it('Test line chart with time shift percentage change', () => {
|
||||
const metrics = [NUM_METRIC];
|
||||
|
||||
const formData = {
|
||||
...LINE_CHART_DEFAULTS,
|
||||
metrics,
|
||||
time_compare: ['1+year'],
|
||||
comparison_type: 'percentage',
|
||||
};
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' });
|
||||
});
|
||||
|
||||
it('Test verbose name shows up in legend', () => {
|
||||
const formData = {
|
||||
...LINE_CHART_DEFAULTS,
|
||||
metrics: ['count'],
|
||||
};
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' });
|
||||
cy.get('text.nv-legend-text').contains('COUNT(*)');
|
||||
});
|
||||
|
||||
it('Test hidden annotation', () => {
|
||||
const formData = {
|
||||
...LINE_CHART_DEFAULTS,
|
||||
metrics: ['count'],
|
||||
annotation_layers: [
|
||||
{
|
||||
name: 'Goal+line',
|
||||
annotationType: 'FORMULA',
|
||||
sourceType: '',
|
||||
value: 'y=140000',
|
||||
overrides: { time_range: null },
|
||||
show: false,
|
||||
titleColumn: '',
|
||||
descriptionColumns: [],
|
||||
timeColumn: '',
|
||||
intervalEndColumn: '',
|
||||
color: null,
|
||||
opacity: '',
|
||||
style: 'solid',
|
||||
width: 1,
|
||||
showMarkers: false,
|
||||
hideLine: false,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' });
|
||||
cy.get('.slice_container').within(() => {
|
||||
// Goal line annotation doesn't show up in legend
|
||||
cy.get('.nv-legend-text').should('have.length', 1);
|
||||
});
|
||||
});
|
||||
|
||||
it('Test event annotation time override', () => {
|
||||
cy.request('/chart/api/read?_flt_3_slice_name=Daily+Totals').then(
|
||||
response => {
|
||||
const value = response.body.pks[0];
|
||||
const formData = {
|
||||
...LINE_CHART_DEFAULTS,
|
||||
metrics: ['count'],
|
||||
annotation_layers: [
|
||||
{
|
||||
name: 'Yearly date',
|
||||
annotationType: 'EVENT',
|
||||
sourceType: 'table',
|
||||
value,
|
||||
overrides: { time_range: null },
|
||||
show: true,
|
||||
titleColumn: 'ds',
|
||||
descriptionColumns: ['ds'],
|
||||
timeColumn: 'ds',
|
||||
color: null,
|
||||
opacity: '',
|
||||
style: 'solid',
|
||||
width: 1,
|
||||
showMarkers: false,
|
||||
hideLine: false,
|
||||
},
|
||||
],
|
||||
};
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
},
|
||||
);
|
||||
|
||||
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' });
|
||||
cy.get('.slice_container').within(() => {
|
||||
cy.get('.nv-event-annotation-layer-0')
|
||||
.children()
|
||||
.should('have.length', 44);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,257 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { FORM_DATA_DEFAULTS, NUM_METRIC, SIMPLE_FILTER } from './shared.helper';
|
||||
|
||||
describe('Visualization > Line', () => {
|
||||
const LINE_CHART_DEFAULTS = { ...FORM_DATA_DEFAULTS, viz_type: 'line' };
|
||||
|
||||
beforeEach(() => {
|
||||
cy.login();
|
||||
cy.server();
|
||||
cy.route('POST', '/superset/explore_json/**').as('getJson');
|
||||
});
|
||||
|
||||
it('should work with adhoc metric', () => {
|
||||
const formData = { ...LINE_CHART_DEFAULTS, metrics: [NUM_METRIC] };
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' });
|
||||
});
|
||||
|
||||
it('should work with groupby', () => {
|
||||
const metrics = ['count'];
|
||||
const groupby = ['gender'];
|
||||
|
||||
const formData = { ...LINE_CHART_DEFAULTS, metrics, groupby };
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' });
|
||||
});
|
||||
|
||||
it('should work with simple filter', () => {
|
||||
const metrics = ['count'];
|
||||
const filters = [SIMPLE_FILTER];
|
||||
|
||||
const formData = {
|
||||
...LINE_CHART_DEFAULTS,
|
||||
metrics,
|
||||
adhoc_filters: filters,
|
||||
};
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' });
|
||||
});
|
||||
|
||||
it('should work with series limit sort asc', () => {
|
||||
const formData = {
|
||||
...LINE_CHART_DEFAULTS,
|
||||
metrics: [NUM_METRIC],
|
||||
limit: 10,
|
||||
groupby: ['name'],
|
||||
timeseries_limit_metric: NUM_METRIC,
|
||||
};
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' });
|
||||
});
|
||||
|
||||
it('should work with series limit sort desc', () => {
|
||||
const formData = {
|
||||
...LINE_CHART_DEFAULTS,
|
||||
metrics: [NUM_METRIC],
|
||||
limit: 10,
|
||||
groupby: ['name'],
|
||||
timeseries_limit_metric: NUM_METRIC,
|
||||
order_desc: true,
|
||||
};
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' });
|
||||
});
|
||||
|
||||
it('should work with rolling avg', () => {
|
||||
const metrics = [NUM_METRIC];
|
||||
|
||||
const formData = {
|
||||
...LINE_CHART_DEFAULTS,
|
||||
metrics,
|
||||
rolling_type: 'mean',
|
||||
rolling_periods: 10,
|
||||
};
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' });
|
||||
});
|
||||
|
||||
it('should work with time shift 1 year', () => {
|
||||
const metrics = [NUM_METRIC];
|
||||
|
||||
const formData = {
|
||||
...LINE_CHART_DEFAULTS,
|
||||
metrics,
|
||||
time_compare: ['1+year'],
|
||||
comparison_type: 'values',
|
||||
groupby: ['gender'],
|
||||
};
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' });
|
||||
|
||||
// Offset color should match original line color
|
||||
cy.get('.nv-legend-text')
|
||||
.contains('boy')
|
||||
.siblings()
|
||||
.first()
|
||||
.should('have.attr', 'style')
|
||||
.then(style => {
|
||||
cy.get('.nv-legend-text')
|
||||
.contains('boy, 1 year offset')
|
||||
.siblings()
|
||||
.first()
|
||||
.should('have.attr', 'style')
|
||||
.and('eq', style);
|
||||
});
|
||||
|
||||
cy.get('.nv-legend-text')
|
||||
.contains('girl')
|
||||
.siblings()
|
||||
.first()
|
||||
.should('have.attr', 'style')
|
||||
.then(style => {
|
||||
cy.get('.nv-legend-text')
|
||||
.contains('girl, 1 year offset')
|
||||
.siblings()
|
||||
.first()
|
||||
.should('have.attr', 'style')
|
||||
.and('eq', style);
|
||||
});
|
||||
});
|
||||
|
||||
it('should work with time shift yoy', () => {
|
||||
const metrics = [NUM_METRIC];
|
||||
|
||||
const formData = {
|
||||
...LINE_CHART_DEFAULTS,
|
||||
metrics,
|
||||
time_compare: ['1+year'],
|
||||
comparison_type: 'ratio',
|
||||
};
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' });
|
||||
});
|
||||
|
||||
it('should work with time shift percentage change', () => {
|
||||
const metrics = [NUM_METRIC];
|
||||
|
||||
const formData = {
|
||||
...LINE_CHART_DEFAULTS,
|
||||
metrics,
|
||||
time_compare: ['1+year'],
|
||||
comparison_type: 'percentage',
|
||||
};
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' });
|
||||
});
|
||||
|
||||
it('Test verbose name shows up in legend', () => {
|
||||
const formData = {
|
||||
...LINE_CHART_DEFAULTS,
|
||||
metrics: ['count'],
|
||||
};
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' });
|
||||
cy.get('text.nv-legend-text').contains('COUNT(*)');
|
||||
});
|
||||
|
||||
it('Test hidden annotation', () => {
|
||||
const formData = {
|
||||
...LINE_CHART_DEFAULTS,
|
||||
metrics: ['count'],
|
||||
annotation_layers: [
|
||||
{
|
||||
name: 'Goal+line',
|
||||
annotationType: 'FORMULA',
|
||||
sourceType: '',
|
||||
value: 'y=140000',
|
||||
overrides: { time_range: null },
|
||||
show: false,
|
||||
titleColumn: '',
|
||||
descriptionColumns: [],
|
||||
timeColumn: '',
|
||||
intervalEndColumn: '',
|
||||
color: null,
|
||||
opacity: '',
|
||||
style: 'solid',
|
||||
width: 1,
|
||||
showMarkers: false,
|
||||
hideLine: false,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' });
|
||||
cy.get('.slice_container').within(() => {
|
||||
// Goal line annotation doesn't show up in legend
|
||||
cy.get('.nv-legend-text').should('have.length', 1);
|
||||
});
|
||||
});
|
||||
|
||||
it('Test event annotation time override', () => {
|
||||
cy.request('/chart/api/read?_flt_3_slice_name=Daily+Totals').then(
|
||||
response => {
|
||||
const value = response.body.pks[0];
|
||||
const formData = {
|
||||
...LINE_CHART_DEFAULTS,
|
||||
metrics: ['count'],
|
||||
annotation_layers: [
|
||||
{
|
||||
name: 'Yearly date',
|
||||
annotationType: 'EVENT',
|
||||
sourceType: 'table',
|
||||
value,
|
||||
overrides: { time_range: null },
|
||||
show: true,
|
||||
titleColumn: 'ds',
|
||||
descriptionColumns: ['ds'],
|
||||
timeColumn: 'ds',
|
||||
color: null,
|
||||
opacity: '',
|
||||
style: 'solid',
|
||||
width: 1,
|
||||
showMarkers: false,
|
||||
hideLine: false,
|
||||
},
|
||||
],
|
||||
};
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
},
|
||||
);
|
||||
|
||||
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' });
|
||||
cy.get('.slice_container').within(() => {
|
||||
cy.get('.nv-event-annotation-layer-0')
|
||||
.children()
|
||||
.should('have.length', 44);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,79 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
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,
|
||||
filterOptionName: 'filter_tqx1en70hh_7nksse7nqic',
|
||||
},
|
||||
],
|
||||
});
|
||||
cy.get('.chart-container .nv-pie .nv-slice path').should(
|
||||
'have.length',
|
||||
1,
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,72 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
describe('Visualization > 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,
|
||||
filterOptionName: 'filter_tqx1en70hh_7nksse7nqic',
|
||||
},
|
||||
],
|
||||
});
|
||||
cy.get('.chart-container .nv-pie .nv-slice path').should('have.length', 1);
|
||||
});
|
||||
});
|
||||
@@ -1,128 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
export default () =>
|
||||
describe('Pivot Table', () => {
|
||||
const PIVOT_TABLE_FORM_DATA = {
|
||||
datasource: '3__table',
|
||||
viz_type: 'pivot_table',
|
||||
slice_id: 61,
|
||||
granularity_sqla: 'ds',
|
||||
time_grain_sqla: 'P1D',
|
||||
time_range: '100+years+ago+:+now',
|
||||
metrics: ['sum__num'],
|
||||
adhoc_filters: [],
|
||||
groupby: ['name'],
|
||||
columns: ['state'],
|
||||
row_limit: 50000,
|
||||
pandas_aggfunc: 'sum',
|
||||
pivot_margins: true,
|
||||
number_format: '.3s',
|
||||
combine_metric: false,
|
||||
};
|
||||
|
||||
const TEST_METRIC = {
|
||||
expressionType: 'SIMPLE',
|
||||
column: {
|
||||
id: 338,
|
||||
column_name: 'sum_boys',
|
||||
expression: '',
|
||||
filterable: false,
|
||||
groupby: false,
|
||||
is_dttm: false,
|
||||
type: 'BIGINT',
|
||||
optionName: '_col_sum_boys',
|
||||
},
|
||||
aggregate: 'SUM',
|
||||
hasCustomLabel: false,
|
||||
label: 'SUM(sum_boys)',
|
||||
optionName: 'metric_gvpdjt0v2qf_6hkf56o012',
|
||||
};
|
||||
|
||||
function verify(formData) {
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'table' });
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
cy.server();
|
||||
cy.login();
|
||||
cy.route('POST', '/superset/explore_json/**').as('getJson');
|
||||
});
|
||||
|
||||
it('should work with single groupby', () => {
|
||||
verify(PIVOT_TABLE_FORM_DATA);
|
||||
cy.get('.chart-container tr th').then(ths => {
|
||||
expect(ths.find(th => th.innerText.trim() === 'name')).to.not.equal(
|
||||
undefined,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('should work with more than one groupby', () => {
|
||||
verify({
|
||||
...PIVOT_TABLE_FORM_DATA,
|
||||
groupby: ['name', 'gender'],
|
||||
});
|
||||
cy.get('.chart-container tr th').then(ths => {
|
||||
expect(ths.find(th => th.innerText.trim() === 'name')).to.not.equal(
|
||||
undefined,
|
||||
);
|
||||
expect(ths.find(th => th.innerText.trim() === 'gender')).to.not.equal(
|
||||
undefined,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('should work with multiple metrics', () => {
|
||||
verify({
|
||||
...PIVOT_TABLE_FORM_DATA,
|
||||
metrics: ['sum__num', TEST_METRIC],
|
||||
});
|
||||
cy.get('.chart-container tr th').then(ths => {
|
||||
expect(ths.find(th => th.innerText.trim() === 'sum__num')).to.not.equal(
|
||||
undefined,
|
||||
);
|
||||
expect(
|
||||
ths.find(th => th.innerText.trim() === 'SUM(sum_boys)'),
|
||||
).to.not.equal(undefined);
|
||||
});
|
||||
});
|
||||
|
||||
it('should work with multiple groupby and multiple metrics', () => {
|
||||
verify({
|
||||
...PIVOT_TABLE_FORM_DATA,
|
||||
groupby: ['name', 'gender'],
|
||||
metrics: ['sum__num', TEST_METRIC],
|
||||
});
|
||||
cy.get('.chart-container tr th').then(ths => {
|
||||
expect(ths.find(th => th.innerText.trim() === 'name')).to.not.equal(
|
||||
undefined,
|
||||
);
|
||||
expect(ths.find(th => th.innerText.trim() === 'gender')).to.not.equal(
|
||||
undefined,
|
||||
);
|
||||
expect(ths.find(th => th.innerText.trim() === 'sum__num')).to.not.equal(
|
||||
undefined,
|
||||
);
|
||||
expect(
|
||||
ths.find(th => th.innerText.trim() === 'SUM(sum_boys)'),
|
||||
).to.not.equal(undefined);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,107 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
describe('Visualization > Pivot Table', () => {
|
||||
const PIVOT_TABLE_FORM_DATA = {
|
||||
datasource: '3__table',
|
||||
viz_type: 'pivot_table',
|
||||
slice_id: 61,
|
||||
granularity_sqla: 'ds',
|
||||
time_grain_sqla: 'P1D',
|
||||
time_range: '100+years+ago+:+now',
|
||||
metrics: ['sum__num'],
|
||||
adhoc_filters: [],
|
||||
groupby: ['name'],
|
||||
columns: ['state'],
|
||||
row_limit: 50000,
|
||||
pandas_aggfunc: 'sum',
|
||||
pivot_margins: true,
|
||||
number_format: '.3s',
|
||||
combine_metric: false,
|
||||
};
|
||||
|
||||
const TEST_METRIC = {
|
||||
expressionType: 'SIMPLE',
|
||||
column: {
|
||||
id: 338,
|
||||
column_name: 'sum_boys',
|
||||
expression: '',
|
||||
filterable: false,
|
||||
groupby: false,
|
||||
is_dttm: false,
|
||||
type: 'BIGINT',
|
||||
optionName: '_col_sum_boys',
|
||||
},
|
||||
aggregate: 'SUM',
|
||||
hasCustomLabel: false,
|
||||
label: 'SUM(sum_boys)',
|
||||
optionName: 'metric_gvpdjt0v2qf_6hkf56o012',
|
||||
};
|
||||
|
||||
function verify(formData) {
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'table' });
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
cy.server();
|
||||
cy.login();
|
||||
cy.route('POST', '/superset/explore_json/**').as('getJson');
|
||||
});
|
||||
|
||||
it('should work with single groupby', () => {
|
||||
verify(PIVOT_TABLE_FORM_DATA);
|
||||
cy.get('.chart-container tr:eq(0) th:eq(1)').contains('sum__num');
|
||||
cy.get('.chart-container tr:eq(1) th:eq(0)').contains('state');
|
||||
cy.get('.chart-container tr:eq(2) th:eq(0)').contains('name');
|
||||
});
|
||||
|
||||
it('should work with more than one groupby', () => {
|
||||
verify({
|
||||
...PIVOT_TABLE_FORM_DATA,
|
||||
groupby: ['name', 'gender'],
|
||||
});
|
||||
cy.get('.chart-container tr:eq(0) th:eq(2)').contains('sum__num');
|
||||
cy.get('.chart-container tr:eq(1) th:eq(1)').contains('state');
|
||||
cy.get('.chart-container tr:eq(2) th:eq(0)').contains('name');
|
||||
cy.get('.chart-container tr:eq(2) th:eq(1)').contains('gender');
|
||||
});
|
||||
|
||||
it('should work with multiple metrics', () => {
|
||||
verify({
|
||||
...PIVOT_TABLE_FORM_DATA,
|
||||
metrics: ['sum__num', TEST_METRIC],
|
||||
});
|
||||
cy.get('.chart-container tr:eq(0) th:eq(1)').contains('sum__num');
|
||||
cy.get('.chart-container tr:eq(0) th:eq(2)').contains('SUM(sum_boys)');
|
||||
cy.get('.chart-container tr:eq(1) th:eq(0)').contains('state');
|
||||
cy.get('.chart-container tr:eq(2) th:eq(0)').contains('name');
|
||||
});
|
||||
|
||||
it('should work with multiple groupby and multiple metrics', () => {
|
||||
verify({
|
||||
...PIVOT_TABLE_FORM_DATA,
|
||||
groupby: ['name', 'gender'],
|
||||
metrics: ['sum__num', TEST_METRIC],
|
||||
});
|
||||
cy.get('.chart-container tr:eq(0) th:eq(2)').contains('sum__num');
|
||||
cy.get('.chart-container tr:eq(0) th:eq(3)').contains('SUM(sum_boys)');
|
||||
cy.get('.chart-container tr:eq(2) th:eq(0)').contains('name');
|
||||
cy.get('.chart-container tr:eq(2) th:eq(1)').contains('gender');
|
||||
});
|
||||
});
|
||||
@@ -1,78 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
export default () =>
|
||||
describe('Sankey', () => {
|
||||
const SANKEY_FORM_DATA = {
|
||||
datasource: '1__table',
|
||||
viz_type: 'sankey',
|
||||
slice_id: 1,
|
||||
url_params: {},
|
||||
granularity_sqla: null,
|
||||
time_grain_sqla: 'P1D',
|
||||
time_range: 'Last+week',
|
||||
groupby: ['source', 'target'],
|
||||
metric: 'sum__value',
|
||||
adhoc_filters: [],
|
||||
row_limit: '5000',
|
||||
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', () => {
|
||||
verify(SANKEY_FORM_DATA);
|
||||
cy.get('.chart-container svg g.node rect').should('have.length', 41);
|
||||
});
|
||||
|
||||
it('should work with filter', () => {
|
||||
verify({
|
||||
...SANKEY_FORM_DATA,
|
||||
adhoc_filters: [
|
||||
{
|
||||
expressionType: 'SQL',
|
||||
sqlExpression: 'SUM(value)+>+0',
|
||||
clause: 'HAVING',
|
||||
subject: null,
|
||||
operator: null,
|
||||
comparator: null,
|
||||
filterOptionName: 'filter_jbdwe0hayaj_h9jfer8fy58',
|
||||
},
|
||||
{
|
||||
expressionType: 'SIMPLE',
|
||||
subject: 'source',
|
||||
operator: '==',
|
||||
comparator: 'Energy',
|
||||
clause: 'WHERE',
|
||||
sqlExpression: null,
|
||||
filterOptionName: 'filter_8e0otka9uif_vmqri4gmbqc',
|
||||
},
|
||||
],
|
||||
});
|
||||
cy.get('.chart-container svg g.node rect').should('have.length', 6);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,77 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
describe('Visualization > Sankey', () => {
|
||||
const SANKEY_FORM_DATA = {
|
||||
datasource: '1__table',
|
||||
viz_type: 'sankey',
|
||||
slice_id: 1,
|
||||
url_params: {},
|
||||
granularity_sqla: null,
|
||||
time_grain_sqla: 'P1D',
|
||||
time_range: 'Last+week',
|
||||
groupby: ['source', 'target'],
|
||||
metric: 'sum__value',
|
||||
adhoc_filters: [],
|
||||
row_limit: '5000',
|
||||
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', () => {
|
||||
verify(SANKEY_FORM_DATA);
|
||||
cy.get('.chart-container svg g.node rect').should('have.length', 41);
|
||||
});
|
||||
|
||||
it('should work with filter', () => {
|
||||
verify({
|
||||
...SANKEY_FORM_DATA,
|
||||
adhoc_filters: [
|
||||
{
|
||||
expressionType: 'SQL',
|
||||
sqlExpression: 'SUM(value)+>+0',
|
||||
clause: 'HAVING',
|
||||
subject: null,
|
||||
operator: null,
|
||||
comparator: null,
|
||||
filterOptionName: 'filter_jbdwe0hayaj_h9jfer8fy58',
|
||||
},
|
||||
{
|
||||
expressionType: 'SIMPLE',
|
||||
subject: 'source',
|
||||
operator: '==',
|
||||
comparator: 'Energy',
|
||||
clause: 'WHERE',
|
||||
sqlExpression: null,
|
||||
filterOptionName: 'filter_8e0otka9uif_vmqri4gmbqc',
|
||||
},
|
||||
],
|
||||
});
|
||||
cy.get('.chart-container svg g.node rect').should('have.length', 6);
|
||||
});
|
||||
});
|
||||
@@ -1,85 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
export default () =>
|
||||
describe('Sunburst', () => {
|
||||
const SUNBURST_FORM_DATA = {
|
||||
datasource: '2__table',
|
||||
viz_type: 'sunburst',
|
||||
slice_id: 47,
|
||||
granularity_sqla: 'year',
|
||||
time_grain_sqla: 'P1D',
|
||||
time_range: '2011-01-01+:+2011-01-01',
|
||||
groupby: ['region'],
|
||||
metric: 'sum__SP_POP_TOTL',
|
||||
adhoc_filters: [],
|
||||
row_limit: 50000,
|
||||
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 without secondary metric', () => {
|
||||
verify(SUNBURST_FORM_DATA);
|
||||
// There should be 7 visible arcs + 1 hidden
|
||||
cy.get('.chart-container svg g#arcs path').should('have.length', 8);
|
||||
});
|
||||
|
||||
it('should work with secondary metric', () => {
|
||||
verify({
|
||||
...SUNBURST_FORM_DATA,
|
||||
secondary_metric: 'sum__SP_RUR_TOTL',
|
||||
});
|
||||
cy.get('.chart-container svg g#arcs path').should('have.length', 8);
|
||||
});
|
||||
|
||||
it('should work with multiple groupbys', () => {
|
||||
verify({
|
||||
...SUNBURST_FORM_DATA,
|
||||
groupby: ['region', 'country_name'],
|
||||
});
|
||||
cy.get('.chart-container svg g#arcs path').should('have.length', 118);
|
||||
});
|
||||
|
||||
it('should work with filter', () => {
|
||||
verify({
|
||||
...SUNBURST_FORM_DATA,
|
||||
adhoc_filters: [
|
||||
{
|
||||
expressionType: 'SIMPLE',
|
||||
subject: 'region',
|
||||
operator: 'in',
|
||||
comparator: ['South Asia', 'North America'],
|
||||
clause: 'WHERE',
|
||||
sqlExpression: null,
|
||||
filterOptionName: 'filter_txje2ikiv6_wxmn0qwd1xo',
|
||||
},
|
||||
],
|
||||
});
|
||||
cy.get('.chart-container svg g#arcs path').should('have.length', 3);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,84 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
describe('Visualization > Sunburst', () => {
|
||||
const SUNBURST_FORM_DATA = {
|
||||
datasource: '2__table',
|
||||
viz_type: 'sunburst',
|
||||
slice_id: 47,
|
||||
granularity_sqla: 'year',
|
||||
time_grain_sqla: 'P1D',
|
||||
time_range: 'No filter',
|
||||
groupby: ['region'],
|
||||
metric: 'sum__SP_POP_TOTL',
|
||||
adhoc_filters: [],
|
||||
row_limit: 50000,
|
||||
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 without secondary metric', () => {
|
||||
verify(SUNBURST_FORM_DATA);
|
||||
// There should be 7 visible arcs + 1 hidden
|
||||
cy.get('.chart-container svg g#arcs path').should('have.length', 8);
|
||||
});
|
||||
|
||||
it('should work with secondary metric', () => {
|
||||
verify({
|
||||
...SUNBURST_FORM_DATA,
|
||||
secondary_metric: 'sum__SP_RUR_TOTL',
|
||||
});
|
||||
cy.get('.chart-container svg g#arcs path').should('have.length', 8);
|
||||
});
|
||||
|
||||
it('should work with multiple groupbys', () => {
|
||||
verify({
|
||||
...SUNBURST_FORM_DATA,
|
||||
groupby: ['region', 'country_name'],
|
||||
});
|
||||
cy.get('.chart-container svg g#arcs path').should('have.length', 117);
|
||||
});
|
||||
|
||||
it('should work with filter', () => {
|
||||
verify({
|
||||
...SUNBURST_FORM_DATA,
|
||||
adhoc_filters: [
|
||||
{
|
||||
expressionType: 'SIMPLE',
|
||||
subject: 'region',
|
||||
operator: 'in',
|
||||
comparator: ['South Asia', 'North America'],
|
||||
clause: 'WHERE',
|
||||
sqlExpression: null,
|
||||
filterOptionName: 'filter_txje2ikiv6_wxmn0qwd1xo',
|
||||
},
|
||||
],
|
||||
});
|
||||
cy.get('.chart-container svg g#arcs path').should('have.length', 3);
|
||||
});
|
||||
});
|
||||
@@ -1,172 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { FORM_DATA_DEFAULTS, NUM_METRIC, SIMPLE_FILTER } from './shared.helper';
|
||||
import readResponseBlob from '../../../utils/readResponseBlob';
|
||||
|
||||
// Table
|
||||
|
||||
export default () =>
|
||||
describe('Table chart', () => {
|
||||
const VIZ_DEFAULTS = { ...FORM_DATA_DEFAULTS, viz_type: 'table' };
|
||||
|
||||
beforeEach(() => {
|
||||
cy.login();
|
||||
cy.server();
|
||||
cy.route('POST', '/superset/explore_json/**').as('getJson');
|
||||
});
|
||||
|
||||
it('Test table with adhoc metric', () => {
|
||||
const formData = { ...VIZ_DEFAULTS, metrics: NUM_METRIC };
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({
|
||||
waitAlias: '@getJson',
|
||||
querySubstring: NUM_METRIC.label,
|
||||
chartSelector: 'table',
|
||||
});
|
||||
});
|
||||
|
||||
it('Test table with groupby', () => {
|
||||
const formData = {
|
||||
...VIZ_DEFAULTS,
|
||||
metrics: NUM_METRIC,
|
||||
groupby: ['name'],
|
||||
};
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({
|
||||
waitAlias: '@getJson',
|
||||
querySubstring: formData.groupby[0],
|
||||
chartSelector: 'table',
|
||||
});
|
||||
});
|
||||
|
||||
it('Test table with percent metrics and groupby', () => {
|
||||
const formData = {
|
||||
...VIZ_DEFAULTS,
|
||||
percent_metrics: NUM_METRIC,
|
||||
metrics: [],
|
||||
groupby: ['name'],
|
||||
};
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'table' });
|
||||
});
|
||||
|
||||
it('Test table with groupby order desc', () => {
|
||||
const formData = {
|
||||
...VIZ_DEFAULTS,
|
||||
metrics: NUM_METRIC,
|
||||
groupby: ['name'],
|
||||
order_desc: true,
|
||||
};
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'table' });
|
||||
});
|
||||
|
||||
it('Test table with groupby and limit', () => {
|
||||
const limit = 10;
|
||||
|
||||
const formData = {
|
||||
...VIZ_DEFAULTS,
|
||||
metrics: NUM_METRIC,
|
||||
groupby: ['name'],
|
||||
row_limit: limit,
|
||||
};
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
|
||||
cy.wait('@getJson').then(async xhr => {
|
||||
cy.verifyResponseCodes(xhr);
|
||||
cy.verifySliceContainer('table');
|
||||
const responseBody = await readResponseBlob(xhr.response.body);
|
||||
expect(responseBody.data.records.length).to.eq(limit);
|
||||
});
|
||||
cy.get('span.label-danger').contains('10 rows');
|
||||
});
|
||||
|
||||
it('Test table with columns and row limit', () => {
|
||||
const formData = {
|
||||
...VIZ_DEFAULTS,
|
||||
all_columns: ['name'],
|
||||
metrics: [],
|
||||
row_limit: 10,
|
||||
};
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'table' });
|
||||
});
|
||||
|
||||
it('Test table with columns, ordering, and row limit', () => {
|
||||
const limit = 10;
|
||||
|
||||
const formData = {
|
||||
...VIZ_DEFAULTS,
|
||||
all_columns: ['name', 'state', 'ds', 'num'],
|
||||
metrics: [],
|
||||
row_limit: limit,
|
||||
order_by_cols: ['["num",+false]'],
|
||||
};
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.wait('@getJson').then(async xhr => {
|
||||
cy.verifyResponseCodes(xhr);
|
||||
cy.verifySliceContainer('table');
|
||||
const responseBody = await readResponseBlob(xhr.response.body);
|
||||
const { records } = responseBody.data;
|
||||
expect(records[0].num).greaterThan(records[records.length - 1].num);
|
||||
});
|
||||
});
|
||||
|
||||
it('Test table with simple filter', () => {
|
||||
const metrics = ['count'];
|
||||
const filters = [SIMPLE_FILTER];
|
||||
|
||||
const formData = { ...VIZ_DEFAULTS, metrics, adhoc_filters: filters };
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'table' });
|
||||
});
|
||||
|
||||
it('Tests table number formatting with % in metric name', () => {
|
||||
const PERCENT_METRIC = {
|
||||
expressionType: 'SQL',
|
||||
sqlExpression: 'CAST(SUM(sum_girls)+AS+FLOAT)/SUM(num)',
|
||||
column: null,
|
||||
aggregate: null,
|
||||
hasCustomLabel: true,
|
||||
label: '%+Girls',
|
||||
optionName: 'metric_6qwzgc8bh2v_zox7hil1mzs',
|
||||
};
|
||||
const formData = {
|
||||
...VIZ_DEFAULTS,
|
||||
metrics: PERCENT_METRIC,
|
||||
groupby: ['state'],
|
||||
};
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({
|
||||
waitAlias: '@getJson',
|
||||
querySubstring: formData.groupby[0],
|
||||
chartSelector: 'table',
|
||||
});
|
||||
cy.get('td').contains(/\d*%/);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,170 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { FORM_DATA_DEFAULTS, NUM_METRIC, SIMPLE_FILTER } from './shared.helper';
|
||||
import readResponseBlob from '../../../utils/readResponseBlob';
|
||||
|
||||
// Table
|
||||
describe('Visualization > Table', () => {
|
||||
const VIZ_DEFAULTS = { ...FORM_DATA_DEFAULTS, viz_type: 'table' };
|
||||
|
||||
beforeEach(() => {
|
||||
cy.login();
|
||||
cy.server();
|
||||
cy.route('POST', '/superset/explore_json/**').as('getJson');
|
||||
});
|
||||
|
||||
it('Test table with adhoc metric', () => {
|
||||
const formData = { ...VIZ_DEFAULTS, metrics: NUM_METRIC };
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({
|
||||
waitAlias: '@getJson',
|
||||
querySubstring: NUM_METRIC.label,
|
||||
chartSelector: 'table',
|
||||
});
|
||||
});
|
||||
|
||||
it('Test table with groupby', () => {
|
||||
const formData = {
|
||||
...VIZ_DEFAULTS,
|
||||
metrics: NUM_METRIC,
|
||||
groupby: ['name'],
|
||||
};
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({
|
||||
waitAlias: '@getJson',
|
||||
querySubstring: formData.groupby[0],
|
||||
chartSelector: 'table',
|
||||
});
|
||||
});
|
||||
|
||||
it('Test table with percent metrics and groupby', () => {
|
||||
const formData = {
|
||||
...VIZ_DEFAULTS,
|
||||
percent_metrics: NUM_METRIC,
|
||||
metrics: [],
|
||||
groupby: ['name'],
|
||||
};
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'table' });
|
||||
});
|
||||
|
||||
it('Test table with groupby order desc', () => {
|
||||
const formData = {
|
||||
...VIZ_DEFAULTS,
|
||||
metrics: NUM_METRIC,
|
||||
groupby: ['name'],
|
||||
order_desc: true,
|
||||
};
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'table' });
|
||||
});
|
||||
|
||||
it('Test table with groupby and limit', () => {
|
||||
const limit = 10;
|
||||
|
||||
const formData = {
|
||||
...VIZ_DEFAULTS,
|
||||
metrics: NUM_METRIC,
|
||||
groupby: ['name'],
|
||||
row_limit: limit,
|
||||
};
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
|
||||
cy.wait('@getJson').then(async xhr => {
|
||||
cy.verifyResponseCodes(xhr);
|
||||
cy.verifySliceContainer('table');
|
||||
const responseBody = await readResponseBlob(xhr.response.body);
|
||||
expect(responseBody.data.records.length).to.eq(limit);
|
||||
});
|
||||
cy.get('span.label-danger').contains('10 rows');
|
||||
});
|
||||
|
||||
it('Test table with columns and row limit', () => {
|
||||
const formData = {
|
||||
...VIZ_DEFAULTS,
|
||||
all_columns: ['name'],
|
||||
metrics: [],
|
||||
row_limit: 10,
|
||||
};
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'table' });
|
||||
});
|
||||
|
||||
it('Test table with columns, ordering, and row limit', () => {
|
||||
const limit = 10;
|
||||
|
||||
const formData = {
|
||||
...VIZ_DEFAULTS,
|
||||
all_columns: ['name', 'state', 'ds', 'num'],
|
||||
metrics: [],
|
||||
row_limit: limit,
|
||||
order_by_cols: ['["num",+false]'],
|
||||
};
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.wait('@getJson').then(async xhr => {
|
||||
cy.verifyResponseCodes(xhr);
|
||||
cy.verifySliceContainer('table');
|
||||
const responseBody = await readResponseBlob(xhr.response.body);
|
||||
const { records } = responseBody.data;
|
||||
expect(records[0].num).greaterThan(records[records.length - 1].num);
|
||||
});
|
||||
});
|
||||
|
||||
it('Test table with simple filter', () => {
|
||||
const metrics = ['count'];
|
||||
const filters = [SIMPLE_FILTER];
|
||||
|
||||
const formData = { ...VIZ_DEFAULTS, metrics, adhoc_filters: filters };
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'table' });
|
||||
});
|
||||
|
||||
it('Tests table number formatting with % in metric name', () => {
|
||||
const PERCENT_METRIC = {
|
||||
expressionType: 'SQL',
|
||||
sqlExpression: 'CAST(SUM(sum_girls)+AS+FLOAT)/SUM(num)',
|
||||
column: null,
|
||||
aggregate: null,
|
||||
hasCustomLabel: true,
|
||||
label: 'Girls',
|
||||
optionName: 'metric_6qwzgc8bh2v_zox7hil1mzs',
|
||||
};
|
||||
const formData = {
|
||||
...VIZ_DEFAULTS,
|
||||
percent_metrics: PERCENT_METRIC,
|
||||
groupby: ['state'],
|
||||
};
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({
|
||||
waitAlias: '@getJson',
|
||||
querySubstring: formData.groupby[0],
|
||||
chartSelector: 'table',
|
||||
});
|
||||
cy.get('td').contains(/\d*%/);
|
||||
});
|
||||
});
|
||||
@@ -18,118 +18,115 @@
|
||||
*/
|
||||
import { FORM_DATA_DEFAULTS, NUM_METRIC } from './shared.helper';
|
||||
|
||||
// time table viz
|
||||
describe('Visualization > Time TableViz', () => {
|
||||
const VIZ_DEFAULTS = { ...FORM_DATA_DEFAULTS, viz_type: 'time_table' };
|
||||
|
||||
export default () =>
|
||||
describe('Time Table Viz', () => {
|
||||
const VIZ_DEFAULTS = { ...FORM_DATA_DEFAULTS, viz_type: 'time_table' };
|
||||
beforeEach(() => {
|
||||
cy.login();
|
||||
cy.server();
|
||||
cy.route('POST', '/superset/explore_json/**').as('getJson');
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
cy.login();
|
||||
cy.server();
|
||||
cy.route('POST', '/superset/explore_json/**').as('getJson');
|
||||
it('Test time series table multiple metrics last year total', () => {
|
||||
const formData = {
|
||||
...VIZ_DEFAULTS,
|
||||
metrics: [NUM_METRIC, 'count'],
|
||||
column_collection: [
|
||||
{
|
||||
key: '9g4K-B-YL',
|
||||
label: 'Last+Year',
|
||||
colType: 'time',
|
||||
timeLag: '1',
|
||||
comparisonType: 'value',
|
||||
},
|
||||
],
|
||||
url: '',
|
||||
};
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({
|
||||
waitAlias: '@getJson',
|
||||
querySubstring: NUM_METRIC.label,
|
||||
});
|
||||
|
||||
it('Test time series table multiple metrics last year total', () => {
|
||||
const formData = {
|
||||
...VIZ_DEFAULTS,
|
||||
metrics: [NUM_METRIC, 'count'],
|
||||
column_collection: [
|
||||
{
|
||||
key: '9g4K-B-YL',
|
||||
label: 'Last+Year',
|
||||
colType: 'time',
|
||||
timeLag: '1',
|
||||
comparisonType: 'value',
|
||||
},
|
||||
],
|
||||
url: '',
|
||||
};
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({
|
||||
waitAlias: '@getJson',
|
||||
querySubstring: NUM_METRIC.label,
|
||||
});
|
||||
cy.get('.time-table').within(() => {
|
||||
cy.get('span').contains('Sum(num)');
|
||||
cy.get('span').contains('COUNT(*)');
|
||||
});
|
||||
});
|
||||
|
||||
it('Test time series table metric and group by last year total', () => {
|
||||
const formData = {
|
||||
...VIZ_DEFAULTS,
|
||||
metrics: [NUM_METRIC],
|
||||
groupby: ['gender'],
|
||||
column_collection: [
|
||||
{
|
||||
key: '9g4K-B-YL',
|
||||
label: 'Last+Year',
|
||||
colType: 'time',
|
||||
timeLag: '1',
|
||||
comparisonType: 'value',
|
||||
},
|
||||
],
|
||||
url: '',
|
||||
};
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({
|
||||
waitAlias: '@getJson',
|
||||
querySubstring: NUM_METRIC.label,
|
||||
});
|
||||
cy.get('.time-table').within(() => {
|
||||
cy.get('td').contains('boy');
|
||||
cy.get('td').contains('girl');
|
||||
});
|
||||
});
|
||||
|
||||
it('Test time series various time columns', () => {
|
||||
const formData = {
|
||||
...VIZ_DEFAULTS,
|
||||
metrics: [NUM_METRIC, 'count'],
|
||||
column_collection: [
|
||||
{ key: 'LHHNPhamU', label: 'Current', colType: 'time', timeLag: 0 },
|
||||
{
|
||||
key: '9g4K-B-YL',
|
||||
label: 'Last Year',
|
||||
colType: 'time',
|
||||
timeLag: '1',
|
||||
comparisonType: 'value',
|
||||
},
|
||||
{
|
||||
key: 'JVZXtNu7_',
|
||||
label: 'YoY',
|
||||
colType: 'time',
|
||||
timeLag: 1,
|
||||
comparisonType: 'perc',
|
||||
d3format: '%',
|
||||
},
|
||||
{ key: 'tN5Gba36u', label: 'Trend', colType: 'spark' },
|
||||
],
|
||||
url: '',
|
||||
};
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({
|
||||
waitAlias: '@getJson',
|
||||
querySubstring: NUM_METRIC.label,
|
||||
});
|
||||
cy.get('.time-table').within(() => {
|
||||
cy.get('th').contains('Current');
|
||||
cy.get('th').contains('Last Year');
|
||||
cy.get('th').contains('YoY');
|
||||
cy.get('th').contains('Trend');
|
||||
|
||||
cy.get('span').contains('%');
|
||||
cy.get('svg')
|
||||
.first()
|
||||
.then(charts => {
|
||||
const firstChart = charts[0];
|
||||
expect(firstChart.clientWidth).greaterThan(0);
|
||||
expect(firstChart.clientHeight).greaterThan(0);
|
||||
});
|
||||
});
|
||||
cy.get('.time-table').within(() => {
|
||||
cy.get('span').contains('Sum(num)');
|
||||
cy.get('span').contains('COUNT(*)');
|
||||
});
|
||||
});
|
||||
|
||||
it('Test time series table metric and group by last year total', () => {
|
||||
const formData = {
|
||||
...VIZ_DEFAULTS,
|
||||
metrics: [NUM_METRIC],
|
||||
groupby: ['gender'],
|
||||
column_collection: [
|
||||
{
|
||||
key: '9g4K-B-YL',
|
||||
label: 'Last+Year',
|
||||
colType: 'time',
|
||||
timeLag: '1',
|
||||
comparisonType: 'value',
|
||||
},
|
||||
],
|
||||
url: '',
|
||||
};
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({
|
||||
waitAlias: '@getJson',
|
||||
querySubstring: NUM_METRIC.label,
|
||||
});
|
||||
cy.get('.time-table').within(() => {
|
||||
cy.get('td').contains('boy');
|
||||
cy.get('td').contains('girl');
|
||||
});
|
||||
});
|
||||
|
||||
it('Test time series various time columns', () => {
|
||||
const formData = {
|
||||
...VIZ_DEFAULTS,
|
||||
metrics: [NUM_METRIC, 'count'],
|
||||
column_collection: [
|
||||
{ key: 'LHHNPhamU', label: 'Current', colType: 'time', timeLag: 0 },
|
||||
{
|
||||
key: '9g4K-B-YL',
|
||||
label: 'Last Year',
|
||||
colType: 'time',
|
||||
timeLag: '1',
|
||||
comparisonType: 'value',
|
||||
},
|
||||
{
|
||||
key: 'JVZXtNu7_',
|
||||
label: 'YoY',
|
||||
colType: 'time',
|
||||
timeLag: 1,
|
||||
comparisonType: 'perc',
|
||||
d3format: '%',
|
||||
},
|
||||
{ key: 'tN5Gba36u', label: 'Trend', colType: 'spark' },
|
||||
],
|
||||
url: '',
|
||||
};
|
||||
|
||||
cy.visitChartByParams(JSON.stringify(formData));
|
||||
cy.verifySliceSuccess({
|
||||
waitAlias: '@getJson',
|
||||
querySubstring: NUM_METRIC.label,
|
||||
});
|
||||
cy.get('.time-table').within(() => {
|
||||
cy.get('th').contains('Current');
|
||||
cy.get('th').contains('Last Year');
|
||||
cy.get('th').contains('YoY');
|
||||
cy.get('th').contains('Trend');
|
||||
|
||||
cy.get('span').contains('%');
|
||||
cy.get('svg')
|
||||
.first()
|
||||
.then(charts => {
|
||||
const firstChart = charts[0];
|
||||
expect(firstChart.clientWidth).greaterThan(0);
|
||||
expect(firstChart.clientHeight).greaterThan(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
export default () =>
|
||||
describe('Treemap', () => {
|
||||
const TREEMAP_FORM_DATA = {
|
||||
datasource: '2__table',
|
||||
viz_type: 'treemap',
|
||||
slice_id: 50,
|
||||
granularity_sqla: 'year',
|
||||
time_grain_sqla: 'P1D',
|
||||
time_range: '1960-01-01+:+now',
|
||||
metrics: ['sum__SP_POP_TOTL'],
|
||||
adhoc_filters: [],
|
||||
groupby: ['country_code'],
|
||||
row_limit: 50000,
|
||||
color_scheme: 'bnbColors',
|
||||
treemap_ratio: 1.618033988749895,
|
||||
number_format: '.3s',
|
||||
};
|
||||
|
||||
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(TREEMAP_FORM_DATA);
|
||||
cy.get('.chart-container svg rect.child').should('have.length', 214);
|
||||
});
|
||||
|
||||
it('should work with multiple groupby', () => {
|
||||
verify({
|
||||
...TREEMAP_FORM_DATA,
|
||||
groupby: ['region', 'country_code'],
|
||||
});
|
||||
cy.get('.chart-container svg rect.parent').should('have.length', 7);
|
||||
cy.get('.chart-container svg rect.child').should('have.length', 214);
|
||||
});
|
||||
|
||||
it('should work with filter', () => {
|
||||
verify({
|
||||
...TREEMAP_FORM_DATA,
|
||||
adhoc_filters: [
|
||||
{
|
||||
expressionType: 'SIMPLE',
|
||||
subject: 'region',
|
||||
operator: '==',
|
||||
comparator: 'South Asia',
|
||||
clause: 'WHERE',
|
||||
sqlExpression: null,
|
||||
filterOptionName: 'filter_8aqxcf5co1a_x7lm2d1fq0l',
|
||||
},
|
||||
],
|
||||
});
|
||||
cy.get('.chart-container svg rect.child').should('have.length', 8);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,84 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
describe('Visualization > Treemap', () => {
|
||||
const TREEMAP_FORM_DATA = {
|
||||
datasource: '2__table',
|
||||
viz_type: 'treemap',
|
||||
slice_id: 50,
|
||||
granularity_sqla: 'year',
|
||||
time_grain_sqla: 'P1D',
|
||||
time_range: 'No filter',
|
||||
metrics: ['sum__SP_POP_TOTL'],
|
||||
adhoc_filters: [],
|
||||
groupby: ['country_code'],
|
||||
row_limit: 50000,
|
||||
color_scheme: 'bnbColors',
|
||||
treemap_ratio: 1.618033988749895,
|
||||
number_format: '.3s',
|
||||
};
|
||||
|
||||
const level0 = '.chart-container rect[style="fill: rgb(255, 90, 95);"]';
|
||||
const level1 = '.chart-container rect[style="fill: rgb(123, 0, 81);"]';
|
||||
const level2 = '.chart-container rect[style="fill: rgb(0, 122, 135);"]';
|
||||
|
||||
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(TREEMAP_FORM_DATA);
|
||||
cy.get(level0).should('have.length', 1);
|
||||
cy.get(level1).should('have.length', 214);
|
||||
});
|
||||
|
||||
it('should work with multiple groupby', () => {
|
||||
verify({
|
||||
...TREEMAP_FORM_DATA,
|
||||
groupby: ['region', 'country_code'],
|
||||
});
|
||||
cy.get(level0).should('have.length', 1);
|
||||
cy.get(level1).should('have.length', 7);
|
||||
cy.get(level2).should('have.length', 214);
|
||||
});
|
||||
|
||||
it('should work with filter', () => {
|
||||
verify({
|
||||
...TREEMAP_FORM_DATA,
|
||||
adhoc_filters: [
|
||||
{
|
||||
expressionType: 'SIMPLE',
|
||||
subject: 'region',
|
||||
operator: '==',
|
||||
comparator: 'South Asia',
|
||||
clause: 'WHERE',
|
||||
sqlExpression: null,
|
||||
filterOptionName: 'filter_8aqxcf5co1a_x7lm2d1fq0l',
|
||||
},
|
||||
],
|
||||
});
|
||||
cy.get(level1).should('have.length', 8);
|
||||
});
|
||||
});
|
||||
@@ -1,85 +0,0 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
export default () =>
|
||||
describe('World Map', () => {
|
||||
const WORLD_MAP_FORM_DATA = {
|
||||
datasource: '2__table',
|
||||
viz_type: 'world_map',
|
||||
slice_id: 45,
|
||||
granularity_sqla: 'year',
|
||||
time_grain_sqla: 'P1D',
|
||||
time_range: '2014-01-01 : 2014-01-02',
|
||||
entity: 'country_code',
|
||||
country_fieldtype: 'cca3',
|
||||
metric: 'sum__SP_RUR_TOTL_ZS',
|
||||
adhoc_filters: [],
|
||||
row_limit: 50000,
|
||||
show_bubbles: true,
|
||||
secondary_metric: 'sum__SP_POP_TOTL',
|
||||
max_bubble_size: '25',
|
||||
};
|
||||
|
||||
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(WORLD_MAP_FORM_DATA);
|
||||
cy.get('.bubbles circle.datamaps-bubble').should('have.length', 206);
|
||||
});
|
||||
|
||||
it('should work with simple filter', () => {
|
||||
verify({
|
||||
...WORLD_MAP_FORM_DATA,
|
||||
metric: 'count',
|
||||
adhoc_filters: [
|
||||
{
|
||||
expressionType: 'SIMPLE',
|
||||
subject: 'region',
|
||||
operator: '==',
|
||||
comparator: 'South Asia',
|
||||
clause: 'WHERE',
|
||||
sqlExpression: null,
|
||||
filterOptionName: 'filter_8aqxcf5co1a_x7lm2d1fq0l',
|
||||
},
|
||||
],
|
||||
});
|
||||
cy.get('.bubbles circle.datamaps-bubble').should('have.length', 8);
|
||||
});
|
||||
|
||||
it('should hide bubbles when told so', () => {
|
||||
verify({
|
||||
...WORLD_MAP_FORM_DATA,
|
||||
show_bubbles: false,
|
||||
});
|
||||
cy.get('.slice_container').then(containers => {
|
||||
expect(
|
||||
containers[0].querySelectorAll('.bubbles circle.datamaps-bubble')
|
||||
.length,
|
||||
).to.equal(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,84 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
describe('Visualization > World Map', () => {
|
||||
const WORLD_MAP_FORM_DATA = {
|
||||
datasource: '2__table',
|
||||
viz_type: 'world_map',
|
||||
slice_id: 45,
|
||||
granularity_sqla: 'year',
|
||||
time_grain_sqla: 'P1D',
|
||||
time_range: '2014-01-01 : 2014-01-02',
|
||||
entity: 'country_code',
|
||||
country_fieldtype: 'cca3',
|
||||
metric: 'sum__SP_RUR_TOTL_ZS',
|
||||
adhoc_filters: [],
|
||||
row_limit: 50000,
|
||||
show_bubbles: true,
|
||||
secondary_metric: 'sum__SP_POP_TOTL',
|
||||
max_bubble_size: '25',
|
||||
};
|
||||
|
||||
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(WORLD_MAP_FORM_DATA);
|
||||
cy.get('.bubbles circle.datamaps-bubble').should('have.length', 206);
|
||||
});
|
||||
|
||||
it('should work with simple filter', () => {
|
||||
verify({
|
||||
...WORLD_MAP_FORM_DATA,
|
||||
metric: 'count',
|
||||
adhoc_filters: [
|
||||
{
|
||||
expressionType: 'SIMPLE',
|
||||
subject: 'region',
|
||||
operator: '==',
|
||||
comparator: 'South Asia',
|
||||
clause: 'WHERE',
|
||||
sqlExpression: null,
|
||||
filterOptionName: 'filter_8aqxcf5co1a_x7lm2d1fq0l',
|
||||
},
|
||||
],
|
||||
});
|
||||
cy.get('.bubbles circle.datamaps-bubble').should('have.length', 8);
|
||||
});
|
||||
|
||||
it('should hide bubbles when told so', () => {
|
||||
verify({
|
||||
...WORLD_MAP_FORM_DATA,
|
||||
show_bubbles: false,
|
||||
});
|
||||
cy.get('.slice_container').then(containers => {
|
||||
expect(
|
||||
containers[0].querySelectorAll('.bubbles circle.datamaps-bubble')
|
||||
.length,
|
||||
).to.equal(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user