mirror of
https://github.com/coder/coder.git
synced 2026-06-03 21:18:24 +00:00
test: pin DateRangePicker calendar today to caller-supplied clock (#24517)
The `DateRangePicker` accepts a `now` prop that stories and tests use to pin preset ranges and future-date disabling to a deterministic clock, but it never forwarded that value to the underlying `Calendar`. `react-day-picker` then computed its own `today` from wall-clock time, which drives both the "today" highlight modifier and the initial visible month — causing stories like `TemplateInsightsControls:Day` to _flake_ as real time advanced. Thread `currentTime` into `react-day-picker`'s `today` prop. When `now` is omitted (production usage), `currentTime` falls back to `new Date()`, which matches `react-day-picker`'s existing default, so there is no runtime behavior change.
This commit is contained in:
@@ -246,6 +246,7 @@ export const DateRangePicker: FC<DateRangePickerProps> = ({
|
||||
onSelect={handleCalendarSelect}
|
||||
numberOfMonths={2}
|
||||
disabled={{ after: currentTime }}
|
||||
today={currentTime}
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user