Migrate Bootstrap Alert to AntD (#12101) (#12122)

This commit is contained in:
Michael S. Molina
2021-02-22 01:50:18 -03:00
committed by GitHub
parent 7ee8d114d2
commit 42ab57850d
31 changed files with 573 additions and 301 deletions

View File

@@ -296,11 +296,7 @@ describe('ListView', () => {
});
it('allows disabling bulkSelect', () => {
wrapper
.find('[data-test="bulk-select-controls"]')
.at(0)
.props()
.onDismiss();
wrapper.find('[data-test="bulk-select-controls"]').at(0).props().onClose();
expect(mockedProps.disableBulkSelect).toHaveBeenCalled();
});

View File

@@ -21,7 +21,7 @@ import { mount } from 'enzyme';
import ModalTrigger from 'src/components/ModalTrigger';
import RefreshIntervalModal from 'src/dashboard/components/RefreshIntervalModal';
import { Alert } from 'react-bootstrap';
import Alert from 'src/components/Alert';
import { supersetTheme, ThemeProvider } from '@superset-ui/core';
const getMountWrapper = props =>

View File

@@ -21,8 +21,8 @@ import { styledMount as mount } from 'spec/helpers/theming';
import { act } from 'react-dom/test-utils';
import { ReactWrapper } from 'enzyme';
import { Provider } from 'react-redux';
import Alert from 'react-bootstrap/lib/Alert';
import { FilterConfigModal } from 'src/dashboard/components/nativeFilters/FilterConfigModal/FilterConfigModal';
import Alert from 'src/components/Alert';
import waitForComponentToPaint from 'spec/helpers/waitForComponentToPaint';
import { mockStore } from 'spec/fixtures/mockStore';

View File

@@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
import { Alert } from 'react-bootstrap';
import React from 'react';
import { mount } from 'enzyme';
import Toast from 'src/messageToasts/components/Toast';
@@ -31,20 +30,19 @@ const props = {
const setup = overrideProps => mount(<Toast {...props} {...overrideProps} />);
describe('Toast', () => {
it('should render an Alert', () => {
it('should render', () => {
const wrapper = setup();
expect(wrapper.find(Alert)).toExist();
expect(wrapper.find('[data-test="toast-container"]')).toExist();
});
it('should render toastText within the alert', () => {
it('should render toastText within the div', () => {
const wrapper = setup();
const alert = wrapper.find(Alert);
expect(alert.childAt(0).childAt(1).text()).toBe(props.toast.text);
const container = wrapper.find('[data-test="toast-container"]');
expect(container.hostNodes().childAt(1).text()).toBe(props.toast.text);
});
it('should call onCloseToast upon alert dismissal', async () => {
await act(
it('should call onCloseToast upon toast dismissal', async () =>
act(
() =>
new Promise(done => {
const onCloseToast = id => {
@@ -53,13 +51,7 @@ describe('Toast', () => {
};
const wrapper = setup({ onCloseToast });
const handleClosePress = wrapper.find('[label="Close alert"]').props()
.onClick;
const alertProps = wrapper.find(Alert).props();
expect(alertProps.onDismiss).toBe(handleClosePress);
handleClosePress(); // there is a timeout for onCloseToast to be called
wrapper.find('[data-test="close-button"]').props().onClick();
}),
);
});
));
});

View File

@@ -18,10 +18,13 @@
*/
import React from 'react';
import { shallow } from 'enzyme';
import { styledMount } from 'spec/helpers/theming';
import { Provider } from 'react-redux';
import sinon from 'sinon';
import { Alert } from 'react-bootstrap';
import Alert from 'src/components/Alert';
import ProgressBar from 'src/common/components/ProgressBar';
import configureStore from 'redux-mock-store';
import thunk from 'redux-thunk';
import FilterableTable from 'src/components/FilterableTable/FilterableTable';
import ExploreResultsButton from 'src/SqlLab/components/ExploreResultsButton';
import ResultSet from 'src/SqlLab/components/ResultSet';
@@ -33,8 +36,12 @@ import {
queries,
runningQuery,
stoppedQuery,
initialState,
} from './fixtures';
const mockStore = configureStore([thunk]);
const store = mockStore(initialState);
describe('ResultSet', () => {
const clearQuerySpy = sinon.spy();
const fetchQuerySpy = sinon.spy();
@@ -105,17 +112,18 @@ describe('ResultSet', () => {
expect(wrapper.find(ExploreResultsButton)).toExist();
});
it('should render empty results', () => {
const wrapper = shallow(<ResultSet {...mockedProps} />);
const emptyResults = {
...queries[0],
results: {
data: [],
},
const props = {
...mockedProps,
query: { ...mockedProps.query, results: { data: [] } },
};
wrapper.setProps({ query: emptyResults });
const wrapper = styledMount(
<Provider store={store}>
<ResultSet {...props} />
</Provider>,
);
expect(wrapper.find(FilterableTable)).not.toExist();
expect(wrapper.find(Alert)).toExist();
expect(wrapper.find(Alert).shallow().text()).toBe(
expect(wrapper.find(Alert).render().text()).toBe(
'The query returned no data',
);
});

View File

@@ -81,12 +81,12 @@ describe('SouthPane', () => {
let wrapper;
it('should render offline when the state is offline', () => {
wrapper = getWrapper();
wrapper = getWrapper().dive();
wrapper.setProps({ offline: true });
expect(wrapper.childAt(0).text()).toBe(STATUS_OPTIONS.offline);
});
it('should pass latest query down to ResultSet component', () => {
wrapper = getWrapper();
wrapper = getWrapper().dive();
expect(wrapper.find(ResultSet)).toExist();
expect(wrapper.find(ResultSet).props().query.id).toEqual(
mockedProps.latestQueryId,