Skip to content

Commit

Permalink
add e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
dtassone committed Jun 7, 2021
1 parent 0dceda2 commit 8bb1cd6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/e2e/fixtures/DataGrid/ConcurrentReactUpdate.tsx
@@ -0,0 +1,15 @@
import * as React from 'react';
import { XGrid } from '@material-ui/x-grid';

export function DeferRenderingSnap() {
const [deferRows, setRows] = React.useState<any>([]);
const [deferColumns] = React.useState([{ field: 'id', headerName: 'Id', width: 100 }]);

React.useEffect(() => {
setTimeout(() => setRows(() => []), 0);
setTimeout(() => setRows(() => []), 0);
setTimeout(() => setRows(() => [{ id: '1' }, { id: '2' }]), 1);
}, []);

return <XGrid autoHeight columns={deferColumns} rows={deferRows} />;
}
11 changes: 11 additions & 0 deletions test/e2e/index.test.ts
@@ -1,5 +1,6 @@
import { expect } from 'chai';
import * as playwright from 'playwright';
import { raf } from 'test/utils/helperFn';

function sleep(timeoutMS: number): Promise<void> {
return new Promise((resolve) => {
Expand Down Expand Up @@ -105,5 +106,15 @@ describe('e2e', () => {
await page.evaluate(() => document.activeElement?.getAttribute('data-testid')),
).to.equal('initial-focus');
});

it('should display the rows', async () => {
await renderFixture('DataGrid/ConcurrentReactUpdate');
await sleep(100);
expect(
await page.evaluate(() =>
Array.from(document.querySelectorAll('[role="cell"]')).map((node) => node.textContent),
),
).to.deep.equal(['1', '2']);
});
});
});

0 comments on commit 8bb1cd6

Please sign in to comment.