mirror of
https://github.com/apache/superset.git
synced 2026-04-20 00:24:38 +00:00
test(frontend): use absolute path for src imports (#9761)
* test(frontend): use absolute path for src imports * Upgrade prettier, fix eslint
This commit is contained in:
@@ -21,9 +21,9 @@ import { shallow } from 'enzyme';
|
||||
import { Table, Thead, Td, Th, Tr } from 'reactable-arc';
|
||||
import { getChartControlPanelRegistry } from '@superset-ui/chart';
|
||||
|
||||
import AlteredSliceTag from '../../../src/components/AlteredSliceTag';
|
||||
import ModalTrigger from '../../../src/components/ModalTrigger';
|
||||
import TooltipWrapper from '../../../src/components/TooltipWrapper';
|
||||
import AlteredSliceTag from 'src/components/AlteredSliceTag';
|
||||
import ModalTrigger from 'src/components/ModalTrigger';
|
||||
import TooltipWrapper from 'src/components/TooltipWrapper';
|
||||
|
||||
const defaultProps = {
|
||||
origFormData: {
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
|
||||
import AnchorLink from '../../../src/components/AnchorLink';
|
||||
import URLShortLinkButton from '../../../src/components/URLShortLinkButton';
|
||||
import AnchorLink from 'src/components/AnchorLink';
|
||||
import URLShortLinkButton from 'src/components/URLShortLinkButton';
|
||||
|
||||
describe('AnchorLink', () => {
|
||||
const props = {
|
||||
|
||||
@@ -21,7 +21,7 @@ import Select from 'react-select';
|
||||
import { shallow } from 'enzyme';
|
||||
import fetchMock from 'fetch-mock';
|
||||
|
||||
import AsyncSelect from '../../../src/components/AsyncSelect';
|
||||
import AsyncSelect from 'src/components/AsyncSelect';
|
||||
|
||||
describe('AsyncSelect', () => {
|
||||
afterAll(fetchMock.reset);
|
||||
|
||||
@@ -20,7 +20,7 @@ import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import { Label } from 'react-bootstrap';
|
||||
|
||||
import CachedLabel from '../../../src/components/CachedLabel';
|
||||
import CachedLabel from 'src/components/CachedLabel';
|
||||
|
||||
describe('CachedLabel', () => {
|
||||
const defaultProps = {
|
||||
|
||||
@@ -20,7 +20,7 @@ import React from 'react';
|
||||
import sinon from 'sinon';
|
||||
import { shallow } from 'enzyme';
|
||||
|
||||
import Checkbox from '../../../src/components/Checkbox';
|
||||
import Checkbox from 'src/components/Checkbox';
|
||||
|
||||
describe('Checkbox', () => {
|
||||
const defaultProps = {
|
||||
@@ -49,10 +49,7 @@ describe('Checkbox', () => {
|
||||
});
|
||||
it('unchecks when clicked', () => {
|
||||
expect(wrapper.find('i.fa-check.text-transparent')).toHaveLength(0);
|
||||
wrapper
|
||||
.find('i')
|
||||
.first()
|
||||
.simulate('click');
|
||||
wrapper.find('i').first().simulate('click');
|
||||
expect(defaultProps.onChange.calledOnce).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -19,9 +19,9 @@
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
|
||||
import ColumnOption from '../../../src/components/ColumnOption';
|
||||
import ColumnTypeLabel from '../../../src/components/ColumnTypeLabel';
|
||||
import InfoTooltipWithTrigger from '../../../src/components/InfoTooltipWithTrigger';
|
||||
import ColumnOption from 'src/components/ColumnOption';
|
||||
import ColumnTypeLabel from 'src/components/ColumnTypeLabel';
|
||||
import InfoTooltipWithTrigger from 'src/components/InfoTooltipWithTrigger';
|
||||
|
||||
describe('ColumnOption', () => {
|
||||
const defaultProps = {
|
||||
@@ -60,12 +60,7 @@ describe('ColumnOption', () => {
|
||||
it('shows a label with column_name when no verbose_name', () => {
|
||||
props.column.verbose_name = null;
|
||||
wrapper = shallow(factory(props));
|
||||
expect(
|
||||
wrapper
|
||||
.find('.option-label')
|
||||
.first()
|
||||
.text(),
|
||||
).toBe('foo');
|
||||
expect(wrapper.find('.option-label').first().text()).toBe('foo');
|
||||
});
|
||||
it('shows a column type label when showType is true', () => {
|
||||
wrapper = shallow(
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
|
||||
import ColumnTypeLabel from '../../../src/components/ColumnTypeLabel';
|
||||
import ColumnTypeLabel from 'src/components/ColumnTypeLabel';
|
||||
|
||||
describe('ColumnOption', () => {
|
||||
const defaultProps = {
|
||||
|
||||
@@ -38,10 +38,7 @@ describe('ConfirmStatusChange', () => {
|
||||
);
|
||||
|
||||
it('opens a confirm modal', () => {
|
||||
wrapper
|
||||
.find('#btn1')
|
||||
.props()
|
||||
.onClick('foo');
|
||||
wrapper.find('#btn1').props().onClick('foo');
|
||||
|
||||
wrapper.update();
|
||||
|
||||
@@ -49,11 +46,7 @@ describe('ConfirmStatusChange', () => {
|
||||
});
|
||||
|
||||
it('calls the function on confirm', () => {
|
||||
wrapper
|
||||
.find(Button)
|
||||
.last()
|
||||
.props()
|
||||
.onClick();
|
||||
wrapper.find(Button).last().props().onClick();
|
||||
|
||||
expect(mockedProps.onConfirm).toHaveBeenCalledWith('foo');
|
||||
});
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
import React from 'react';
|
||||
|
||||
import CopyToClipboard from '../../../src/components/CopyToClipboard';
|
||||
import CopyToClipboard from 'src/components/CopyToClipboard';
|
||||
|
||||
describe('CopyToClipboard', () => {
|
||||
const defaultProps = {
|
||||
|
||||
@@ -20,10 +20,12 @@ import React from 'react';
|
||||
import getErrorMessageComponentRegistry from 'src/components/ErrorMessage/getErrorMessageComponentRegistry';
|
||||
import { ErrorMessageComponentProps } from 'src/components/ErrorMessage/types';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const ERROR_MESSAGE_COMPONENT = (_: ErrorMessageComponentProps) => (
|
||||
<div>Test error</div>
|
||||
);
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const OVERRIDE_ERROR_MESSAGE_COMPONENT = (_: ErrorMessageComponentProps) => (
|
||||
<div>Custom error</div>
|
||||
);
|
||||
|
||||
@@ -20,7 +20,7 @@ import React from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
import FilterableTable, {
|
||||
MAX_COLUMNS_FOR_TABLE,
|
||||
} from '../../../../src/components/FilterableTable/FilterableTable';
|
||||
} from 'src/components/FilterableTable/FilterableTable';
|
||||
|
||||
describe('FilterableTable', () => {
|
||||
const mockedProps = {
|
||||
|
||||
@@ -20,9 +20,9 @@ import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
|
||||
import { Col, Row } from 'react-bootstrap';
|
||||
import TextControl from '../../../src/explore/components/controls/TextControl';
|
||||
import InfoTooltipWithTrigger from '../../../src/components/InfoTooltipWithTrigger';
|
||||
import FormRow from '../../../src/components/FormRow';
|
||||
import TextControl from 'src/explore/components/controls/TextControl';
|
||||
import InfoTooltipWithTrigger from 'src/components/InfoTooltipWithTrigger';
|
||||
import FormRow from 'src/components/FormRow';
|
||||
|
||||
const defaultProps = {
|
||||
label: 'Hello',
|
||||
|
||||
@@ -111,10 +111,7 @@ describe('ListView', () => {
|
||||
});
|
||||
|
||||
it('calls fetchData on sort', () => {
|
||||
wrapper
|
||||
.find('[data-test="sort-header"]')
|
||||
.at(1)
|
||||
.simulate('click');
|
||||
wrapper.find('[data-test="sort-header"]').at(1).simulate('click');
|
||||
|
||||
expect(mockedProps.fetchData).toHaveBeenCalled();
|
||||
expect(mockedProps.fetchData.mock.calls[0]).toMatchInlineSnapshot(`
|
||||
@@ -160,10 +157,7 @@ describe('ListView', () => {
|
||||
wrapper.update();
|
||||
|
||||
act(() => {
|
||||
wrapper
|
||||
.find('[data-test="apply-filters"]')
|
||||
.last()
|
||||
.prop('onClick')();
|
||||
wrapper.find('[data-test="apply-filters"]').last().prop('onClick')();
|
||||
});
|
||||
wrapper.update();
|
||||
|
||||
@@ -241,10 +235,7 @@ Array [
|
||||
.onClick();
|
||||
});
|
||||
wrapper.update();
|
||||
const bulkActionsProps = wrapper
|
||||
.find(MenuItem)
|
||||
.last()
|
||||
.props();
|
||||
const bulkActionsProps = wrapper.find(MenuItem).last().props();
|
||||
|
||||
bulkActionsProps.onSelect(bulkActionsProps.eventKey);
|
||||
expect(mockedProps.bulkActions[0].onSelect.mock.calls[0])
|
||||
@@ -275,10 +266,7 @@ Array [
|
||||
.onClick();
|
||||
});
|
||||
wrapper.update();
|
||||
const bulkActionsProps = wrapper
|
||||
.find(MenuItem)
|
||||
.last()
|
||||
.props();
|
||||
const bulkActionsProps = wrapper.find(MenuItem).last().props();
|
||||
|
||||
bulkActionsProps.onSelect(bulkActionsProps.eventKey);
|
||||
expect(mockedProps.bulkActions[0].onSelect.mock.calls[0])
|
||||
@@ -383,11 +371,7 @@ describe('ListView with new UI filters', () => {
|
||||
wrapper.update();
|
||||
|
||||
act(() => {
|
||||
wrapper
|
||||
.find('[data-test="search-input"]')
|
||||
.last()
|
||||
.props()
|
||||
.onBlur();
|
||||
wrapper.find('[data-test="search-input"]').last().props().onBlur();
|
||||
});
|
||||
|
||||
expect(newFiltersProps.fetchData.mock.calls[0]).toMatchInlineSnapshot(`
|
||||
|
||||
@@ -20,7 +20,7 @@ import React from 'react';
|
||||
import { shallow, mount } from 'enzyme';
|
||||
import { Nav } from 'react-bootstrap';
|
||||
|
||||
import Menu from '../../../src/components/Menu/Menu';
|
||||
import Menu from 'src/components/Menu/Menu';
|
||||
|
||||
const defaultProps = {
|
||||
data: {
|
||||
|
||||
@@ -19,9 +19,9 @@
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
|
||||
import MetricOption from '../../../src/components/MetricOption';
|
||||
import ColumnTypeLabel from '../../../src/components/ColumnTypeLabel';
|
||||
import InfoTooltipWithTrigger from '../../../src/components/InfoTooltipWithTrigger';
|
||||
import MetricOption from 'src/components/MetricOption';
|
||||
import ColumnTypeLabel from 'src/components/ColumnTypeLabel';
|
||||
import InfoTooltipWithTrigger from 'src/components/InfoTooltipWithTrigger';
|
||||
|
||||
describe('MetricOption', () => {
|
||||
const defaultProps = {
|
||||
@@ -61,12 +61,7 @@ describe('MetricOption', () => {
|
||||
it('shows a label with metric_name when no verbose_name', () => {
|
||||
props.metric.verbose_name = null;
|
||||
wrapper = shallow(factory(props));
|
||||
expect(
|
||||
wrapper
|
||||
.find('.option-label')
|
||||
.first()
|
||||
.text(),
|
||||
).toBe('foo');
|
||||
expect(wrapper.find('.option-label').first().text()).toBe('foo');
|
||||
});
|
||||
it('shows only 1 InfoTooltipWithTrigger when no descr and no warning', () => {
|
||||
props.metric.warning_text = null;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
import React from 'react';
|
||||
|
||||
import ModalTrigger from '../../../src/components/ModalTrigger';
|
||||
import ModalTrigger from 'src/components/ModalTrigger';
|
||||
|
||||
describe('ModalTrigger', () => {
|
||||
const defaultProps = {
|
||||
|
||||
@@ -23,7 +23,7 @@ import { shallow } from 'enzyme';
|
||||
import VirtualizedSelect from 'react-virtualized-select';
|
||||
import Select, { Creatable } from 'react-select';
|
||||
|
||||
import OnPasteSelect from '../../../src/components/OnPasteSelect';
|
||||
import OnPasteSelect from 'src/components/OnPasteSelect';
|
||||
|
||||
const defaultProps = {
|
||||
onChange: sinon.spy(),
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
|
||||
import InfoTooltipWithTrigger from '../../../src/components/InfoTooltipWithTrigger';
|
||||
import OptionDescription from '../../../src/components/OptionDescription';
|
||||
import InfoTooltipWithTrigger from 'src/components/InfoTooltipWithTrigger';
|
||||
import OptionDescription from 'src/components/OptionDescription';
|
||||
|
||||
const defaultProps = {
|
||||
option: {
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
|
||||
import PopoverSection from '../../../src/components/PopoverSection';
|
||||
import PopoverSection from 'src/components/PopoverSection';
|
||||
|
||||
describe('PopoverSection', () => {
|
||||
const defaultProps = {
|
||||
|
||||
@@ -72,20 +72,14 @@ describe('SearchInput', () => {
|
||||
it('submits on search icon click', () => {
|
||||
typeSearchInput('bar');
|
||||
|
||||
wrapper
|
||||
.find('[data-test="search-submit"]')
|
||||
.props()
|
||||
.onClick();
|
||||
wrapper.find('[data-test="search-submit"]').props().onClick();
|
||||
|
||||
expect(defaultProps.onSubmit).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('clears on clear icon click', () => {
|
||||
const wrapper2 = factory({ value: 'fizz' });
|
||||
wrapper2
|
||||
.find('[data-test="search-clear"]')
|
||||
.props()
|
||||
.onClick();
|
||||
wrapper2.find('[data-test="search-clear"]').props().onClick();
|
||||
|
||||
expect(defaultProps.onClear).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -23,8 +23,8 @@ import sinon from 'sinon';
|
||||
import fetchMock from 'fetch-mock';
|
||||
import thunk from 'redux-thunk';
|
||||
|
||||
import TableSelector from 'src/components/TableSelector';
|
||||
import { initialState, tables } from '../sqllab/fixtures';
|
||||
import TableSelector from '../../../src/components/TableSelector';
|
||||
|
||||
describe('TableSelector', () => {
|
||||
let mockedProps;
|
||||
|
||||
@@ -21,7 +21,7 @@ import configureStore from 'redux-mock-store';
|
||||
import { shallow } from 'enzyme';
|
||||
|
||||
import { OverlayTrigger } from 'react-bootstrap';
|
||||
import URLShortLinkButton from '../../../src/components/URLShortLinkButton';
|
||||
import URLShortLinkButton from 'src/components/URLShortLinkButton';
|
||||
|
||||
describe('URLShortLinkButton', () => {
|
||||
const defaultProps = {
|
||||
|
||||
@@ -20,8 +20,8 @@ import React from 'react';
|
||||
import configureStore from 'redux-mock-store';
|
||||
import { shallow } from 'enzyme';
|
||||
|
||||
import URLShortLinkModal from '../../../src/components/URLShortLinkModal';
|
||||
import ModalTrigger from '../../../src/components/ModalTrigger';
|
||||
import URLShortLinkModal from 'src/components/URLShortLinkModal';
|
||||
import ModalTrigger from 'src/components/ModalTrigger';
|
||||
|
||||
describe('URLShortLinkModal', () => {
|
||||
const defaultProps = {
|
||||
|
||||
@@ -22,7 +22,7 @@ import sinon from 'sinon';
|
||||
import PropTypes from 'prop-types';
|
||||
import { shallow } from 'enzyme';
|
||||
|
||||
import VirtualizedRendererWrap from '../../../src/components/VirtualizedRendererWrap';
|
||||
import VirtualizedRendererWrap from 'src/components/VirtualizedRendererWrap';
|
||||
|
||||
const defaultProps = {
|
||||
focusedOption: { label: 'focusedOn', value: 'focusedOn' },
|
||||
|
||||
Reference in New Issue
Block a user