Add unit coverage for use-activity - #877
Merged
Merged
Conversation
Cover the activity hooks' pure range logic and query wiring, which had no direct tests: getRangeBounds for all five ranges (including the DST-transition daily end bound and the UTC-derived default daily date parsed as local midnight), rangeLabel, the range-to-granularity mapping, tz/start/end query-param construction with empty bounds omitted for all-time, payload unwrapping for the heatmap and token/ project endpoints, the useActiveHours raw-bounds request (no granularity param) feeding buildActiveHours, per-range cache keys, and refetch-on-remount behavior. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The activity hooks (
apps/web/src/hooks/use-activity.ts) power the entire activity/stats pane but had zero direct test coverage. This addsuse-activity.test.tsx(27 tests) covering the pure range logic and the query-hook wiring, closing the last item of the 2026-07-31 ranked web coverage queue.What is pinned
getRangeBounds, all five ranges: explicit daily date → local midnight through next local midnight; daily end lands on the next calendar midnight across a DST transition (2026-03-08), not start+24h; the default daily date is derived from the UTC date but parsed as local midnight (documented product quirk, pinned at an instant where the two disagree west of UTC); year starts at local Jan 1; 7d/30d are exact rolling epoch windows; all-time returns empty bounds.tzalways sent;start/endomitted entirely for all-time;useActiveHourssends raw bounds with no granularity param (distinct from the other endpoints).days, token-by-model→models, token-by-project / working-time-by-project→projects; four passthrough endpoints return the payload as-is.refetchOnMount: "always"refetches on remount while fresh.All timezone assertions are written relative to the ambient zone (the module captures
LOCAL_TZat import), verified to hold in both America/Denver and UTC.Validation
calledUrlhelper), 1 nit applied (dropped unnecessary casts).pnpm run check, full unit suite (server 2394 / web 617 / ext 60 / scripts 4),pnpm run finalize:web, inert E2E 175 passed / 12 skipped, live lane 11 passed — all green.🤖 Generated with Claude Code