Skip to content

Commit 7b66e0b

Browse files
authored
chore: E2E tests for Drill to Detail supported Charts (apache#21681)
1 parent b6891aa commit 7b66e0b

24 files changed

+484
-201
lines changed

superset-frontend/cypress-base/cypress/integration/dashboard/drilltodetail.test.ts

+350-60
Large diffs are not rendered by default.

superset-frontend/cypress-base/cypress/integration/dashboard/nativeFilters.test.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ function visitDashboard() {
6464
cy.wait('@get');
6565
cy.wait('@getCharts');
6666
cy.wait('@getDatasets');
67-
cy.wait(500);
67+
cy.url().should('contain', 'native_filters_key');
6868
}
6969

7070
function prepareDashboardFilters(
@@ -454,6 +454,7 @@ describe('Native filters', () => {
454454
let filterKey: string;
455455
const removeFirstChar = (search: string) =>
456456
search.split('').slice(1, search.length).join('');
457+
457458
cy.location().then(loc => {
458459
const queryParams = qs.parse(removeFirstChar(loc.search));
459460
filterKey = queryParams.native_filters_key as string;

superset-frontend/cypress-base/cypress/integration/explore/visualizations/area.test.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
* under the License.
1818
*/
1919
describe('Visualization > Area', () => {
20+
beforeEach(() => {
21+
cy.preserveLogin();
22+
cy.intercept('POST', '/superset/explore_json/**').as('getJson');
23+
});
24+
2025
const AREA_FORM_DATA = {
2126
datasource: '2__table',
2227
viz_type: 'area',
@@ -55,11 +60,6 @@ describe('Visualization > Area', () => {
5560
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' });
5661
}
5762

58-
beforeEach(() => {
59-
cy.login();
60-
cy.intercept('POST', '/superset/explore_json/**').as('getJson');
61-
});
62-
6363
it('should work without groupby', () => {
6464
verify(AREA_FORM_DATA);
6565
cy.get('.nv-area').should('have.length', 1);
@@ -105,6 +105,8 @@ describe('Visualization > Area', () => {
105105
});
106106

107107
it('should allow type to search color schemes and apply the scheme', () => {
108+
verify(AREA_FORM_DATA);
109+
108110
cy.get('#controlSections-tab-display').click();
109111
cy.get('.Control[data-test="color_scheme"]').scrollIntoView();
110112
cy.get('.Control[data-test="color_scheme"] input[type="search"]')

superset-frontend/cypress-base/cypress/integration/explore/visualizations/big_number.test.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
import { interceptChart } from 'cypress/utils';
2020

2121
describe('Visualization > Big Number with Trendline', () => {
22+
beforeEach(() => {
23+
cy.preserveLogin();
24+
interceptChart({ legacy: false }).as('chartData');
25+
});
26+
2227
const BIG_NUMBER_FORM_DATA = {
2328
datasource: '2__table',
2429
viz_type: 'big_number',
@@ -49,11 +54,6 @@ describe('Visualization > Big Number with Trendline', () => {
4954
});
5055
}
5156

52-
beforeEach(() => {
53-
cy.login();
54-
interceptChart({ legacy: false }).as('chartData');
55-
});
56-
5757
it('should work', () => {
5858
verify(BIG_NUMBER_FORM_DATA);
5959
cy.get('.chart-container .header-line');

superset-frontend/cypress-base/cypress/integration/explore/visualizations/big_number_total.test.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ import { interceptChart } from 'cypress/utils';
2020
import { FORM_DATA_DEFAULTS, NUM_METRIC } from './shared.helper';
2121

2222
describe('Visualization > Big Number Total', () => {
23+
beforeEach(() => {
24+
cy.preserveLogin();
25+
interceptChart({ legacy: false }).as('chartData');
26+
});
27+
2328
const BIG_NUMBER_DEFAULTS = {
2429
...FORM_DATA_DEFAULTS,
2530
viz_type: 'big_number_total',
2631
};
2732

28-
beforeEach(() => {
29-
cy.login();
30-
interceptChart({ legacy: false }).as('chartData');
31-
});
32-
3333
it('Test big number chart with adhoc metric', () => {
3434
const formData = { ...BIG_NUMBER_DEFAULTS, metric: NUM_METRIC };
3535

superset-frontend/cypress-base/cypress/integration/explore/visualizations/box_plot.test.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
* under the License.
1818
*/
1919
describe('Visualization > Box Plot', () => {
20+
beforeEach(() => {
21+
cy.preserveLogin();
22+
cy.intercept('POST', '/api/v1/chart/data*').as('getJson');
23+
});
24+
2025
const BOX_PLOT_FORM_DATA = {
2126
datasource: '2__table',
2227
viz_type: 'box_plot',
@@ -37,17 +42,14 @@ describe('Visualization > Box Plot', () => {
3742
cy.verifySliceSuccess({ waitAlias: '@getJson' });
3843
}
3944

40-
beforeEach(() => {
41-
cy.login();
42-
cy.intercept('POST', '/api/v1/chart/data*').as('getJson');
43-
});
44-
4545
it('should work', () => {
4646
verify(BOX_PLOT_FORM_DATA);
4747
cy.get('.chart-container .box_plot canvas').should('have.length', 1);
4848
});
4949

5050
it('should allow type to search color schemes', () => {
51+
verify(BOX_PLOT_FORM_DATA);
52+
5153
cy.get('#controlSections-tab-display').click();
5254
cy.get('.Control[data-test="color_scheme"]').scrollIntoView();
5355
cy.get('.Control[data-test="color_scheme"] input[type="search"]')

superset-frontend/cypress-base/cypress/integration/explore/visualizations/bubble.test.js

+7-27
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
* under the License.
1818
*/
1919
describe('Visualization > Bubble', () => {
20+
beforeEach(() => {
21+
cy.preserveLogin();
22+
cy.intercept('POST', '/superset/explore_json/**').as('getJson');
23+
});
24+
2025
const BUBBLE_FORM_DATA = {
2126
datasource: '2__table',
2227
viz_type: 'bubble',
@@ -51,33 +56,6 @@ describe('Visualization > Bubble', () => {
5156
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' });
5257
}
5358

54-
beforeEach(() => {
55-
cy.login();
56-
cy.intercept('POST', '/superset/explore_json/**').as('getJson');
57-
});
58-
59-
// Number of circles are pretty unstable when there are a lot of circles
60-
// Since main functionality is already covered in filter test below,
61-
// skip this test until we find a solution.
62-
it.skip('should work', () => {
63-
cy.visitChartByParams(BUBBLE_FORM_DATA).then(() => {
64-
cy.wait('@getJson').then(xhr => {
65-
let expectedBubblesNumber = 0;
66-
xhr.responseBody.data.forEach(element => {
67-
expectedBubblesNumber += element.values.length;
68-
});
69-
cy.get('[data-test="chart-container"]')
70-
.should('be.visible', { timeout: 15000 })
71-
.within(() => {
72-
cy.get('svg')
73-
.should('exist')
74-
.find('.nv-point-clips circle')
75-
.should('have.length', expectedBubblesNumber);
76-
});
77-
});
78-
});
79-
});
80-
8159
it('should work with filter', () => {
8260
verify({
8361
...BUBBLE_FORM_DATA,
@@ -109,6 +87,8 @@ describe('Visualization > Bubble', () => {
10987
});
11088

11189
it('should allow type to search color schemes and apply the scheme', () => {
90+
cy.visitChartByParams(BUBBLE_FORM_DATA);
91+
11292
cy.get('.Control[data-test="color_scheme"]').scrollIntoView();
11393
cy.get('.Control[data-test="color_scheme"] input[type="search"]')
11494
.focus()

superset-frontend/cypress-base/cypress/integration/explore/visualizations/compare.test.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
* under the License.
1818
*/
1919
describe('Visualization > Compare', () => {
20+
beforeEach(() => {
21+
cy.preserveLogin();
22+
cy.intercept('POST', '/superset/explore_json/**').as('getJson');
23+
});
24+
2025
const COMPARE_FORM_DATA = {
2126
datasource: '3__table',
2227
viz_type: 'compare',
@@ -51,11 +56,6 @@ describe('Visualization > Compare', () => {
5156
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' });
5257
}
5358

54-
beforeEach(() => {
55-
cy.login();
56-
cy.intercept('POST', '/superset/explore_json/**').as('getJson');
57-
});
58-
5959
it('should work without groupby', () => {
6060
verify(COMPARE_FORM_DATA);
6161
cy.get('.chart-container .nvd3 path.nv-line').should('have.length', 1);
@@ -88,6 +88,8 @@ describe('Visualization > Compare', () => {
8888
});
8989

9090
it('should allow type to search color schemes and apply the scheme', () => {
91+
verify(COMPARE_FORM_DATA);
92+
9193
cy.get('#controlSections-tab-display').click();
9294
cy.get('.Control[data-test="color_scheme"]').scrollIntoView();
9395
cy.get('.Control[data-test="color_scheme"] input[type="search"]')

superset-frontend/cypress-base/cypress/integration/explore/visualizations/dist_bar.test.js

+11-10
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,20 @@
1919
import { FORM_DATA_DEFAULTS, NUM_METRIC } from './shared.helper';
2020

2121
describe('Visualization > Distribution bar chart', () => {
22-
const VIZ_DEFAULTS = { ...FORM_DATA_DEFAULTS, viz_type: 'dist_bar' };
23-
2422
beforeEach(() => {
25-
cy.login();
23+
cy.preserveLogin();
2624
cy.intercept('POST', '/superset/explore_json/**').as('getJson');
2725
});
2826

29-
it('should work with adhoc metric', () => {
30-
const formData = {
31-
...VIZ_DEFAULTS,
32-
metrics: NUM_METRIC,
33-
groupby: ['state'],
34-
};
27+
const VIZ_DEFAULTS = { ...FORM_DATA_DEFAULTS, viz_type: 'dist_bar' };
28+
const DISTBAR_FORM_DATA = {
29+
...VIZ_DEFAULTS,
30+
metrics: NUM_METRIC,
31+
groupby: ['state'],
32+
};
3533

36-
cy.visitChartByParams(formData);
34+
it('should work with adhoc metric', () => {
35+
cy.visitChartByParams(DISTBAR_FORM_DATA);
3736
cy.verifySliceSuccess({
3837
waitAlias: '@getJson',
3938
querySubstring: NUM_METRIC.label,
@@ -79,6 +78,8 @@ describe('Visualization > Distribution bar chart', () => {
7978
});
8079

8180
it('should allow type to search color schemes and apply the scheme', () => {
81+
cy.visitChartByParams(DISTBAR_FORM_DATA);
82+
8283
cy.get('#controlSections-tab-display').click();
8384
cy.get('.Control[data-test="color_scheme"]').scrollIntoView();
8485
cy.get('.Control[data-test="color_scheme"] input[type="search"]')

superset-frontend/cypress-base/cypress/integration/explore/visualizations/dual_line.test.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
* under the License.
1818
*/
1919
describe('Visualization > Dual Line', () => {
20+
beforeEach(() => {
21+
cy.preserveLogin();
22+
cy.intercept('POST', '/superset/explore_json/**').as('getJson');
23+
});
24+
2025
const DUAL_LINE_FORM_DATA = {
2126
datasource: '3__table',
2227
viz_type: 'dual_line',
@@ -39,11 +44,6 @@ describe('Visualization > Dual Line', () => {
3944
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' });
4045
}
4146

42-
beforeEach(() => {
43-
cy.login();
44-
cy.intercept('POST', '/superset/explore_json/**').as('getJson');
45-
});
46-
4747
it('should work', () => {
4848
verify(DUAL_LINE_FORM_DATA);
4949
cy.get('.chart-container svg path.nv-line').should('have.length', 2);
@@ -68,6 +68,8 @@ describe('Visualization > Dual Line', () => {
6868
});
6969

7070
it('should allow type to search color schemes and apply the scheme', () => {
71+
verify(DUAL_LINE_FORM_DATA);
72+
7173
cy.get('#controlSections-tab-display').click();
7274
cy.get('.Control[data-test="color_scheme"]').scrollIntoView();
7375
cy.get('.Control[data-test="color_scheme"] input[type="search"]')

superset-frontend/cypress-base/cypress/integration/explore/visualizations/gauge.test.js

+10-9
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,18 @@
1717
* under the License.
1818
*/
1919

20-
// TODO(kgabryje): fix it and un-skip
21-
describe.skip('Visualization > Gauge', () => {
20+
describe('Visualization > Gauge', () => {
21+
beforeEach(() => {
22+
cy.preserveLogin();
23+
cy.intercept('POST', '/api/v1/chart/data*').as('getJson');
24+
});
25+
2226
const GAUGE_FORM_DATA = {
23-
datasource: '2__table',
27+
datasource: '3__table',
2428
viz_type: 'gauge_chart',
2529
metric: 'count',
2630
adhoc_filters: [],
27-
slice_id: 49,
31+
slice_id: 54,
2832
row_limit: 10,
2933
};
3034

@@ -33,11 +37,6 @@ describe.skip('Visualization > Gauge', () => {
3337
cy.verifySliceSuccess({ waitAlias: '@getJson' });
3438
}
3539

36-
beforeEach(() => {
37-
cy.login();
38-
cy.intercept('POST', '/api/v1/chart/data*').as('getJson');
39-
});
40-
4140
it('should work', () => {
4241
verify(GAUGE_FORM_DATA);
4342
cy.get('.chart-container .gauge_chart canvas').should('have.length', 1);
@@ -64,6 +63,8 @@ describe.skip('Visualization > Gauge', () => {
6463
});
6564

6665
it('should allow type to search color schemes', () => {
66+
verify(GAUGE_FORM_DATA);
67+
6768
cy.get('#controlSections-tab-display').click();
6869
cy.get('.Control[data-test="color_scheme"]').scrollIntoView();
6970
cy.get('.Control[data-test="color_scheme"] input[type="search"]')

superset-frontend/cypress-base/cypress/integration/explore/visualizations/graph.test.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ type adhocFilter = {
2727
};
2828

2929
describe('Visualization > Graph', () => {
30+
beforeEach(() => {
31+
cy.preserveLogin();
32+
cy.intercept('POST', '/api/v1/chart/data*').as('getJson');
33+
});
34+
3035
const GRAPH_FORM_DATA = {
3136
datasource: '1__table',
3237
viz_type: 'graph_chart',
@@ -50,11 +55,6 @@ describe('Visualization > Graph', () => {
5055
cy.verifySliceSuccess({ waitAlias: '@getJson' });
5156
}
5257

53-
beforeEach(() => {
54-
cy.login();
55-
cy.intercept('POST', '/api/v1/chart/data*').as('getJson');
56-
});
57-
5858
it('should work with ad-hoc metric', () => {
5959
verify(GRAPH_FORM_DATA);
6060
cy.get('.chart-container .graph_chart canvas').should('have.length', 1);
@@ -79,6 +79,8 @@ describe('Visualization > Graph', () => {
7979
});
8080

8181
it('should allow type to search color schemes', () => {
82+
verify(GRAPH_FORM_DATA);
83+
8284
cy.get('#controlSections-tab-display').click();
8385
cy.get('.Control[data-test="color_scheme"]').scrollIntoView();
8486
cy.get('.Control[data-test="color_scheme"] input[type="search"]')

superset-frontend/cypress-base/cypress/integration/explore/visualizations/histogram.test.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
import { QueryFormData } from '@superset-ui/core';
2020

2121
describe('Visualization > Histogram', () => {
22+
beforeEach(() => {
23+
cy.preserveLogin();
24+
cy.intercept('POST', '/superset/explore_json/**').as('getJson');
25+
});
26+
2227
const HISTOGRAM_FORM_DATA: QueryFormData = {
2328
datasource: '3__table',
2429
viz_type: 'histogram',
@@ -43,11 +48,6 @@ describe('Visualization > Histogram', () => {
4348
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' });
4449
}
4550

46-
beforeEach(() => {
47-
cy.login();
48-
cy.intercept('POST', '/superset/explore_json/**').as('getJson');
49-
});
50-
5151
it('should work without groupby', () => {
5252
verify(HISTOGRAM_FORM_DATA);
5353
cy.get('.chart-container svg .vx-bar').should(
@@ -86,6 +86,8 @@ describe('Visualization > Histogram', () => {
8686
});
8787

8888
it('should allow type to search color schemes and apply the scheme', () => {
89+
verify(HISTOGRAM_FORM_DATA);
90+
8991
cy.get('#controlSections-tab-display').click();
9092
cy.get('.Control[data-test="color_scheme"]').scrollIntoView();
9193
cy.get('.Control[data-test="color_scheme"] input[type="search"]')

0 commit comments

Comments
 (0)