mirror of
https://github.com/apache/superset.git
synced 2026-04-11 20:37:16 +00:00
feat: [dashboard] notification and warning for auto force refresh (#9886)
* feat: [dashboard] notification and warning for auto force refresh * fix review comments
This commit is contained in:
@@ -17,9 +17,11 @@
|
||||
* under the License.
|
||||
*/
|
||||
import React from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
import { mount, shallow } from 'enzyme';
|
||||
|
||||
import ModalTrigger from 'src/components/ModalTrigger';
|
||||
import RefreshIntervalModal from 'src/dashboard/components/RefreshIntervalModal';
|
||||
import { Modal, Alert } from 'react-bootstrap';
|
||||
|
||||
describe('RefreshIntervalModal', () => {
|
||||
const mockedProps = {
|
||||
@@ -44,7 +46,22 @@ describe('RefreshIntervalModal', () => {
|
||||
it('should change refreshFrequency with edit mode', () => {
|
||||
const wrapper = mount(<RefreshIntervalModal {...mockedProps} />);
|
||||
wrapper.instance().handleFrequencyChange({ value: 30 });
|
||||
wrapper.instance().onSave();
|
||||
expect(mockedProps.onChange).toHaveBeenCalled();
|
||||
expect(mockedProps.onChange).toHaveBeenCalledWith(30, mockedProps.editMode);
|
||||
});
|
||||
it('should show warning message', () => {
|
||||
const props = {
|
||||
...mockedProps,
|
||||
refreshLimit: 3600,
|
||||
refreshWarning: 'Show warning',
|
||||
};
|
||||
|
||||
const wrapper = shallow(<RefreshIntervalModal {...props} />);
|
||||
wrapper.instance().handleFrequencyChange({ value: 30 });
|
||||
expect(wrapper.find(ModalTrigger).dive().find(Alert)).toHaveLength(1);
|
||||
|
||||
wrapper.instance().handleFrequencyChange({ value: 3601 });
|
||||
expect(wrapper.find(ModalTrigger).dive().find(Alert)).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user