Skip to content

Commit

Permalink
[test] Stabilize flaky Data Grid tests (#16053)
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasTy authored Jan 1, 2025
1 parent a5f4a73 commit 88438a1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
import { createRenderer, act } from '@mui/internal-test-utils';
import { expect } from 'chai';
import { getColumnValues } from 'test/utils/helperFn';
import { GridInitialStatePremium } from '../models/gridStatePremium';

const isJSDOM = /jsdom/.test(window.navigator.userAgent);

Expand Down Expand Up @@ -51,7 +50,7 @@ const FULL_INITIAL_STATE: GridInitialState = {
describe('<DataGridPremium /> - State persistence', () => {
const { render } = createRenderer();

let apiRef: React.MutableRefObject<GridApi>;
let apiRef: React.RefObject<GridApi>;

function TestCase(props: Omit<DataGridPremiumProps, 'rows' | 'columns' | 'apiRef'>) {
apiRef = useGridApiRef();
Expand Down Expand Up @@ -102,10 +101,7 @@ describe('<DataGridPremium /> - State persistence', () => {
});
});

let exportedState: GridInitialStatePremium = {};
await act(() => {
exportedState = apiRef.current.exportState();
});
const exportedState = apiRef.current.exportState();
expect(exportedState.rowGrouping).to.deep.equal(FULL_INITIAL_STATE.rowGrouping);
expect(exportedState.aggregation).to.deep.equal(FULL_INITIAL_STATE.aggregation);
});
Expand All @@ -121,10 +117,7 @@ describe('<DataGridPremium /> - State persistence', () => {
});
});

let exportedState: GridInitialStatePremium = {};
await act(() => {
exportedState = apiRef.current.exportState({ exportOnlyDirtyModels: true });
});
const exportedState = apiRef.current.exportState({ exportOnlyDirtyModels: true });
expect(exportedState.rowGrouping).to.deep.equal(FULL_INITIAL_STATE.rowGrouping);
expect(exportedState.aggregation).to.deep.equal(FULL_INITIAL_STATE.aggregation);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ describe('<DataGrid /> - Row selection', () => {
await user.keyboard('{Shift>}[ArrowDown]{/Shift}');
expect(getSelectedRowIds()).to.deep.equal([1, 2, 3]);

await user.keyboard('{ArrowDown/}');
await user.keyboard('{ArrowDown}');
expect(getSelectedRowIds()).to.deep.equal([1, 2, 3]); // Already on the last row
});

Expand Down

0 comments on commit 88438a1

Please sign in to comment.