Skip to content
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 @@ -57,10 +57,10 @@ const setup = (queryEditor: QueryEditor, store?: Store) =>

// Renders the header and opens its "..." dropdown menu, returning the store so
// each test can assert on the actions it dispatches.
const openTabDropdown = () => {
const openTabDropdown = async () => {
const store = mockStore(initialState);
const { getByTestId } = setup(defaultQueryEditor, store);
userEvent.click(getByTestId('dropdown-trigger'));
await userEvent.click(getByTestId('dropdown-trigger'));
return store;
};

Expand Down Expand Up @@ -123,7 +123,7 @@ test('renders current name for unrelated unsaved changes', () => {
});

test('should dispatch removeQueryEditor action', async () => {
const store = openTabDropdown();
const store = await openTabDropdown();
await waitFor(() =>
expect(screen.getByTestId('close-tab-menu-option')).toBeInTheDocument(),
);
Expand All @@ -140,7 +140,7 @@ test('should dispatch removeQueryEditor action', async () => {
});

test('should dispatch queryEditorSetTitle action', async () => {
const store = openTabDropdown();
const store = await openTabDropdown();
await waitFor(() =>
expect(screen.getByTestId('rename-tab-menu-option')).toBeInTheDocument(),
);
Expand All @@ -164,7 +164,7 @@ test('should dispatch queryEditorSetTitle action', async () => {
});

test('prefills the rename input with the current tab name', async () => {
openTabDropdown();
await openTabDropdown();
await waitFor(() =>
expect(screen.getByTestId('rename-tab-menu-option')).toBeInTheDocument(),
);
Expand All @@ -175,7 +175,7 @@ test('prefills the rename input with the current tab name', async () => {
});

test('focuses the rename input when the modal opens', async () => {
openTabDropdown();
await openTabDropdown();
await waitFor(() =>
expect(screen.getByTestId('rename-tab-menu-option')).toBeInTheDocument(),
);
Expand All @@ -186,7 +186,7 @@ test('focuses the rename input when the modal opens', async () => {
});

test('disables Save when the input is empty or whitespace', async () => {
openTabDropdown();
await openTabDropdown();
await waitFor(() =>
expect(screen.getByTestId('rename-tab-menu-option')).toBeInTheDocument(),
);
Expand All @@ -198,7 +198,7 @@ test('disables Save when the input is empty or whitespace', async () => {
});

test('does not dispatch or dismiss on Enter when the input is empty', async () => {
const store = openTabDropdown();
const store = await openTabDropdown();
await waitFor(() =>
expect(screen.getByTestId('rename-tab-menu-option')).toBeInTheDocument(),
);
Expand All @@ -218,7 +218,7 @@ test('does not dispatch or dismiss on Enter when the input is empty', async () =
});

test('does not dispatch a title change when the modal is cancelled', async () => {
const store = openTabDropdown();
const store = await openTabDropdown();
await waitFor(() =>
expect(screen.getByTestId('rename-tab-menu-option')).toBeInTheDocument(),
);
Expand All @@ -232,7 +232,7 @@ test('does not dispatch a title change when the modal is cancelled', async () =>
});

test('does not dispatch a title change when dismissed with the close button', async () => {
const store = openTabDropdown();
const store = await openTabDropdown();
await waitFor(() =>
expect(screen.getByTestId('rename-tab-menu-option')).toBeInTheDocument(),
);
Expand All @@ -246,7 +246,7 @@ test('does not dispatch a title change when dismissed with the close button', as
});

test('returns focus to the menu-dots trigger after the modal is cancelled', async () => {
openTabDropdown();
await openTabDropdown();
await waitFor(() =>
expect(screen.getByTestId('rename-tab-menu-option')).toBeInTheDocument(),
);
Expand All @@ -261,7 +261,7 @@ test('returns focus to the menu-dots trigger after the modal is cancelled', asyn
});

test('returns focus to the menu-dots trigger after a successful rename', async () => {
openTabDropdown();
await openTabDropdown();
await waitFor(() =>
expect(screen.getByTestId('rename-tab-menu-option')).toBeInTheDocument(),
);
Expand All @@ -277,7 +277,7 @@ test('returns focus to the menu-dots trigger after a successful rename', async (
});

test('should dispatch removeAllOtherQueryEditors action', async () => {
const store = openTabDropdown();
const store = await openTabDropdown();
await waitFor(() =>
expect(screen.getByTestId('close-tab-menu-option')).toBeInTheDocument(),
);
Expand All @@ -299,7 +299,7 @@ test('should dispatch removeAllOtherQueryEditors action', async () => {
});

test('should dispatch cloneQueryToNewTab action', async () => {
const store = openTabDropdown();
const store = await openTabDropdown();
await waitFor(() =>
expect(screen.getByTestId('close-tab-menu-option')).toBeInTheDocument(),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,27 @@ import { render, screen, userEvent } from 'spec/helpers/testing-library';

import RowCountLabel from '.';

test('RowCountLabel renders singular result', () => {
test('RowCountLabel renders singular result', async () => {
render(<RowCountLabel rowcount={1} limit={100} />);
const expectedText = '1 row';
expect(screen.getByText(expectedText)).toBeInTheDocument();
userEvent.hover(screen.getByText(expectedText));
await userEvent.hover(screen.getByText(expectedText));
expect(screen.queryByRole('tooltip')).not.toBeInTheDocument();
});

test('RowCountLabel renders plural result', () => {
test('RowCountLabel renders plural result', async () => {
render(<RowCountLabel rowcount={2} limit={100} />);
const expectedText = '2 rows';
expect(screen.getByText(expectedText)).toBeInTheDocument();
userEvent.hover(screen.getByText(expectedText));
await userEvent.hover(screen.getByText(expectedText));
expect(screen.queryByRole('tooltip')).not.toBeInTheDocument();
});

test('RowCountLabel renders formatted result', () => {
test('RowCountLabel renders formatted result', async () => {
render(<RowCountLabel rowcount={1000} limit={10000} />);
const expectedText = '1k rows';
expect(screen.getByText(expectedText)).toBeInTheDocument();
userEvent.hover(screen.getByText(expectedText));
await userEvent.hover(screen.getByText(expectedText));
expect(screen.queryByRole('tooltip')).not.toBeInTheDocument();
});

Expand Down Expand Up @@ -69,10 +69,10 @@ test('RowCountLabel uses a caller-provided limitReachedMessage instead of the de
expect(tooltip).not.toHaveTextContent('The row limit set for the chart');
});

test('RowCountLabel renders loading', () => {
test('RowCountLabel renders loading', async () => {
render(<RowCountLabel loading />);
const expectedText = 'Loading...';
expect(screen.getByText(expectedText)).toBeInTheDocument();
userEvent.hover(screen.getByText(expectedText));
await userEvent.hover(screen.getByText(expectedText));
expect(screen.queryByRole('tooltip')).not.toBeInTheDocument();
});
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,7 @@ describe('Footer', () => {
await userEvent.click(dropdownTrigger);

// Click the "Create dataset" option
await waitFor(() => {
const datasetOnlyOption = screen.getByText('Create dataset');
userEvent.click(datasetOnlyOption);
});
await userEvent.click(await screen.findByText('Create dataset'));

await waitFor(() => {
expect(mockCreateResource).toHaveBeenCalledWith({
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/pages/Home/Home.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,9 @@ test('With toggle switch - does not show thumbnails when switch is off', async (
await renderWelcome();
const toggle = await screen.findByRole('switch', {}, { timeout: 10000 });

await userEvent.click(toggle);
await waitFor(
() => {
userEvent.click(toggle);
expect(screen.queryByAltText('Thumbnails')).not.toBeInTheDocument();
},
{ timeout: 10000 },
Expand Down
Loading