An open source design system that's fully customizable and agent ready
TypeScript
test(Table): the re-sort cases read 1,000 rows without the hidden check (#9970)
Christopher Chedeauca2b80bc8eb2
diff --git a/packages/core/src/Table/Table.perf.test.tsx b/packages/core/src/Table/Table.perf.test.tsxindex abc7ff9f3d..fe750218bb 100644--- a/packages/core/src/Table/Table.perf.test.tsx+++ b/packages/core/src/Table/Table.perf.test.tsx@@ -582,6 +582,10 @@ describe('Table render performance', () => {describe('re-sort', () => {const sortedRows = createTestData(1000);const reversedRows = [...sortedRows].reverse();+ // By default, a role query reads each row's computed style to check that+ // the row is not hidden. Over 1,000 rows in jsdom that costs seconds. These+ // cases assert which rows come first, so they skip that check.+ const rows = () => screen.getAllByRole('row', {hidden: true});function renderSortable(renderCell: (row: TestRow) => string,@@ -618,7 +622,7 @@ describe('re-sort', () => {resort();expect(renderCell).not.toHaveBeenCalled();- expect(screen.getAllByRole('row')[1]).toHaveTextContent('Item 999');+ expect(rows()[1]).toHaveTextContent('Item 999');});it('re-renders the rows when a plugin reads the row index', () => {@@ -635,7 +639,7 @@ describe('re-sort', () => {resort();expect(renderCell).toHaveBeenCalledTimes(1000);- const [, first, second] = screen.getAllByRole('row');+ const [, first, second] = rows();expect(first).toHaveTextContent('Item 999');expect(first).toHaveAttribute('data-odd', 'false');expect(second).toHaveAttribute('data-odd', 'true');