mirror of
https://github.com/apache/superset.git
synced 2026-04-19 16:14:52 +00:00
test: Fix act errors in DndColumnSelectControl tests (#22068)
This commit is contained in:
@@ -21,47 +21,53 @@ import { render, screen } from 'spec/helpers/testing-library';
|
|||||||
import userEvent from '@testing-library/user-event';
|
import userEvent from '@testing-library/user-event';
|
||||||
import Option from 'src/explore/components/controls/DndColumnSelectControl/Option';
|
import Option from 'src/explore/components/controls/DndColumnSelectControl/Option';
|
||||||
|
|
||||||
test('renders with default props', () => {
|
test('renders with default props', async () => {
|
||||||
const { container } = render(
|
const { container } = render(
|
||||||
<Option index={1} clickClose={jest.fn()}>
|
<Option index={1} clickClose={jest.fn()}>
|
||||||
Option
|
Option
|
||||||
</Option>,
|
</Option>,
|
||||||
);
|
);
|
||||||
expect(container).toBeInTheDocument();
|
expect(container).toBeInTheDocument();
|
||||||
expect(screen.getByRole('img', { name: 'x-small' })).toBeInTheDocument();
|
expect(
|
||||||
|
await screen.findByRole('img', { name: 'x-small' }),
|
||||||
|
).toBeInTheDocument();
|
||||||
expect(
|
expect(
|
||||||
screen.queryByRole('img', { name: 'caret-right' }),
|
screen.queryByRole('img', { name: 'caret-right' }),
|
||||||
).not.toBeInTheDocument();
|
).not.toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('renders with caret', () => {
|
test('renders with caret', async () => {
|
||||||
render(
|
render(
|
||||||
<Option index={1} clickClose={jest.fn()} withCaret>
|
<Option index={1} clickClose={jest.fn()} withCaret>
|
||||||
Option
|
Option
|
||||||
</Option>,
|
</Option>,
|
||||||
);
|
);
|
||||||
expect(screen.getByRole('img', { name: 'x-small' })).toBeInTheDocument();
|
expect(
|
||||||
expect(screen.getByRole('img', { name: 'caret-right' })).toBeInTheDocument();
|
await screen.findByRole('img', { name: 'x-small' }),
|
||||||
|
).toBeInTheDocument();
|
||||||
|
expect(
|
||||||
|
await screen.findByRole('img', { name: 'caret-right' }),
|
||||||
|
).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('renders with extra triangle', () => {
|
test('renders with extra triangle', async () => {
|
||||||
render(
|
render(
|
||||||
<Option index={1} clickClose={jest.fn()} isExtra>
|
<Option index={1} clickClose={jest.fn()} isExtra>
|
||||||
Option
|
Option
|
||||||
</Option>,
|
</Option>,
|
||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
screen.getByRole('button', { name: 'Show info tooltip' }),
|
await screen.findByRole('button', { name: 'Show info tooltip' }),
|
||||||
).toBeInTheDocument();
|
).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('triggers onClose', () => {
|
test('triggers onClose', async () => {
|
||||||
const clickClose = jest.fn();
|
const clickClose = jest.fn();
|
||||||
render(
|
render(
|
||||||
<Option index={1} clickClose={clickClose}>
|
<Option index={1} clickClose={clickClose}>
|
||||||
Option
|
Option
|
||||||
</Option>,
|
</Option>,
|
||||||
);
|
);
|
||||||
userEvent.click(screen.getByRole('img', { name: 'x-small' }));
|
userEvent.click(await screen.findByRole('img', { name: 'x-small' }));
|
||||||
expect(clickClose).toHaveBeenCalled();
|
expect(clickClose).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import { render, screen, fireEvent } from 'spec/helpers/testing-library';
|
|||||||
import { DndItemType } from 'src/explore/components/DndItemType';
|
import { DndItemType } from 'src/explore/components/DndItemType';
|
||||||
import OptionWrapper from 'src/explore/components/controls/DndColumnSelectControl/OptionWrapper';
|
import OptionWrapper from 'src/explore/components/controls/DndColumnSelectControl/OptionWrapper';
|
||||||
|
|
||||||
test('renders with default props', () => {
|
test('renders with default props', async () => {
|
||||||
const { container } = render(
|
const { container } = render(
|
||||||
<OptionWrapper
|
<OptionWrapper
|
||||||
index={1}
|
index={1}
|
||||||
@@ -33,10 +33,12 @@ test('renders with default props', () => {
|
|||||||
{ useDnd: true },
|
{ useDnd: true },
|
||||||
);
|
);
|
||||||
expect(container).toBeInTheDocument();
|
expect(container).toBeInTheDocument();
|
||||||
expect(screen.getByRole('img', { name: 'x-small' })).toBeInTheDocument();
|
expect(
|
||||||
|
await screen.findByRole('img', { name: 'x-small' }),
|
||||||
|
).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('triggers onShiftOptions on drop', () => {
|
test('triggers onShiftOptions on drop', async () => {
|
||||||
const onShiftOptions = jest.fn();
|
const onShiftOptions = jest.fn();
|
||||||
render(
|
render(
|
||||||
<>
|
<>
|
||||||
@@ -58,7 +60,7 @@ test('triggers onShiftOptions on drop', () => {
|
|||||||
{ useDnd: true },
|
{ useDnd: true },
|
||||||
);
|
);
|
||||||
|
|
||||||
fireEvent.dragStart(screen.getByText('Option 1'));
|
fireEvent.dragStart(await screen.findByText('Option 1'));
|
||||||
fireEvent.drop(screen.getByText('Option 2'));
|
fireEvent.drop(await screen.findByText('Option 2'));
|
||||||
expect(onShiftOptions).toHaveBeenCalled();
|
expect(onShiftOptions).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user