You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2018/11/19 19:29:48 UTC

[GitHub] michellethomas closed pull request #6407: Adding cypress tests for showing errors, time range filter, and verbose name

michellethomas closed pull request #6407:  Adding cypress tests for showing errors, time range filter, and verbose name
URL: https://github.com/apache/incubator-superset/pull/6407
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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 0000000000..68ad638635
--- /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 5f3797346f..68b7a14883 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 6705b770bc..ca7e048258 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 0f70106376..f9a62a0f21 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 c9423379bc..a44336a9d4 100644
--- a/tests/utils_tests.py
+++ b/tests/utils_tests.py
@@ -618,6 +618,10 @@ def test_get_since_until(self):
         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')
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org