add new slice form improvements (#2928)

* dont set first datasource as default

* not used

* add a disabled class if datasource is not selected

* sort datasources alphabettically

* make btn disabled is no datasource is selected

* fix linting
This commit is contained in:
Alanna Scott
2017-06-08 10:49:02 -07:00
committed by GitHub
parent 24a2f5b8f0
commit 24292dbc11
3 changed files with 30 additions and 9 deletions

View File

@@ -32,7 +32,27 @@ describe('AddSliceContainer', () => {
expect(wrapper.find(Button)).to.have.lengthOf(1);
});
it('renders a disabled button if no datasource is selected', () => {
expect(wrapper.find(Button).dive().find('.btn[disabled=true]')).to.have.length(1);
});
it('renders an enabled button if datasource is selected', () => {
const datasourceValue = defaultProps.datasources[0].value;
wrapper.setState({
datasourceValue,
datasourceId: datasourceValue.split('__')[0],
datasourceType: datasourceValue.split('__')[1],
});
expect(wrapper.find(Button).dive().find('.btn[disabled=false]')).to.have.length(1);
});
it('formats explore url', () => {
const datasourceValue = defaultProps.datasources[0].value;
wrapper.setState({
datasourceValue,
datasourceId: datasourceValue.split('__')[0],
datasourceType: datasourceValue.split('__')[1],
});
const formattedUrl = '/superset/explore/table/1?form_data=%7B%22viz_type%22%3A%22table%22%7D';
expect(wrapper.instance().exploreUrl()).to.equal(formattedUrl);
});