Skip to content

Conversation

@krissalvador27
Copy link
Contributor

@krissalvador27 krissalvador27 commented Nov 4, 2019

What's this fix?
Fixes the breaking test in master from merged in PR #1608

What happened?
The broken test was validating that a change in end date would call deleteModifier for no-selected-start-before-selected-end on all visible days. Turns out the test was flakey because the visible days object calculated by DayPickerRangeController is determined by the initialVisibleMonthThunk.

const initialVisibleMonthThunk = initialVisibleMonth || (
   startDate ? () => startDate : () => this.today
);

DayPickerRangeController.jsx Line 1065.

The default initialVisibleMonthThunk does not take into account a passed in end date and by defaulting to today, the test cannot rely on a hardcoded number of times that deleteModifier will run. This isn't a major issue since DayPickerRangeController is most likely consumed by using the DateRangePicker kitchen sink that determines initialVisibleMonthThunk like so

const initialVisibleMonthThunk = initialVisibleMonth || (
    () => (startDate || endDate || moment())
);

DayPickerRangeController.jsx Line 460.

Happy to update the default of DayPickerRangeController to match the default on the DateRangePicker for both consistency and expected behavior, but wanted to prioritize fixing the flakey test for now.

Let me know if this works @majapw @ljharb! 😁

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems reasonable to me

@krissalvador27
Copy link
Contributor Author

@ljharb Would we be able to merge and publish a new minor? I feel some slight nervousness for being the pull request that is breaking master right now 😅

@ljharb
Copy link
Member

ljharb commented Nov 5, 2019

No need to publish anything just for tests; I’m going to defer to @majapw to merge this tho.

@majapw majapw merged commit 5b479ee into react-dates:master Nov 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants