fix(test): use getByRole for table headers to fix CI failures with antd 5.27.6

Ant Design Table v5.27.6 renders measurement cells containing duplicate
header text, breaking tests using getByText(). Changed to getByRole('columnheader')
for semantic, robust queries.

Fixes:
- DatasetList.permissions.test.tsx: 2 locations (lines 67, 137)
- DatasetList.listview.test.tsx: 12 locations (lines 158-178, 276, 309, 335, 1115)

All 50 tests now passing with antd@5.27.6.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Joe Li
2025-11-12 11:31:19 -08:00
parent 8952e80ffd
commit 825b7edcc0
2 changed files with 39 additions and 13 deletions

View File

@@ -155,13 +155,27 @@ test('renders all required column headers', async () => {
const table = screen.getByTestId('listview-table');
// Verify all column headers are present
expect(within(table).getByText(/Name/i)).toBeInTheDocument();
expect(within(table).getByText(/Type/i)).toBeInTheDocument();
expect(within(table).getByText(/Database/i)).toBeInTheDocument();
expect(within(table).getByText(/Schema/i)).toBeInTheDocument();
expect(within(table).getByText(/Owners/i)).toBeInTheDocument();
expect(within(table).getByText(/Last modified/i)).toBeInTheDocument();
expect(within(table).getByText(/Actions/i)).toBeInTheDocument();
expect(
within(table).getByRole('columnheader', { name: /Name/i }),
).toBeInTheDocument();
expect(
within(table).getByRole('columnheader', { name: /Type/i }),
).toBeInTheDocument();
expect(
within(table).getByRole('columnheader', { name: /Database/i }),
).toBeInTheDocument();
expect(
within(table).getByRole('columnheader', { name: /Schema/i }),
).toBeInTheDocument();
expect(
within(table).getByRole('columnheader', { name: /Owners/i }),
).toBeInTheDocument();
expect(
within(table).getByRole('columnheader', { name: /Last modified/i }),
).toBeInTheDocument();
expect(
within(table).getByRole('columnheader', { name: /Actions/i }),
).toBeInTheDocument();
});
test('displays dataset name in Name column', async () => {
@@ -259,7 +273,9 @@ test('sorting by Name column updates API call with sort parameter', async () =>
});
const table = screen.getByTestId('listview-table');
const nameHeader = within(table).getByText(/Name/i);
const nameHeader = within(table).getByRole('columnheader', {
name: /Name/i,
});
// Record initial calls
const initialCalls = fetchMock.calls(API_ENDPOINTS.DATASETS).length;
@@ -290,7 +306,9 @@ test('sorting by Database column updates sort parameter', async () => {
});
const table = screen.getByTestId('listview-table');
const databaseHeader = within(table).getByText(/Database/i);
const databaseHeader = within(table).getByRole('columnheader', {
name: /Database/i,
});
const initialCalls = fetchMock.calls(API_ENDPOINTS.DATASETS).length;
@@ -314,7 +332,9 @@ test('sorting by Last modified column updates sort parameter', async () => {
});
const table = screen.getByTestId('listview-table');
const modifiedHeader = within(table).getByText(/Last modified/i);
const modifiedHeader = within(table).getByRole('columnheader', {
name: /Last modified/i,
});
const initialCalls = fetchMock.calls(API_ENDPOINTS.DATASETS).length;
@@ -1092,7 +1112,9 @@ test('sort order persists after deleting a dataset', async () => {
});
const table = screen.getByTestId('listview-table');
const nameHeader = within(table).getByText(/Name/i);
const nameHeader = within(table).getByRole('columnheader', {
name: /Name/i,
});
// Record initial API calls count
const initialCalls = fetchMock.calls(API_ENDPOINTS.DATASETS).length;

View File

@@ -64,7 +64,9 @@ test('admin users see all UI elements', async () => {
// Admin should see actions column
await waitFor(() => {
const table = screen.getByTestId('listview-table');
expect(within(table).getByText(/Actions/i)).toBeInTheDocument();
expect(
within(table).getByRole('columnheader', { name: /Actions/i }),
).toBeInTheDocument();
});
});
@@ -134,7 +136,9 @@ test('write users see Actions column', async () => {
await waitFor(() => {
const table = screen.getByTestId('listview-table');
expect(within(table).getByText(/Actions/i)).toBeInTheDocument();
expect(
within(table).getByRole('columnheader', { name: /Actions/i }),
).toBeInTheDocument();
});
});