mirror of
https://github.com/apache/superset.git
synced 2024-09-12 00:29:39 -04:00
Add more tests to Save Modal specs (#2313)
This commit is contained in:
parent
dcd5bdeb00
commit
c02a7fe763
@ -141,6 +141,7 @@ class SaveModal extends React.Component {
|
||||
}
|
||||
{this.props.slice &&
|
||||
<Radio
|
||||
id="overwrite-radio"
|
||||
disabled={!this.props.can_overwrite}
|
||||
checked={this.state.action === 'overwrite'}
|
||||
onChange={this.changeAction.bind(this, 'overwrite')}
|
||||
@ -150,6 +151,7 @@ class SaveModal extends React.Component {
|
||||
}
|
||||
|
||||
<Radio
|
||||
id="saveas-radio"
|
||||
inline
|
||||
checked={this.state.action === 'saveas'}
|
||||
onChange={this.changeAction.bind(this, 'saveas')}
|
||||
|
@ -14,7 +14,8 @@ const defaultProps = {
|
||||
saveSlice: sinon.spy(),
|
||||
},
|
||||
form_data: defaultFormData,
|
||||
user_id: 1,
|
||||
user_id: '1',
|
||||
dashboards: [],
|
||||
slice: {},
|
||||
};
|
||||
|
||||
@ -31,4 +32,44 @@ describe('SaveModal', () => {
|
||||
expect(wrapper.find(Button)).to.have.lengthOf(2);
|
||||
expect(wrapper.find(Radio)).to.have.lengthOf(5);
|
||||
});
|
||||
|
||||
it('does not show overwrite option for new slice', () => {
|
||||
defaultProps.slice = null;
|
||||
const wrapperNewSlice = shallow(<SaveModal {...defaultProps} />);
|
||||
expect(wrapperNewSlice.find('#overwrite-radio')).to.have.lengthOf(0);
|
||||
expect(wrapperNewSlice.find('#saveas-radio')).to.have.lengthOf(1);
|
||||
});
|
||||
|
||||
it('disable overwrite option for non-owner', () => {
|
||||
defaultProps.slice = {};
|
||||
defaultProps.can_overwrite = false;
|
||||
const wrapperForNonOwner = shallow(<SaveModal {...defaultProps} />);
|
||||
const overwriteRadio = wrapperForNonOwner.find('#overwrite-radio');
|
||||
expect(overwriteRadio).to.have.lengthOf(1);
|
||||
expect(overwriteRadio.prop('disabled')).to.equal(true);
|
||||
});
|
||||
|
||||
it('saves a new slice', () => {
|
||||
defaultProps.slice = {
|
||||
slice_id: 1,
|
||||
slice_name: 'title',
|
||||
};
|
||||
defaultProps.can_overwrite = false;
|
||||
const wrapperForNewSlice = shallow(<SaveModal {...defaultProps} />);
|
||||
const saveasRadio = wrapperForNewSlice.find('#saveas-radio');
|
||||
saveasRadio.simulate('click');
|
||||
expect(wrapperForNewSlice.state().action).to.equal('saveas');
|
||||
});
|
||||
|
||||
it('overwrite a slice', () => {
|
||||
defaultProps.slice = {
|
||||
slice_id: 1,
|
||||
slice_name: 'title',
|
||||
};
|
||||
defaultProps.can_overwrite = true;
|
||||
const wrapperForOverwrite = shallow(<SaveModal {...defaultProps} />);
|
||||
const overwriteRadio = wrapperForOverwrite.find('#overwrite-radio');
|
||||
overwriteRadio.simulate('click');
|
||||
expect(wrapperForOverwrite.state().action).to.equal('overwrite');
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user