Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Creating tests for table and dist bar
- Loading branch information
1 parent
ae80a1c
commit 0b443d6
Showing
4 changed files
with
176 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
superset/assets/cypress/integration/explore/visualizations/dist_bar.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { FORM_DATA_DEFAULTS, NUM_METRIC } from './shared.helper'; | ||
|
||
// Dist bar | ||
|
||
describe('Distribution bar chart', () => { | ||
const VIZ_DEFAULTS = { ...FORM_DATA_DEFAULTS, viz_type: 'dist_bar' }; | ||
|
||
beforeEach(() => { | ||
cy.login(); | ||
cy.server(); | ||
cy.route('POST', '/superset/explore_json/**').as('getJson'); | ||
}); | ||
|
||
it('Test dist bar with adhoc metric', () => { | ||
const formData = { ...VIZ_DEFAULTS, metrics: NUM_METRIC, groupby: ['state'] }; | ||
|
||
cy.visitChartByParams(JSON.stringify(formData)); | ||
cy.verifySliceSuccess({ | ||
waitAlias: '@getJson', | ||
querySubstring: NUM_METRIC.label, | ||
chartSelector: 'svg', | ||
}); | ||
}); | ||
|
||
it('Test dist bar with series', () => { | ||
const formData = { | ||
...VIZ_DEFAULTS, | ||
metrics: NUM_METRIC, | ||
groupby: ['state'], | ||
columns: ['gender'], | ||
}; | ||
|
||
cy.visitChartByParams(JSON.stringify(formData)); | ||
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' }); | ||
}); | ||
|
||
it('Test dist bar with row limit', () => { | ||
const formData = { | ||
...VIZ_DEFAULTS, | ||
metrics: NUM_METRIC, | ||
groupby: ['state'], | ||
row_limit: 10, | ||
}; | ||
|
||
cy.visitChartByParams(JSON.stringify(formData)); | ||
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' }); | ||
}); | ||
|
||
it('Test dist bar with contribution', () => { | ||
const formData = { | ||
...VIZ_DEFAULTS, | ||
metrics: NUM_METRIC, | ||
groupby: ['state'], | ||
columns: ['gender'], | ||
contribution: true, | ||
}; | ||
|
||
cy.visitChartByParams(JSON.stringify(formData)); | ||
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' }); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
superset/assets/cypress/integration/explore/visualizations/table.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import { FORM_DATA_DEFAULTS, NUM_METRIC, SIMPLE_FILTER } from './shared.helper'; | ||
|
||
// Table | ||
|
||
describe('Table chart', () => { | ||
const VIZ_DEFAULTS = { ...FORM_DATA_DEFAULTS, viz_type: 'table' }; | ||
|
||
beforeEach(() => { | ||
cy.login(); | ||
cy.server(); | ||
cy.route('POST', '/superset/explore_json/**').as('getJson'); | ||
}); | ||
|
||
it('Test table with adhoc metric', () => { | ||
const formData = { ...VIZ_DEFAULTS, metrics: NUM_METRIC }; | ||
|
||
cy.visitChartByParams(JSON.stringify(formData)); | ||
cy.verifySliceSuccess({ | ||
waitAlias: '@getJson', | ||
querySubstring: NUM_METRIC.label, | ||
chartSelector: 'table', | ||
}); | ||
}); | ||
|
||
it('Test table with groupby', () => { | ||
const formData = { ...VIZ_DEFAULTS, metrics: NUM_METRIC, groupby: ['name'] }; | ||
|
||
cy.visitChartByParams(JSON.stringify(formData)); | ||
cy.verifySliceSuccess({ | ||
waitAlias: '@getJson', | ||
querySubstring: formData.groupby[0], | ||
chartSelector: 'table', | ||
}); | ||
}); | ||
|
||
it('Test table with percent metrics and groupby', () => { | ||
const formData = { | ||
...VIZ_DEFAULTS, | ||
percent_metrics: NUM_METRIC, | ||
metrics: [], | ||
groupby: ['name'], | ||
}; | ||
|
||
cy.visitChartByParams(JSON.stringify(formData)); | ||
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'table' }); | ||
}); | ||
|
||
it('Test table with groupby order desc', () => { | ||
const formData = { ...VIZ_DEFAULTS, metrics: NUM_METRIC, groupby: ['name'], order_desc: true }; | ||
|
||
cy.visitChartByParams(JSON.stringify(formData)); | ||
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'table' }); | ||
}); | ||
|
||
it('Test table with groupby and limit', () => { | ||
const limit = 10; | ||
|
||
const formData = { ...VIZ_DEFAULTS, metrics: NUM_METRIC, groupby: ['name'], row_limit: limit }; | ||
|
||
cy.visitChartByParams(JSON.stringify(formData)); | ||
|
||
cy.wait('@getJson').then((data) => { | ||
cy.verifyResponseCodes(data); | ||
cy.verifySliceContainer('table'); | ||
expect(data.response.body.data.records.length).to.eq(limit); | ||
}); | ||
}); | ||
|
||
it('Test table with columns and row limit', () => { | ||
const formData = { ...VIZ_DEFAULTS, all_columns: ['name'], metrics: [], row_limit: 10 }; | ||
|
||
cy.visitChartByParams(JSON.stringify(formData)); | ||
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'table' }); | ||
}); | ||
|
||
it('Test table with columns, ordering, and row limit', () => { | ||
const limit = 10; | ||
|
||
const formData = { | ||
...VIZ_DEFAULTS, | ||
all_columns: ['name', 'state', 'ds', 'num'], | ||
metrics: [], | ||
row_limit: limit, | ||
order_by_cols: ['["num",+false]'], | ||
}; | ||
|
||
cy.visitChartByParams(JSON.stringify(formData)); | ||
cy.wait('@getJson').then((data) => { | ||
cy.verifyResponseCodes(data); | ||
cy.verifySliceContainer('table'); | ||
const records = data.response.body.data.records; | ||
expect(records[0].num).greaterThan(records[records.length - 1].num); | ||
}); | ||
}); | ||
|
||
it('Test table with simple filter', () => { | ||
const metrics = ['count']; | ||
const filters = [SIMPLE_FILTER]; | ||
|
||
const formData = { ...VIZ_DEFAULTS, metrics, adhoc_filters: filters }; | ||
|
||
cy.visitChartByParams(JSON.stringify(formData)); | ||
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'table' }); | ||
}); | ||
}); |