Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
93bf5ac
Bump React to ^19.0.0
renovate[bot] Dec 6, 2024
1506c31
codemod docs
JCQuintas Dec 6, 2024
c656122
Fix/update DataGrid ref usage
LukasTy Dec 9, 2024
91daf42
Fix a few more Pickers and Tree view cases
LukasTy Dec 9, 2024
914270e
Fix prettier
flaviendelangle Dec 9, 2024
4dc9d67
Fix more useref usages
LukasTy Dec 9, 2024
c62046e
Changes from `ref` react-ts-codemod
LukasTy Dec 9, 2024
a4e6a2f
Changes from `react-element` react-ts-codemod
LukasTy Dec 9, 2024
e7dc07d
docs:typescript:formatted
LukasTy Dec 9, 2024
85998ce
Run react-ts-codemods on `test` folder
LukasTy Dec 9, 2024
ddbae8e
Bump/test `@mui/material@6` to avoid `JSX` namespace errors
LukasTy Dec 9, 2024
4ca779b
Hide `JSX` namespace issues in `@react-spring`
LukasTy Dec 9, 2024
8c09a3e
Remove broken prop
LukasTy Dec 10, 2024
f652cd8
Make `fieldRef` optional param to avoid the need for `fieldRef: undef…
LukasTy Dec 10, 2024
190e37d
Use `@mui` packages with fixed `JSX` namespace
LukasTy Dec 10, 2024
be7cbc8
prettier
LukasTy Dec 10, 2024
05c307b
Fix `DateTimeRangePickerTimeWrapper` ref handling
LukasTy Dec 10, 2024
ecd1f5a
Avoid `JSX` namespace issue due to `@emotion`
LukasTy Dec 10, 2024
4b6da95
ignore specific errors while react-spring is not fixed
JCQuintas Dec 10, 2024
81c09f3
Fix docs charts TS errors
LukasTy Dec 10, 2024
9ab8ac7
Avoid `JSX` namespace issue due to `@emotion` on `@mui/x-codemod` pac…
LukasTy Dec 10, 2024
f3e6970
docs:typescript:formatted
LukasTy Dec 10, 2024
731f5dc
Revert to previous casting solution to avoid TS error
LukasTy Dec 10, 2024
ea994c8
Align `@mui/types` version to avoid data grid typing conflicts
LukasTy Dec 10, 2024
a6362d3
Explicitly type `useMultiInputFieldSelectedSections` to avoid implici…
LukasTy Dec 11, 2024
8317602
Bump react types
LukasTy Dec 11, 2024
aad5677
Fix `useNow` hook
LukasTy Dec 11, 2024
41ab3c2
Use released packages
LukasTy Dec 11, 2024
dede7d1
Add `skipLibCheck` until `@mui/joy` is released from `v5`
LukasTy Dec 11, 2024
5ef32f2
Bump `@mui/monorepo` and `@mui/docs`
LukasTy Dec 11, 2024
3bb3494
Fix browser test
LukasTy Dec 11, 2024
443e8fa
Bump `@mui/joy`
LukasTy Dec 11, 2024
b825c72
Use `rtl` API for column querying
LukasTy Dec 11, 2024
18f2912
Fix some tests by making them async
LukasTy Dec 11, 2024
37678a0
Minor cleanup
LukasTy Dec 11, 2024
f8d425b
Fix `sorting.DataGrid` test
LukasTy Dec 12, 2024
6afea09
Fix after merge
LukasTy Dec 12, 2024
09ce052
Move refs to props
LukasTy Dec 12, 2024
c243a43
Revert "Move refs to props"
LukasTy Dec 13, 2024
e0f937c
Fix `consumeThemeProps` typing to work for React 19
LukasTy Dec 13, 2024
d53daa4
fix consumeThemeProps
JCQuintas Dec 13, 2024
2850c26
Revert "fix consumeThemeProps"
JCQuintas Dec 13, 2024
bf1ea94
Refactor tests to user `userEvent`
LukasTy Dec 13, 2024
04632a8
Stabilize `data-grid-premium` tests
LukasTy Dec 13, 2024
0f41ede
Make `rowSelection.DataGridPro` tests pass
LukasTy Dec 13, 2024
2662a65
Make `rowPinning.DataGridPro` tests pass
LukasTy Dec 13, 2024
d437bc1
Stabilize flaky `DataGridPro` tests
LukasTy Dec 17, 2024
fae1f8d
Stabilize tabindex test
LukasTy Dec 17, 2024
80fd09f
Bump `@mui/internal-test-utils`
LukasTy Dec 17, 2024
87c2d9e
fix eslint
LukasTy Dec 17, 2024
6c89540
Revert "pointless" `waitFor` calls
LukasTy Dec 18, 2024
331478a
Bump @types/react
arminmeh Dec 18, 2024
61f7fa4
update docs/package.json
arminmeh Dec 19, 2024
94027c4
Update lock file
arminmeh Dec 19, 2024
f8e48f5
Fix row selection test
arminmeh Dec 19, 2024
6b4a212
Do not publish 'resize' event if the dimensions have not changed
arminmeh Dec 19, 2024
a3b032c
Revert some test changes
arminmeh Dec 19, 2024
3974d69
Fix dependencies after rebase
arminmeh Dec 24, 2024
39f276c
fix package order
arminmeh Dec 24, 2024
35506cc
Fix tests
arminmeh Dec 24, 2024
f577a75
Test cleanup
arminmeh Dec 24, 2024
e6ef9e4
Add step to disable pnpm peer deps installing on CI when react is not…
LukasTy Dec 24, 2024
3d43e6a
Fix param name
LukasTy Dec 24, 2024
52ffe7b
fix param name 2
LukasTy Dec 24, 2024
e14cbc3
Set pnpm config flag on project
LukasTy Dec 24, 2024
2e4bd1a
Use `--no-frozen-lockfile` when `with-react-version` is not `stable`
LukasTy Dec 24, 2024
08f84bf
Simplify
MBilalShafi Dec 24, 2024
7220a0b
Merge branch 'master' into renovate/major-react
MBilalShafi Dec 24, 2024
6e1070f
Fix error in CI config file
LukasTy Dec 27, 2024
a5c40a3
Remove no longer needed explicit beta version
LukasTy Dec 27, 2024
3bf257c
Setup React 18 tests to run on main branches
LukasTy Dec 27, 2024
efebb48
Test filters on individual jobs
LukasTy Dec 27, 2024
9d56411
Try
LukasTy Dec 27, 2024
caf3bd8
try 2
LukasTy Dec 27, 2024
3e8e486
Test more specific version name
LukasTy Dec 27, 2024
cdc72a2
echo params
LukasTy Dec 27, 2024
1475f33
Revert suggested fix
LukasTy Dec 27, 2024
a4c728e
Try
LukasTy Dec 27, 2024
ca32e1b
Try 3
LukasTy Dec 27, 2024
dd14eba
try 4
LukasTy Dec 27, 2024
8c71c2d
try 5
LukasTy Dec 27, 2024
46314cd
try 6
LukasTy Dec 27, 2024
1ce6f75
Try reusing config via context
LukasTy Dec 27, 2024
ed403a3
Don't run on renovate branch by default
LukasTy Dec 27, 2024
3d40915
cleanup
LukasTy Dec 27, 2024
bb0868f
Bump "MUI Core"
LukasTy Dec 27, 2024
94976e5
Allow `react-is` v18 or v19
LukasTy Dec 27, 2024
78a4dea
Merge branch 'master' into renovate/major-react
LukasTy Dec 27, 2024
4d740b7
Merge branch 'master' into renovate/major-react
LukasTy Dec 30, 2024
85bf3f5
Improve typing
LukasTy Dec 30, 2024
7187ad0
await async action
LukasTy Dec 30, 2024
636a349
Try act with curly braces
LukasTy Dec 30, 2024
4fa033c
Simplify `user.keyboard` usage
LukasTy Dec 30, 2024
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
Prev Previous commit
Next Next commit
Fix some tests by making them async
  • Loading branch information
LukasTy authored and arminmeh committed Dec 24, 2024
commit 18f291298213371c9ee8c34b989dbe5c9d78b76d
103 changes: 52 additions & 51 deletions packages/x-data-grid/src/tests/columnsVisibility.DataGrid.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import { expect } from 'chai';
import { spy } from 'sinon';
import { act, createRenderer, fireEvent, screen } from '@mui/internal-test-utils';
import { createRenderer, fireEvent, screen } from '@mui/internal-test-utils';
import {
DataGrid,
DataGridProps,
Expand All @@ -18,7 +18,7 @@ const rows: GridRowsProp = [{ id: 1, idBis: 1 }];

const columns: GridColDef[] = [{ field: 'id' }, { field: 'idBis' }];

describe('<DataGridPro /> - Columns visibility', () => {
describe('<DataGrid /> - Columns visibility', () => {
const { render } = createRenderer();

function TestDataGrid(
Expand Down Expand Up @@ -50,8 +50,8 @@ describe('<DataGridPro /> - Columns visibility', () => {
expect(getColumnHeadersTextContent()).to.deep.equal(['id', 'idBis']);
});

it('should update the visible columns when props.onColumnVisibilityModelChange and props.columnVisibilityModel are not defined', () => {
render(
it('should update the visible columns when props.onColumnVisibilityModelChange and props.columnVisibilityModel are not defined', async () => {
const { user } = render(
<TestDataGrid
slots={{
toolbar: GridToolbar,
Expand All @@ -60,14 +60,14 @@ describe('<DataGridPro /> - Columns visibility', () => {
);

expect(getColumnHeadersTextContent()).to.deep.equal(['id', 'idBis']);
fireEvent.click(screen.getByRole('button', { name: 'Select columns' }));
fireEvent.click(screen.getByRole('checkbox', { name: 'id' }));
await user.click(screen.getByRole('button', { name: 'Select columns' }));
await user.click(screen.getByRole('checkbox', { name: 'id' }));
expect(getColumnHeadersTextContent()).to.deep.equal(['idBis']);
});

it('should call onColumnVisibilityModelChange and update the visible columns when props.columnVisibilityModel is not defined', () => {
it('should call onColumnVisibilityModelChange and update the visible columns when props.columnVisibilityModel is not defined', async () => {
const onColumnVisibilityModelChange = spy();
render(
const { user } = render(
<TestDataGrid
slots={{
toolbar: GridToolbar,
Expand All @@ -77,8 +77,8 @@ describe('<DataGridPro /> - Columns visibility', () => {
);

expect(getColumnHeadersTextContent()).to.deep.equal(['id', 'idBis']);
fireEvent.click(screen.getByRole('button', { name: 'Select columns' }));
fireEvent.click(screen.getByRole('checkbox', { name: 'id' }));
await user.click(screen.getByRole('button', { name: 'Select columns' }));
await user.click(screen.getByRole('checkbox', { name: 'id' }));
expect(getColumnHeadersTextContent()).to.deep.equal(['idBis']);
expect(onColumnVisibilityModelChange.callCount).to.equal(1);
expect(onColumnVisibilityModelChange.lastCall.firstArg).to.deep.equal({
Expand Down Expand Up @@ -109,7 +109,7 @@ describe('<DataGridPro /> - Columns visibility', () => {
});
});

it('should call onColumnVisibilityModelChange with the new model when toggling all columns', () => {
it('should call onColumnVisibilityModelChange with the new model when toggling all columns', async () => {
const onColumnVisibilityModelChange = spy();
function ControlledTest() {
const [model, setModel] = React.useState<GridColumnVisibilityModel>({ idBis: false });
Expand All @@ -126,20 +126,20 @@ describe('<DataGridPro /> - Columns visibility', () => {
/>
);
}
render(<ControlledTest />);
const { user } = render(<ControlledTest />);

expect(getColumnHeadersTextContent()).to.deep.equal(['id']);

fireEvent.click(screen.getByRole('button', { name: 'Select columns' }));
await user.click(screen.getByRole('button', { name: 'Select columns' }));
const showHideAllCheckbox = screen.getByRole('checkbox', { name: 'Show/Hide All' });

// Hide all
fireEvent.click(showHideAllCheckbox);
await user.click(showHideAllCheckbox);
expect(onColumnVisibilityModelChange.callCount).to.equal(1);
expect(onColumnVisibilityModelChange.lastCall.firstArg).to.deep.equal({});

// Show all
fireEvent.click(showHideAllCheckbox);
await user.click(showHideAllCheckbox);
expect(onColumnVisibilityModelChange.callCount).to.equal(2);
expect(onColumnVisibilityModelChange.lastCall.firstArg).to.deep.equal({
id: false,
Expand All @@ -148,8 +148,8 @@ describe('<DataGridPro /> - Columns visibility', () => {
});

// Fixes (1) and (2) in https://github.com/mui/mui-x/issues/7393#issuecomment-1372129661
it('should not show hidden non hideable columns when "Show/Hide All" is clicked', () => {
render(
it('should not show hidden non hideable columns when "Show/Hide All" is clicked', async () => {
const { user } = render(
<TestDataGrid
slots={{
toolbar: GridToolbar,
Expand All @@ -163,13 +163,13 @@ describe('<DataGridPro /> - Columns visibility', () => {
/>,
);

fireEvent.click(screen.getByRole('button', { name: 'Select columns' }));
await user.click(screen.getByRole('button', { name: 'Select columns' }));
const showHideAllCheckbox = screen.getByRole('checkbox', { name: 'Show/Hide All' });
// Hide all
fireEvent.click(showHideAllCheckbox);
await user.click(showHideAllCheckbox);
expect(getColumnHeadersTextContent()).to.deep.equal([]);
// Show all
fireEvent.click(showHideAllCheckbox);
await user.click(showHideAllCheckbox);
expect(getColumnHeadersTextContent()).to.deep.equal(['id']);
});
});
Expand Down Expand Up @@ -226,8 +226,8 @@ describe('<DataGridPro /> - Columns visibility', () => {
expect(getColumnHeadersTextContent()).to.deep.equal(['id']);
});

it('should allow to update the visible columns through the UI when initialized with initialState', () => {
render(
it('should allow to update the visible columns through the UI when initialized with initialState', async () => {
const { user } = render(
<TestDataGrid
initialState={{
columns: {
Expand All @@ -241,14 +241,14 @@ describe('<DataGridPro /> - Columns visibility', () => {
);

expect(getColumnHeadersTextContent()).to.deep.equal(['id']);
fireEvent.click(screen.getByRole('button', { name: 'Select columns' }));
fireEvent.click(screen.getByRole('checkbox', { name: 'id' }));
await user.click(screen.getByRole('button', { name: 'Select columns' }));
await user.click(screen.getByRole('checkbox', { name: 'id' }));
expect(getColumnHeadersTextContent()).to.deep.equal([]);
});
});

it('should autofocus the first switch element in columns management when `autoFocusSearchField` disabled', () => {
render(
it('should autofocus the first switch element in columns management when `autoFocusSearchField` disabled', async () => {
const { user } = render(
<TestDataGrid
slots={{
toolbar: GridToolbar,
Expand All @@ -261,21 +261,21 @@ describe('<DataGridPro /> - Columns visibility', () => {
/>,
);

fireEvent.click(screen.getByRole('button', { name: 'Select columns' }));
await user.click(screen.getByRole('button', { name: 'Select columns' }));

expect(screen.getByRole('checkbox', { name: columns[0].field })).toHaveFocus();
});

it('should hide `Show/Hide all` in columns management when `disableShowHideToggle` is `true`', () => {
const { setProps } = render(
it('should hide `Show/Hide all` in columns management when `disableShowHideToggle` is `true`', async () => {
const { setProps, user } = render(
<TestDataGrid
slots={{
toolbar: GridToolbar,
}}
/>,
);

fireEvent.click(screen.getByRole('button', { name: 'Select columns' }));
await user.click(screen.getByRole('button', { name: 'Select columns' }));
// check if `Show/Hide all` checkbox is present initially
expect(screen.getByRole('checkbox', { name: 'Show/Hide All' })).not.to.equal(null);
setProps({
Expand All @@ -290,16 +290,16 @@ describe('<DataGridPro /> - Columns visibility', () => {
expect(screen.queryByRole('checkbox', { name: 'Show/Hide All' })).to.equal(null);
});

it('should hide `Reset` in columns panel when `disableResetButton` is `true`', () => {
const { setProps } = render(
it('should hide `Reset` in columns panel when `disableResetButton` is `true`', async () => {
const { setProps, user } = render(
<TestDataGrid
slots={{
toolbar: GridToolbar,
}}
/>,
);

fireEvent.click(screen.getByRole('button', { name: 'Select columns' }));
await user.click(screen.getByRole('button', { name: 'Select columns' }));
// check if Reset button is present initially
expect(screen.getByRole('button', { name: 'Reset' })).not.to.equal(null);
setProps({
Expand All @@ -313,8 +313,8 @@ describe('<DataGridPro /> - Columns visibility', () => {
expect(screen.queryByRole('button', { name: 'Reset' })).to.equal(null);
});

it('should reset the columns to initial columns state when `Reset` button is clicked in columns management panel', () => {
render(
it('should reset the columns to initial columns state when `Reset` button is clicked in columns management panel', async () => {
const { user } = render(
<TestDataGrid
slots={{
toolbar: GridToolbar,
Expand All @@ -323,17 +323,17 @@ describe('<DataGridPro /> - Columns visibility', () => {
);

expect(getColumnHeadersTextContent()).to.deep.equal(['id', 'idBis']);
fireEvent.click(screen.getByRole('button', { name: 'Select columns' }));
await user.click(screen.getByRole('button', { name: 'Select columns' }));
const resetButton = screen.getByRole('button', { name: 'Reset' });
expect(resetButton).to.have.attribute('disabled');

// Hide `idBis` column
fireEvent.click(screen.getByRole('checkbox', { name: 'idBis' }));
await user.click(screen.getByRole('checkbox', { name: 'idBis' }));
expect(getColumnHeadersTextContent()).to.deep.equal(['id']);
expect(resetButton).not.to.have.attribute('disabled');

// Reset columns
fireEvent.click(resetButton);
await user.click(resetButton);
expect(getColumnHeadersTextContent()).to.deep.equal(['id', 'idBis']);
expect(resetButton).to.have.attribute('disabled');
});
Expand All @@ -360,10 +360,10 @@ describe('<DataGridPro /> - Columns visibility', () => {
expect(screen.queryByRole('checkbox', { name: 'idBis' })).to.equal(null);
});

it('should avoid toggling columns provided by `getTogglableColumns` prop on `Show/Hide All`', () => {
it('should avoid toggling columns provided by `getTogglableColumns` prop on `Show/Hide All`', async () => {
const getTogglableColumns = (cols: GridColDef[]) =>
cols.filter((column) => column.field !== 'idBis').map((column) => column.field);
render(
const { user } = render(
<TestDataGrid
slots={{
toolbar: GridToolbar,
Expand All @@ -376,19 +376,19 @@ describe('<DataGridPro /> - Columns visibility', () => {
/>,
);

fireEvent.click(screen.getByRole('button', { name: 'Select columns' }));
await user.click(screen.getByRole('button', { name: 'Select columns' }));
const showHideAllCheckbox = screen.getByRole('checkbox', { name: 'Show/Hide All' });
fireEvent.click(showHideAllCheckbox);
await user.click(showHideAllCheckbox);
expect(getColumnHeadersTextContent()).to.deep.equal(['idBis']);

fireEvent.click(showHideAllCheckbox);
await user.click(showHideAllCheckbox);
expect(getColumnHeadersTextContent()).to.deep.equal(['id', 'idBis']);
});
});

describe('prop: toggleAllMode', () => {
it('should toggle filtered columns when `toggleAllMode` is `filtered`', () => {
render(
it('should toggle filtered columns when `toggleAllMode` is `filtered`', async () => {
const { user } = render(
<div style={{ width: 400, height: 300 }}>
<DataGrid
columns={[
Expand All @@ -411,17 +411,18 @@ describe('<DataGridPro /> - Columns visibility', () => {

expect(getColumnHeadersTextContent()).to.deep.equal(['id', 'firstName', 'lastName', 'age']);
const button = screen.getByRole('button', { name: 'Select columns' });
act(() => button.focus());
fireEvent.click(button);
await user.click(button);

const input = screen.getByPlaceholderText('Search');
fireEvent.change(input, { target: { value: 'name' } });
await user.type(input, 'name');
const showHideAllCheckbox = screen.getByRole('checkbox', { name: 'Show/Hide All' });
fireEvent.click(showHideAllCheckbox);
await user.click(showHideAllCheckbox);
expect(getColumnHeadersTextContent()).to.deep.equal(['id', 'age']);

fireEvent.change(input, { target: { value: 'firstName' } });
fireEvent.click(showHideAllCheckbox);
// clear the search before the new search
await user.clear(input);
await user.type(input, 'firstName');
await user.click(showHideAllCheckbox);
expect(getColumnHeadersTextContent()).to.deep.equal(['id', 'firstName', 'age']);
});
});
Expand Down