Commit 70c7ee2
authored
🤖 fix: mock Date.now() in Storybook for deterministic snapshots (#1033)
## Problem
The `WithBashToolWaiting` story was flaky because the elapsed time
display changed every run.
The `BashToolCall` component calculates elapsed time using `Date.now()`
for the current time, but stories use a fixed timestamp (`NOW =
1700000000000`, Nov 2023) for message timestamps. This meant the elapsed
time showed something like `33000000s` (the difference between real
`Date.now()` and the fixed timestamp), which changed every second.
## Solution
Mock `Date.now()` globally in Storybook preview to return the same
stable `NOW` timestamp used by all test fixtures. Now the elapsed time
calculation is deterministic.
_Generated with `mux`_1 parent 45d9c5b commit 70c7ee2
1 file changed
+5
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
6 | 11 | | |
7 | 12 | | |
8 | 13 | | |
| |||
0 commit comments