chore(Explore): Change text when saving a chart in a new dashboard (#19467)

* Change text when new dashboard

* Test buttons behavior
This commit is contained in:
Geido
2022-04-05 22:05:05 +03:00
committed by GitHub
parent f64d654de3
commit 1521ab3b6f
2 changed files with 37 additions and 1 deletions

View File

@@ -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 });