test(body.history): de-flake idempotency assertion with fake timers
The `should clone body before transformation to preserve original` test asserted `expect(result1).toBe(result2)` for two consecutive transformRequestBody calls on identical input. That invariant is not guaranteed by production code because the cch billing hash in src/headers/billing.ts:59 mixes `Date.now().toString(36)` into its input to mimic CC's per-request attestation hash. Two calls in different milliseconds produce different cch values and therefore different output bytes. The test only ever passed when both calls landed in the same millisecond — reliable on bare-metal fast hardware, unreliable under husky pre-commit + pre-push with lint-staged overhead, CI workers, or any system under load. It happened to be stable enough to not trip on previous 0.1.4 work, then shifted across the threshold during the 0.1.4 release sequencing and blocked the push. Fix: wrap the two calls in `vi.useFakeTimers()` + `vi.setSystemTime(...)` so the frozen clock produces byte-identical cch values and the idempotency assertion becomes meaningful (it validates that NOTHING other than time-derived fields varies across calls, which is the actual invariant the test name promises). Real timers are restored in finally so the rest of the suite is unaffected. Verification: body.history.test.ts 5/5 green in isolation, full vitest suite 3/3 green (933 tests each run).
V
Vacbo committed
3480827ae120cb5e634c85696b560d93897c3f06
Parent: d0e3674