[test] Fix flaky "should render only the pageSize" Data Grid virtualization test#23090
Merged
LukasTy merged 1 commit intoJul 6, 2026
Merged
Conversation
… test The test scrolled the virtual scroller to the bottom and then asserted the last rendered cell synchronously, with no waitFor. `scrollTo` updates `scrollTop` synchronously, but the browser dispatches the native `scroll` event asynchronously, and the grid's render context is updated only from that event (handleScroll -> triggerUpdateRenderContext -> flushSync). When the assertion runs before the scroll event fires, the DOM still shows the initial top window, so the last cell reads its initial value instead of the expected one, failing intermittently in CI. Wrap the assertion in waitFor, matching the convention already used by the sibling scroll tests in this file. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Deploy previewhttps://deploy-preview-23090--material-ui-x.netlify.app/Bundle size
Check out the code infra dashboard for more information about this PR. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes an intermittent browser-test failure in the Data Grid Pro rows virtualization pagination suite by waiting for the render context to update after a programmatic scrollTo, eliminating a race between synchronous scrollTop changes and asynchronous native scroll event dispatch.
Changes:
- Wrap the “last rendered cell” assertion in
waitForso it retries until the bottom window is actually rendered. - Add an inline comment explaining why the wait is necessary (async scroll event + render context update path).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
The browser test
<DataGridPro /> - Rows > virtualization > Pagination > should render only the pageSizefails intermittently in CI (for example CircleCI build https://circleci.com/gh/mui/mui-x/877236, which surfaced on the unrelated Renovate PR #23083 that only bumps@tanstack/queryin the docs):Cause
The test scrolls the virtual scroller to the bottom and then asserts the last rendered cell synchronously, with no
waitFor:scrollToupdatesscrollTopsynchronously, but the browser dispatches the nativescrollevent asynchronously. The grid updates its render context only from that event (handleScroll->triggerUpdateRenderContext->ReactDOM.flushSync). When the assertion runs before the scroll event fires, the DOM still shows the initial top window, so the last cell reads its initial value (7) instead of the expected31. Under CI load the event is sometimes late, hence the flake.The sibling test
should not virtualize the last page if smaller than viewportis not affected: its last page fits within the viewport, so the scroll is clamped to 0 and no re-render is needed.Fix
Wrap the assertion in
waitFor, matching the convention already used by every other scroll test in this file.Test plan
Ran the browser test suite for the file locally; the target test and the full
rows.DataGridPro.test.tsx(47 tests) pass.🤖 Generated with Claude Code