-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[test] Disable react-transition-group
transitions in unit testing
#16288
Merged
LukasTy
merged 39 commits into
mui:master
from
lauri865:override-react-transition-group-in-tests
Jan 31, 2025
Merged
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
0c7316d
override react transition group + remove `waitFor` calls
lauri865 2f5117a
Install missing `react-transition-group` dep in `test` package
LukasTy cfbdf4e
Always render the transition component - `in` as `false` should rende…
LukasTy 73c71ba
Fix eslint and prettier issues
LukasTy 5546f97
Try built-in `react-transition-group` transition disabling for testing
LukasTy 583b078
Try mocking components instead of using config
LukasTy 1e8be24
prettier & eslint
LukasTy fd8dccd
Revert back to `config.disabled = "true"` solution
LukasTy f30868b
Override `config` flag for tests needing transitions
LukasTy 88f8035
Merge branch 'master' into override-react-transition-group-in-tests
LukasTy e8a289f
Use `waitFor` in relevant cases, where browser tests fail otherwise
LukasTy b639fa2
Remove `waitFor` where possible
LukasTy b7c64b8
Merge branch 'master' into override-react-transition-group-in-tests
LukasTy a6f2d87
Call `beforeAll` hooks to properly setup license and disable transiti…
LukasTy f4b027b
Fix tests
LukasTy 7c15df7
Fix the fix of tests :D
LukasTy fcf61b8
brainfart
LukasTy a30bdc4
Ensure the filter panel is opened before entering filter value
LukasTy 1efc333
Try more assertions
LukasTy da44c19
Make assertions properly async
LukasTy d8e765c
Try async expected DOM assertions
LukasTy 2a48064
Keep `waitFor` for a flaky test
LukasTy 40d8eb9
Refactor
LukasTy e82a695
Try `user.type`
LukasTy 78a49b5
Try assertion for active filter
LukasTy 1daa8c3
Use `findBy` instead of `waitFor`
LukasTy 8a87dbf
Try with `skipClick`
LukasTy 3a97908
Revert test to original behavior
LukasTy 5458de4
Revert test change to maybe avoid flakiness
LukasTy 49ba6d5
Try the failing assertion in async method
LukasTy 52a723f
Merge branch 'master' into override-react-transition-group-in-tests
LukasTy 8f2bff8
Merge branch 'master' into override-react-transition-group-in-tests
LukasTy 6cfb531
Move config to `beforeEach`
LukasTy 4cac57d
Code review: Jan
LukasTy d92ea56
A few flaky refactors
LukasTy 018956e
Merge branch 'master' into override-react-transition-group-in-tests
LukasTy 6dc1330
Address another flaky test
LukasTy ee62e4d
Revert change
LukasTy d05549a
Update packages/x-data-grid-pro/src/tests/editComponents.DataGridPro.…
LukasTy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import * as React from 'react'; | ||
import { config } from 'react-transition-group'; | ||
import { createRenderer, fireEvent, screen } from '@mui/internal-test-utils'; | ||
import { expect } from 'chai'; | ||
import { gridClasses, DataGridPro, DataGridProProps } from '@mui/x-data-grid-pro'; | ||
|
@@ -198,6 +199,10 @@ describe('<DataGridPro /> - Column headers', () => { | |
}); | ||
|
||
it('should remove the MuiDataGrid-menuOpen CSS class only after the transition has ended', () => { | ||
const restoreDisabledConfig = config.disabled; | ||
// enable `react-transition-group` transitions for this test | ||
config.disabled = false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test needs animations with timeouts or a complete refactor/removal |
||
|
||
render( | ||
<div style={{ width: 300, height: 500 }}> | ||
<DataGridPro {...baselineProps} columns={[{ field: 'brand' }]} /> | ||
|
@@ -212,6 +217,9 @@ describe('<DataGridPro /> - Column headers', () => { | |
expect(menuIconButton?.parentElement).to.have.class(gridClasses.menuOpen); | ||
clock.runToLast(); // Wait for the transition to run | ||
expect(menuIconButton?.parentElement).not.to.have.class(gridClasses.menuOpen); | ||
|
||
// restore previous config | ||
config.disabled = restoreDisabledConfig; | ||
}); | ||
|
||
it('should restore focus to the column header when dismissing the menu by selecting any item', () => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 3 additions & 5 deletions
8
packages/x-data-grid-pro/src/tests/license.DataGridPro.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,19 @@ | ||
import * as React from 'react'; | ||
import { expect } from 'chai'; | ||
import { createRenderer, screen, waitFor } from '@mui/internal-test-utils'; | ||
import { createRenderer, screen } from '@mui/internal-test-utils'; | ||
import { DataGridPro } from '@mui/x-data-grid-pro'; | ||
import { LicenseInfo } from '@mui/x-license'; | ||
|
||
describe('<DataGridPro /> - License', () => { | ||
const { render } = createRenderer(); | ||
|
||
it('should render watermark when the license is missing', async () => { | ||
it('should render watermark when the license is missing', () => { | ||
LicenseInfo.setLicenseKey(''); | ||
|
||
expect(() => render(<DataGridPro columns={[]} rows={[]} autoHeight />)).toErrorDev([ | ||
'MUI X: Missing license key.', | ||
]); | ||
|
||
await waitFor(() => { | ||
expect(screen.getByText('MUI X Missing license key')).not.to.equal(null); | ||
}); | ||
expect(screen.getByText('MUI X Missing license key')).not.to.equal(null); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test needs animations or refactoring.