Skip to content

Commit 83c7554

Browse files
committed
Add accessibility test to the row grouping feature
1 parent c2cd9e9 commit 83c7554

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

packages/x-data-grid-premium/src/tests/rowGrouping.DataGridPremium.test.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
getColumnValues,
1515
getCell,
1616
getSelectByName,
17+
getRow,
1718
} from 'test/utils/helperFn';
1819
import { expect } from 'chai';
1920
import {
@@ -2762,6 +2763,27 @@ describe('<DataGridPremium /> - Row grouping', () => {
27622763
});
27632764
});
27642765

2766+
describe('accessibility', () => {
2767+
it('should add necessary treegrid aria attributes to the rows', () => {
2768+
render(
2769+
<Test
2770+
initialState={{ rowGrouping: { model: ['category1', 'category2'] } }}
2771+
defaultGroupingExpansionDepth={-1}
2772+
rowGroupingColumnMode="multiple"
2773+
/>,
2774+
);
2775+
2776+
expect(getRow(0).getAttribute('aria-level')).to.equal('1'); // Cat A
2777+
expect(getRow(1).getAttribute('aria-level')).to.equal('2'); // Cat 1
2778+
expect(getRow(1).getAttribute('aria-posinset')).to.equal('1');
2779+
expect(getRow(1).getAttribute('aria-setsize')).to.equal('2'); // Cat A has Cat 1 & Cat 2
2780+
expect(getRow(2).getAttribute('aria-level')).to.equal('3'); // Cat 1 row
2781+
expect(getRow(3).getAttribute('aria-posinset')).to.equal('2'); // Cat 2
2782+
expect(getRow(4).getAttribute('aria-posinset')).to.equal('1'); // Cat 2 row
2783+
expect(getRow(4).getAttribute('aria-setsize')).to.equal('2'); // Cat 2 has 2 rows
2784+
});
2785+
});
2786+
27652787
// See https://github.com/mui/mui-x/issues/8626
27662788
it('should properly update the rows when they change', async () => {
27672789
render(

0 commit comments

Comments
 (0)