This is an automated email from the ASF dual-hosted git repository.

sadpandajoe pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 2872d16ee65 test(frontend): await the userEvent calls that needed 
restructuring (#44799)
2872d16ee65 is described below

commit 2872d16ee659e14c22cefc2e57450a9ee4dd2b2e
Author: Sepuri Sai Krishna <[email protected]>
AuthorDate: Sat Oct 3 03:26:47 2026 +0530

    test(frontend): await the userEvent calls that needed restructuring (#44799)
---
 .../SqlEditorTabHeader/SqlEditorTabHeader.test.tsx | 28 +++++++++++-----------
 .../RowCountLabel/RowCountLabel.test.tsx           | 16 ++++++-------
 .../datasets/AddDataset/Footer/Footer.test.tsx     |  5 +---
 superset-frontend/src/pages/Home/Home.test.tsx     |  2 +-
 4 files changed, 24 insertions(+), 27 deletions(-)

diff --git 
a/superset-frontend/src/SqlLab/components/SqlEditorTabHeader/SqlEditorTabHeader.test.tsx
 
b/superset-frontend/src/SqlLab/components/SqlEditorTabHeader/SqlEditorTabHeader.test.tsx
index 8ce4dc1e8bf..0bc9c8b3467 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 32906e5f20c..cbc6278ddaf 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(<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();
 });
 
@@ -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();
 });
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 c64811d7a1f..bcfc649bc22 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 bbe2419f90e..bdeefa84a70 100644
--- a/superset-frontend/src/pages/Home/Home.test.tsx
+++ b/superset-frontend/src/pages/Home/Home.test.tsx
@@ -287,9 +287,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 },

Reply via email to