diff --git a/superset-frontend/src/SqlLab/components/SqlEditorTabHeader/SqlEditorTabHeader.test.tsx b/superset-frontend/src/SqlLab/components/SqlEditorTabHeader/SqlEditorTabHeader.test.tsx index 8ce4dc1e8bfc..0bc9c8b3467d 100644 --- a/superset-frontend/src/SqlLab/components/SqlEditorTabHeader/SqlEditorTabHeader.test.tsx +++ b/superset-frontend/src/SqlLab/components/SqlEditorTabHeader/SqlEditorTabHeader.test.tsx @@ -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; }; @@ -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(), ); @@ -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(), ); @@ -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(), ); @@ -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(), ); @@ -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(), ); @@ -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(), ); @@ -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(), ); @@ -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(), ); @@ -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(), ); @@ -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(), ); @@ -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(), ); @@ -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(), ); diff --git a/superset-frontend/src/components/RowCountLabel/RowCountLabel.test.tsx b/superset-frontend/src/components/RowCountLabel/RowCountLabel.test.tsx index 32906e5f20c4..cbc6278ddaf8 100644 --- a/superset-frontend/src/components/RowCountLabel/RowCountLabel.test.tsx +++ b/superset-frontend/src/components/RowCountLabel/RowCountLabel.test.tsx @@ -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(); 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(); 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(); 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(); }); @@ -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(); 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(); }); diff --git a/superset-frontend/src/features/datasets/AddDataset/Footer/Footer.test.tsx b/superset-frontend/src/features/datasets/AddDataset/Footer/Footer.test.tsx index c64811d7a1f8..bcfc649bc221 100644 --- a/superset-frontend/src/features/datasets/AddDataset/Footer/Footer.test.tsx +++ b/superset-frontend/src/features/datasets/AddDataset/Footer/Footer.test.tsx @@ -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({ diff --git a/superset-frontend/src/pages/Home/Home.test.tsx b/superset-frontend/src/pages/Home/Home.test.tsx index 75dc4ee0c754..7ed8cac53478 100644 --- a/superset-frontend/src/pages/Home/Home.test.tsx +++ b/superset-frontend/src/pages/Home/Home.test.tsx @@ -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 },