From commits-return-1860-archive-asf-public=cust-asf.ponee.io@superset.incubator.apache.org Mon Nov 19 20:29:55 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 7F1A3180671 for ; Mon, 19 Nov 2018 20:29:54 +0100 (CET) Received: (qmail 39819 invoked by uid 500); 19 Nov 2018 19:29:53 -0000 Mailing-List: contact commits-help@superset.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@superset.incubator.apache.org Delivered-To: mailing list commits@superset.incubator.apache.org Received: (qmail 39809 invoked by uid 99); 19 Nov 2018 19:29:53 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 19 Nov 2018 19:29:53 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 105AA82D88; Mon, 19 Nov 2018 19:29:53 +0000 (UTC) Date: Mon, 19 Nov 2018 19:29:52 +0000 To: "commits@superset.apache.org" Subject: [incubator-superset] branch master updated: Adding cypress tests for showing errors, time range filter, and verbose name (#6407) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <154265579274.8712.18026673378089401725@gitbox.apache.org> From: michellet@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: incubator-superset X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 8f3d9111493e0ae3d52ba9ada81fe1e414cbabd8 X-Git-Newrev: d1a3ba85dd9e75ecbdc52a7c92ed27efda709f48 X-Git-Rev: d1a3ba85dd9e75ecbdc52a7c92ed27efda709f48 X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated 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 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')