diff --git a/src/DataGrid.tsx b/src/DataGrid.tsx index dc6f6aeb58..5eb99d289d 100644 --- a/src/DataGrid.tsx +++ b/src/DataGrid.tsx @@ -205,6 +205,7 @@ export interface DataGridProps extends Sha /** @default 'ltr' */ direction?: Maybe; 'data-testid'?: Maybe; + 'data-cy'?: Maybe; } /** @@ -264,7 +265,8 @@ function DataGrid( 'aria-description': ariaDescription, 'aria-describedby': ariaDescribedBy, 'aria-rowcount': rawAriaRowCount, - 'data-testid': testId + 'data-testid': testId, + 'data-cy': dataCy } = props; /** @@ -1122,6 +1124,7 @@ function DataGrid( onScroll={handleScroll} onKeyDown={handleKeyDown} data-testid={testId} + data-cy={dataCy} > diff --git a/test/browser/label.test.ts b/test/browser/label.test.ts index e75eb360ca..7a10790111 100644 --- a/test/browser/label.test.ts +++ b/test/browser/label.test.ts @@ -7,7 +7,9 @@ test('should set label and description', () => { 'aria-label': 'label', 'aria-labelledby': 'labelledby', 'aria-description': 'description', - 'aria-describedby': 'describedby' + 'aria-describedby': 'describedby', + 'data-testid': 'testid', + 'data-cy': 'cy' }); const grid = getGrid().element(); @@ -15,4 +17,6 @@ test('should set label and description', () => { expect(grid).toHaveAttribute('aria-labelledby', 'labelledby'); expect(grid).toHaveAttribute('aria-description', 'description'); expect(grid).toHaveAttribute('aria-describedby', 'describedby'); + expect(grid).toHaveAttribute('data-testid', 'testid'); + expect(grid).toHaveAttribute('data-cy', 'cy'); });