-
Notifications
You must be signed in to change notification settings - Fork 2k
DateCalendar: add unit tests #103676
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
DateCalendar: add unit tests #103676
Conversation
Jetpack Cloud live (direct link)
Automattic for Agencies live (direct link)
|
This PR modifies the release build for the following Calypso Apps: For info about this notification, see here: PCYsg-OT6-p2
To test WordPress.com changes, run |
This PR does not affect the size of JS and CSS bundles shipped to the user's browser. Generated by performance advisor bot at iscalypsofastyet.com. |
@@ -1,6 +1,8 @@ | |||
const path = require( 'path' ); | |||
const base = require( '@automattic/calypso-jest' ); | |||
|
|||
process.env.TZ = 'UTC'; |
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 change is important to make sure that all jest tests run in the UTC timezone, regardless of the machine's local timezone. I wasn't sure whether this file was the best place for it, though — alternatively, we could move it to @automattic/calypso-jest
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 looks like a good place. Note that if we want to apply it to client tests, we'll need to add it to the client jest preset too.
14bf8d6
to
57c9895
Compare
8ae225b
to
2ba1280
Compare
57c9895
to
1c3decc
Compare
8d7dd48
to
097ce2e
Compare
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 is looking pretty good IMO 👍 Thanks for adding thorough test coverage.
Just a few questions, nothing blocking. Ideally, we'd get rid of the extra dependency if possible.
// earlier by 1 day (from midnight to 10pm the previous day). | ||
expect( getDateCell( today, { selected: true } ) ).toBeVisible(); | ||
} ); | ||
} ); |
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 wonder how much edge cases we want to support. Like, should we handle daylight savings time transitions correctly?
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.
At least for now, I would ship an initial suite of tests that covers well the majority of use cases.
There are potentially so many edge cases (especially when it comes to time zones, daylight savings, etc) that it would take a considerable amount of time to cover them all, and I'm not sure the effort is worth it for now.
Additionally, I also assume that the underlying react-day-picker
component delagates all these calculations to date-fns
, meaning that it should be generally reliable.
Happy to add more tests at a later point in time, if needed.
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.
Sounds good to me, thanks for confirming!
@@ -1,6 +1,8 @@ | |||
const path = require( 'path' ); | |||
const base = require( '@automattic/calypso-jest' ); | |||
|
|||
process.env.TZ = 'UTC'; |
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 looks like a good place. Note that if we want to apply it to client tests, we'll need to add it to the client jest preset too.
097ce2e
to
feebbc7
Compare
Part 2 (for |
Requires #103675
Partially addresses DS-111
Proposed Changes
Add unit tests for the
DateCalendar
componentWhy are these changes being made?
react-day-picker
dependencyWorking on the tests flagged the inconsistency about the
onSelect
callback arguments which is fixes in #103675I will add
DateRangeCalendar
unit tests in a follow-up PRTesting Instructions
Pre-merge Checklist