This is an automated email from the ASF dual-hosted git repository. jli pushed a commit to branch feat-chart-list-rtl-tests in repository https://gitbox.apache.org/repos/asf/superset.git
commit 74001059bb1b0a6c7bd62f41f1ef08120ac8bdc0 Author: Joe Li <[email protected]> AuthorDate: Fri Feb 6 15:47:00 2026 -0800 fix(chart-list): reduce test flakiness and improve selector resilience - Add missing await to userEvent.click() calls in sort column test - Replace fragile .ant-alert-close-icon querySelector with role-based query - Remove no-op waitFor wrapper around negative assertion Co-Authored-By: Claude Opus 4.6 <[email protected]> --- .../src/pages/ChartList/ChartList.cardview.test.tsx | 11 ++++++----- .../src/pages/ChartList/ChartList.listview.test.tsx | 10 ++++------ 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/superset-frontend/src/pages/ChartList/ChartList.cardview.test.tsx b/superset-frontend/src/pages/ChartList/ChartList.cardview.test.tsx index d6369376925..75e8f96c790 100644 --- a/superset-frontend/src/pages/ChartList/ChartList.cardview.test.tsx +++ b/superset-frontend/src/pages/ChartList/ChartList.cardview.test.tsx @@ -17,7 +17,7 @@ * under the License. */ import fetchMock from 'fetch-mock'; -import { fireEvent, screen, waitFor } from 'spec/helpers/testing-library'; +import { fireEvent, screen, waitFor, within } from 'spec/helpers/testing-library'; import { isFeatureEnabled } from '@superset-ui/core'; import { mockCharts, @@ -475,10 +475,11 @@ describe('ChartList Card View Tests', () => { expect(screen.getByTestId('bulk-select-controls')).toBeInTheDocument(); }); - // Click the X button to close bulk select (look for close icon in bulk select bar) - const closeButton = document.querySelector( - '.ant-alert-close-icon', - ) as HTMLButtonElement; + // Click the X button to close bulk select + const bulkSelectBar = screen.getByTestId('bulk-select-controls'); + const closeButton = within(bulkSelectBar).getByRole('button', { + name: /close/i, + }); fireEvent.click(closeButton); // Verify bulk select controls are gone diff --git a/superset-frontend/src/pages/ChartList/ChartList.listview.test.tsx b/superset-frontend/src/pages/ChartList/ChartList.listview.test.tsx index f444f3534fb..d90abbe05cc 100644 --- a/superset-frontend/src/pages/ChartList/ChartList.listview.test.tsx +++ b/superset-frontend/src/pages/ChartList/ChartList.listview.test.tsx @@ -86,9 +86,7 @@ test('renders table in list view', async () => { }); // Verify cards are not rendered in list view - await waitFor(() => { - expect(screen.queryByTestId('styled-card')).not.toBeInTheDocument(); - }); + expect(screen.queryByTestId('styled-card')).not.toBeInTheDocument(); }); test('displays dataset names with and without schema prefix', async () => { @@ -235,7 +233,7 @@ test('sorts table when clicking column headers', async () => { expect(sortableHeaders).toHaveLength(3); const nameHeader = within(table).getByTitle('Name'); - userEvent.click(nameHeader); + await userEvent.click(nameHeader); await waitFor(() => { const sortCalls = fetchMock.callHistory @@ -248,7 +246,7 @@ test('sorts table when clicking column headers', async () => { }); const typeHeader = within(table).getByTitle('Type'); - userEvent.click(typeHeader); + await userEvent.click(typeHeader); await waitFor(() => { const typeSortCalls = fetchMock.callHistory @@ -261,7 +259,7 @@ test('sorts table when clicking column headers', async () => { }); const lastModifiedHeader = within(table).getByTitle('Last modified'); - userEvent.click(lastModifiedHeader); + await userEvent.click(lastModifiedHeader); await waitFor(() => { const lastModifiedSortCalls = fetchMock.callHistory
