You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by mi...@apache.org on 2018/11/19 19:29:52 UTC
[incubator-superset] branch master updated: Adding cypress tests
for showing errors, time range filter, and verbose name (#6407)
This is an automated email from the ASF dual-hosted git repository.
michellet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
The following commit(s) were added to refs/heads/master by this push:
new d1a3ba8 Adding cypress tests for showing errors, time range filter, and verbose name (#6407)
d1a3ba8 is described below
commit d1a3ba85dd9e75ecbdc52a7c92ed27efda709f48
Author: michellethomas <mi...@gmail.com>
AuthorDate: Mon Nov 19 11:29:46 2018 -0800
Adding cypress tests for showing errors, time range filter, and verbose name (#6407)
* Adding cypress tests for showing erros, time range filter, and verbose name
* Adding tests for time range without ago
* Adding test to verify error message showing
---
.../cypress/integration/explore/chart.test.js | 39 +++++++++++++++++++++
.../cypress/integration/explore/control.test.js | 40 ++++++++++++++++++++--
.../integration/explore/visualizations/line.js | 11 ++++++
.../integration/explore/visualizations/table.js | 1 +
tests/utils_tests.py | 4 +++
5 files changed, 92 insertions(+), 3 deletions(-)
diff --git a/superset/assets/cypress/integration/explore/chart.test.js b/superset/assets/cypress/integration/explore/chart.test.js
new file mode 100644
index 0000000..68ad638
--- /dev/null
+++ b/superset/assets/cypress/integration/explore/chart.test.js
@@ -0,0 +1,39 @@
+import { FORM_DATA_DEFAULTS, NUM_METRIC } from './visualizations/shared.helper';
+import readResponseBlob from '../../utils/readResponseBlob';
+
+describe('Error', () => {
+ beforeEach(() => {
+ cy.login();
+ cy.server();
+ cy.route('POST', '/superset/explore_json/**').as('getJson');
+ });
+
+ it('No data error message shows up', () => {
+ const formData = {
+ ...FORM_DATA_DEFAULTS,
+ metrics: [NUM_METRIC],
+ viz_type: 'line',
+ adhoc_filters: [{
+ expressionType: 'SIMPLE',
+ subject: 'state',
+ operator: 'in',
+ comparator: ['Fake State'],
+ clause: 'WHERE',
+ sqlExpression: null,
+ fromFormData: true,
+ }],
+ };
+
+ cy.visitChartByParams(JSON.stringify(formData));
+ cy.wait('@getJson').then(async (xhr) => {
+ expect(xhr.status).to.eq(400);
+
+ const responseBody = await readResponseBlob(xhr.response.body);
+
+ if (responseBody.error) {
+ expect(responseBody.error).to.eq('No data');
+ }
+ });
+ cy.get('div.alert').contains('No data');
+ });
+});
diff --git a/superset/assets/cypress/integration/explore/control.test.js b/superset/assets/cypress/integration/explore/control.test.js
index 5f37973..68b7a14 100644
--- a/superset/assets/cypress/integration/explore/control.test.js
+++ b/superset/assets/cypress/integration/explore/control.test.js
@@ -1,6 +1,7 @@
// ***********************************************
// Tests for setting controls in the UI
// ***********************************************
+import { FORM_DATA_DEFAULTS, NUM_METRIC } from './visualizations/shared.helper';
describe('Groupby', () => {
it('Set groupby', () => {
@@ -61,7 +62,7 @@ describe('AdhocMetrics', () => {
});
});
- xit('Clear metric and set custom sql adhoc metric', () => {
+ it('Clear metric and set custom sql adhoc metric', () => {
const metric = 'SUM(num)/COUNT(DISTINCT name)';
cy.visitChartByName('Num Births Trend');
@@ -70,7 +71,7 @@ describe('AdhocMetrics', () => {
cy.get('[data-test=metrics]').within(() => {
cy.get('.select-clear').click();
cy.get('.Select-control').click({ force: true });
- cy.get('input').type('num', { force: true });
+ cy.get('input').type('num{downarrow}', { force: true });
cy.get('.VirtualizedSelectFocusedOption')
.trigger('mousedown')
.click();
@@ -80,7 +81,7 @@ describe('AdhocMetrics', () => {
cy.get('#adhoc-metric-edit-tabs-tab-SQL').click();
cy.get('.ace_content').click();
cy.get('.ace_text-input')
- .type(`{selectall}{backspace}${metric}`, { force: true });
+ .type('/COUNT(DISTINCT name)', { force: true });
cy.get('button').contains('Save').click();
});
@@ -267,3 +268,36 @@ describe('Annotations', () => {
cy.get('.nv-legend-text').should('have.length', 2);
});
});
+
+describe('Time range filter', () => {
+ beforeEach(() => {
+ cy.login();
+ cy.server();
+ cy.route('POST', '/superset/explore_json/**').as('getJson');
+ });
+
+ it('Defaults to the correct tab for time_range params', () => {
+ const formData = {
+ ...FORM_DATA_DEFAULTS,
+ metrics: [NUM_METRIC],
+ viz_type: 'line',
+ time_range: '100 years ago : now',
+ };
+
+ cy.visitChartByParams(JSON.stringify(formData));
+ cy.verifySliceSuccess({ waitAlias: '@getJson' });
+
+ cy.get('[data-test=time_range]').within(() => {
+ cy.get('span.label').click();
+ });
+
+ cy.get('#filter-popover').within(() => {
+ cy.get('div.tab-pane.active').within(() => {
+ cy.get('div.PopoverSection :not(.dimmed)').within(() => {
+ cy.get('input[value="100 years ago"]');
+ cy.get('input[value="now"]');
+ });
+ });
+ });
+ });
+});
diff --git a/superset/assets/cypress/integration/explore/visualizations/line.js b/superset/assets/cypress/integration/explore/visualizations/line.js
index 6705b77..ca7e048 100644
--- a/superset/assets/cypress/integration/explore/visualizations/line.js
+++ b/superset/assets/cypress/integration/explore/visualizations/line.js
@@ -113,4 +113,15 @@ export default () => describe('Line', () => {
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(*)');
+ });
});
diff --git a/superset/assets/cypress/integration/explore/visualizations/table.js b/superset/assets/cypress/integration/explore/visualizations/table.js
index 0f70106..f9a62a0 100644
--- a/superset/assets/cypress/integration/explore/visualizations/table.js
+++ b/superset/assets/cypress/integration/explore/visualizations/table.js
@@ -66,6 +66,7 @@ export default () => describe('Table chart', () => {
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', () => {
diff --git a/tests/utils_tests.py b/tests/utils_tests.py
index c942337..a44336a 100644
--- a/tests/utils_tests.py
+++ b/tests/utils_tests.py
@@ -618,6 +618,10 @@ class UtilsTestCase(unittest.TestCase):
expected = datetime(2016, 11, 5), datetime(2016, 11, 7)
self.assertEqual(result, expected)
+ result = get_since_until(time_range='5 days : now')
+ expected = datetime(2016, 11, 2), datetime(2016, 11, 7)
+ self.assertEqual(result, expected)
+
with self.assertRaises(ValueError):
get_since_until(time_range='tomorrow : yesterday')