MPDx - 6916: Remove Date-Fns - #17
Conversation
…-Fns # Conflicts: # src/components/Layouts/Primary/TopBar/NotificationMenu/Item/Item.tsx # src/components/Task/Drawer/CommentList/Item/Item.tsx # src/components/Task/Drawer/ContactList/Item/Item.tsx # src/components/Task/Drawer/Form/Form.mock.tsx # src/components/Task/List/List.tsx # src/lib/intlFormat/intlFormat.ts
|
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/cru/mpdx-react/HeFsCpEynzErMc8FCM6VMUxadKxH |
|
There are still some failing tests. They seem to come from |
| <ThemeProvider theme={theme}> | ||
| <CssBaseline /> | ||
| <MuiPickersUtilsProvider utils={DateFnsUtils}> | ||
| <MuiPickersUtilsProvider utils={LuxonUtils} > |
There was a problem hiding this comment.
I tried following these setup instructions, but I wonder if this is connected to the failing tests that seem to use the Material UI date pickers: https://material-ui-pickers.dev/getting-started/installation
There was a problem hiding this comment.
@OzzieOrca I've stared at this for a while to figure out what Prettier was complaining about, I think it was the extra space after {LuxonUtils}!
OzzieOrca
left a comment
There was a problem hiding this comment.
Looks good except prettier is failing on travis with a storybook preview file.
efc02b7 to
9631796
Compare
| if (isChromatic()) { | ||
| Settings.now = () => DateTime.local(2020, 2, 1).valueOf(); | ||
| } |
There was a problem hiding this comment.
I was trying to figure out what happened to Chromatic and looked into it a little bit and decided to just add this commit to fix 2 things:
- With Storybook running locally, the date when making a GraphQL query and the date when creating a mock for that query were seconds/milliseconds off. With the way the GraphQL mocks are set up, this caused the mock not to match the variables of the query and it threw an error that it couldn't find a mock for the query. I decided to just mock the date for now so I removed the
isChromaticcheck to mock the date locally too. - This is the only mock where you used a Luxon function inside the
Settings.nowfunction. Apparently that causes an infinite loop 🤷 It must useSettings.nowto figure out the date inside which calls it repeatedly. I just used the native date constructor like you used everywhere else.
There was a problem hiding this comment.
Right, I did discover that setting Settings.now with Luxon creates an infinite loop. I forgot to take this one out though. Thank you for that!
As a follow-up to adding Luxon to the project, I wanted to rip out Date-Fns. I also wanted to avoid using the default JS Date as much as much as possible -- One of the biggest things about Luxon is that the months are 1-indexed (January = 1, February = 2, etc.) as opposed to JS Date which is 0-indexed (January = 0, February = 1, etc.). I thought this might cause confusion when we are accessing the
monthproperty from one library or the other, so I hope this should be consistent and easier to understand.