mirror of https://github.com/apache/superset.git
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
This commit is contained in:
parent
8f3d911149
commit
d1a3ba85dd
|
@ -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');
|
||||
});
|
||||
});
|
|
@ -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"]');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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(*)');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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', () => {
|
||||
|
|
|
@ -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')
|
||||
|
||||
|
|
Loading…
Reference in New Issue