Skip to content

Commit

Permalink
Test buttons behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
geido committed Mar 31, 2022
1 parent 6238d12 commit 3d52cba
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions superset-frontend/src/explore/components/SaveModal.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,36 @@ describe('SaveModal', () => {
expect(wrapper.find(Radio)).toHaveLength(2);

const footerWrapper = shallow(wrapper.find(StyledModal).props().footer);

expect(footerWrapper.find(Button)).toHaveLength(3);
});

it('renders the right footer buttons when an existing dashboard', () => {
const wrapper = getWrapper();
const footerWrapper = shallow(wrapper.find(StyledModal).props().footer);
const saveAndGoDash = footerWrapper
.find('#btn_modal_save_goto_dash')
.getElement();
const save = footerWrapper.find('#btn_modal_save').getElement();
expect(save.props.children).toBe('Save');
expect(saveAndGoDash.props.children).toBe('Save & go to dashboard');
});

it('renders the right footer buttons when a new dashboard', () => {
const wrapper = getWrapper();
wrapper.setState({
saveToDashboardId: null,
newDashboardName: 'Test new dashboard',
});
const footerWrapper = shallow(wrapper.find(StyledModal).props().footer);
const saveAndGoDash = footerWrapper
.find('#btn_modal_save_goto_dash')
.getElement();
const save = footerWrapper.find('#btn_modal_save').getElement();
expect(save.props.children).toBe('Save to new dashboard');
expect(saveAndGoDash.props.children).toBe('Save & go to new dashboard');
});

it('overwrite radio button is disabled for new slice', () => {
const wrapper = getWrapper();
wrapper.setProps({ slice: null });
Expand Down

0 comments on commit 3d52cba

Please sign in to comment.