Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Fix act errors in DndColumnSelectControl tests #22068

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,47 +21,53 @@ import { render, screen } from 'spec/helpers/testing-library';
import userEvent from '@testing-library/user-event';
import Option from 'src/explore/components/controls/DndColumnSelectControl/Option';

test('renders with default props', () => {
test('renders with default props', async () => {
const { container } = render(
<Option index={1} clickClose={jest.fn()}>
Option
</Option>,
);
expect(container).toBeInTheDocument();
expect(screen.getByRole('img', { name: 'x-small' })).toBeInTheDocument();
expect(
await screen.findByRole('img', { name: 'x-small' }),
).toBeInTheDocument();
expect(
screen.queryByRole('img', { name: 'caret-right' }),
).not.toBeInTheDocument();
});

test('renders with caret', () => {
test('renders with caret', async () => {
render(
<Option index={1} clickClose={jest.fn()} withCaret>
Option
</Option>,
);
expect(screen.getByRole('img', { name: 'x-small' })).toBeInTheDocument();
expect(screen.getByRole('img', { name: 'caret-right' })).toBeInTheDocument();
expect(
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(
<Option index={1} clickClose={jest.fn()} isExtra>
Option
</Option>,
);
expect(
screen.getByRole('button', { name: 'Show info tooltip' }),
await screen.findByRole('button', { name: 'Show info tooltip' }),
).toBeInTheDocument();
});

test('triggers onClose', () => {
test('triggers onClose', async () => {
const clickClose = jest.fn();
render(
<Option index={1} clickClose={clickClose}>
Option
</Option>,
);
userEvent.click(screen.getByRole('img', { name: 'x-small' }));
userEvent.click(await screen.findByRole('img', { name: 'x-small' }));
expect(clickClose).toHaveBeenCalled();
});
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { render, screen, fireEvent } from 'spec/helpers/testing-library';
import { DndItemType } from 'src/explore/components/DndItemType';
import OptionWrapper from 'src/explore/components/controls/DndColumnSelectControl/OptionWrapper';

test('renders with default props', () => {
test('renders with default props', async () => {
const { container } = render(
<OptionWrapper
index={1}
Expand All @@ -33,10 +33,12 @@ test('renders with default props', () => {
{ useDnd: true },
);
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();
render(
<>
Expand All @@ -58,7 +60,7 @@ test('triggers onShiftOptions on drop', () => {
{ useDnd: true },
);

fireEvent.dragStart(screen.getByText('Option 1'));
fireEvent.drop(screen.getByText('Option 2'));
fireEvent.dragStart(await screen.findByText('Option 1'));
fireEvent.drop(await screen.findByText('Option 2'));
expect(onShiftOptions).toHaveBeenCalled();
});