You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ly...@apache.org on 2022/09/08 18:06:03 UTC

[superset] 01/01: 22 act errors removed from LeftPanel test

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

lyndsi pushed a commit to branch lyndsi/leftpanel-act-cleanup
in repository https://gitbox.apache.org/repos/asf/superset.git

commit a618c83487d27ccd72e2f9f1c5adcfc6bb708256
Author: lyndsiWilliams <kc...@gmail.com>
AuthorDate: Thu Sep 8 13:05:40 2022 -0500

    22 act errors removed from LeftPanel test
---
 .../AddDataset/LeftPanel/LeftPanel.test.tsx        | 29 +++++++++++++---------
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/superset-frontend/src/views/CRUD/data/dataset/AddDataset/LeftPanel/LeftPanel.test.tsx b/superset-frontend/src/views/CRUD/data/dataset/AddDataset/LeftPanel/LeftPanel.test.tsx
index 4e9d1a89ca..9027b232af 100644
--- a/superset-frontend/src/views/CRUD/data/dataset/AddDataset/LeftPanel/LeftPanel.test.tsx
+++ b/superset-frontend/src/views/CRUD/data/dataset/AddDataset/LeftPanel/LeftPanel.test.tsx
@@ -21,7 +21,6 @@ import { SupersetClient } from '@superset-ui/core';
 import userEvent from '@testing-library/user-event';
 import { render, screen, waitFor } from 'spec/helpers/testing-library';
 import LeftPanel from 'src/views/CRUD/data/dataset/AddDataset/LeftPanel';
-import { act } from 'react-dom/test-utils';
 
 describe('LeftPanel', () => {
   const mockFun = jest.fn();
@@ -160,17 +159,21 @@ describe('LeftPanel', () => {
       },
     } as any);
 
-  it('should render', () => {
+  test('should render', async () => {
     const { container } = render(<LeftPanel setDataset={mockFun} />, {
       useRedux: true,
     });
+
+    expect(
+      await screen.findByText(/select database & schema/i),
+    ).toBeInTheDocument();
     expect(container).toBeInTheDocument();
   });
 
-  it('should render tableselector and databaselector container and selects', () => {
+  test('should render tableselector and databaselector container and selects', async () => {
     render(<LeftPanel setDataset={mockFun} />, { useRedux: true });
 
-    expect(screen.getByText(/select database & schema/i)).toBeVisible();
+    expect(await screen.findByText(/select database & schema/i)).toBeVisible();
 
     const databaseSelect = screen.getByRole('combobox', {
       name: 'Select database or type database name',
@@ -181,12 +184,18 @@ describe('LeftPanel', () => {
     expect(databaseSelect).toBeInTheDocument();
     expect(schemaSelect).toBeInTheDocument();
   });
-  it('does not render blank state if there is nothing selected', () => {
+
+  test('does not render blank state if there is nothing selected', async () => {
     render(<LeftPanel setDataset={mockFun} />, { useRedux: true });
+
+    expect(
+      await screen.findByText(/select database & schema/i),
+    ).toBeInTheDocument();
     const emptyState = screen.queryByRole('img', { name: /empty/i });
     expect(emptyState).not.toBeInTheDocument();
   });
-  it('renders list of options when user clicks on schema', async () => {
+
+  test('renders list of options when user clicks on schema', async () => {
     render(<LeftPanel setDataset={mockFun} schema="schema_a" dbId={1} />, {
       useRedux: true,
     });
@@ -197,9 +206,7 @@ describe('LeftPanel', () => {
     userEvent.click(databaseSelect);
     expect(await screen.findByText('test-postgres')).toBeInTheDocument();
 
-    act(() => {
-      userEvent.click(screen.getAllByText('test-postgres')[0]);
-    });
+    userEvent.click(screen.getAllByText('test-postgres')[0]);
     const tableSelect = screen.getByRole('combobox', {
       name: /select schema or type schema name/i,
     });
@@ -217,11 +224,9 @@ describe('LeftPanel', () => {
     ).toBeInTheDocument();
 
     SupersetClientGet.mockImplementation(getTableMockFunction);
-    act(() => {
-      userEvent.click(screen.getAllByText('public')[1]);
-    });
 
     // Todo: (Phillip) finish testing for showing list of options once table is implemented
+    // userEvent.click(screen.getAllByText('public')[1]);
     // expect(screen.getByTestId('options-list')).toBeInTheDocument();
   });
 });