Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/table/__tests__/a11y.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,16 @@
expect(wrapper.find('[role=table]')!.getElement().getAttribute('aria-rowcount')).toEqual('-1');
});

test('aria-rowcount should be -1 if the table is loading', () => {
const wrapper = renderTableWrapper({ loading: true, loadingText: 'Loading items', totalItemsCount: 500 });
expect(wrapper.find('[role=table]')!.getElement().getAttribute('aria-rowcount')).toEqual('-1');

Check failure on line 135 in src/table/__tests__/a11y.test.tsx

View workflow job for this annotation

GitHub Actions / build / build

labels › rows › aria-rowcount should be -1 if the table is loading

expect(received).toEqual(expected) // deep equality Expected: "-1" Received: "0" at Object.<anonymous> (src/table/__tests__/a11y.test.tsx:135:88)

Check failure on line 135 in src/table/__tests__/a11y.test.tsx

View workflow job for this annotation

GitHub Actions / dry-run / Components unit tests

labels › rows › aria-rowcount should be -1 if the table is loading

expect(received).toEqual(expected) // deep equality Expected: "-1" Received: "0" at Object.<anonymous> (src/table/__tests__/a11y.test.tsx:135:88)
});

test('aria-rowcount should be 2 (header and empty state cell) if the empty state is rendered', () => {
const wrapper = renderTableWrapper({ items: [], totalItemsCount: 500 });
expect(wrapper.find('[role=table]')!.getElement().getAttribute('aria-rowcount')).toEqual('2');
});

test.each([undefined, 21])('sets aria-rowindex on table rows', firstIndex => {
const expectedFirstIndex = firstIndex ?? 1;
const wrapper = renderTableWrapper({ firstIndex });
Expand Down
2 changes: 1 addition & 1 deletion src/table/internal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ const InternalTable = React.forwardRef(
)}
{...getTableRoleProps({
tableRole,
totalItemsCount,
totalItemsCount: loading ? -1 : allItems.length === 0 ? 1 : totalItemsCount,
totalColumnsCount: totalColumnsCount,
ariaLabel: ariaLabels?.tableLabel,
ariaLabelledby,
Expand Down
Loading