-
-
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] Fix flaky tests #16257
[test] Fix flaky tests #16257
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export const isJSDOM = | ||
typeof window !== 'undefined' && /jsdom|HappyDOM/.test(window.navigator.userAgent); | ||
LukasTy marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ import { screen, createRenderer } from '@mui/internal-test-utils'; | |
import { DateCalendar, dayCalendarClasses } from '@mui/x-date-pickers/DateCalendar'; | ||
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider'; | ||
import { createPickerRenderer, AdapterName, availableAdapters } from 'test/utils/pickers'; | ||
import { he, fr } from 'date-fns/locale'; | ||
import { he, fr, enUS } from 'date-fns/locale'; | ||
import 'dayjs/locale/he'; | ||
import 'dayjs/locale/fr'; | ||
import 'moment/locale/he'; | ||
|
@@ -21,7 +21,7 @@ describe('<DateCalendar /> - localization', () => { | |
}); | ||
|
||
it('should display correct week day labels in Hebrew locale ', () => { | ||
render(<DateCalendar />); | ||
render(<DateCalendar reduceAnimations />); | ||
|
||
expect(screen.getByText('א')).toBeVisible(); | ||
}); | ||
|
@@ -31,7 +31,10 @@ describe('<DateCalendar /> - localization', () => { | |
|
||
it('should correctly switch between locale with week starting in Monday and week starting in Sunday', () => { | ||
const { setProps } = renderWithoutWrapper( | ||
<LocalizationProvider dateAdapter={availableAdapters[adapterName]}> | ||
<LocalizationProvider | ||
dateAdapter={availableAdapters[adapterName]} | ||
adapterLocale={adapterName === 'date-fns' ? enUS : 'en-US'} | ||
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. Was it needed here, because of leaking config from the other test in the suite? 🤔 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. Correct. Try running the test in isolation, it will fail 100% of the times with moment.js. It's specific to moment.js though, and due to importing side effects that seem to manipulate the locale of the global moment.js instance Maybe we could trigger locale change on top-level for momentjs adapter instead. Or if you know how to fix scoping for momentjs, that would be even better. 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. It only seems to currently work in CI (and when you run the whole test suite) due to other tests changing the locale back to english. But I have seen the test fail in CI as well, I guess if this test happens to run before the other ones. |
||
> | ||
<DateCalendar reduceAnimations /> | ||
</LocalizationProvider>, | ||
); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -249,7 +249,7 @@ const PickersCalendarHeader = React.forwardRef(function PickersCalendarHeader( | |
</SwitchViewButton> | ||
)} | ||
</PickersCalendarHeaderLabelContainer> | ||
<Fade in={view === 'day'}> | ||
<Fade in={view === 'day'} appear={!reduceAnimations} enter={!reduceAnimations}> | ||
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. Nice find. 👍 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. That'd probably the correct way, but I tried to go the easy route to prove the root cause. There's an exit prop as well that should remove the hide animations. Even better might be to put 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.
Gotcha. 👌
I tried locally, but it does not seem to change anything, the animation is still there.
Great point, now that we have this context, we should be able to move this setting there. 👍 |
||
<PickersArrowSwitcher | ||
slots={slots} | ||
slotProps={slotProps} | ||
|
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.
I would keep the try/catch here as it was in
useGridVirtualScroller
so it doesn't fail in server envThere 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.
Why would it fail in server environment? Besides
window
not being defined, which it checks for.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.
I didn't notice there was a check for
window
alread 👍🏻