Skip to content

Cover the service-resources web helpers and hooks - #833

Merged
selfcontained merged 1 commit into
mainfrom
agt_0845f6728538/job-test-enforcer-a02cbb82
Jul 26, 2026
Merged

Cover the service-resources web helpers and hooks#833
selfcontained merged 1 commit into
mainfrom
agt_0845f6728538/job-test-enforcer-a02cbb82

Conversation

@selfcontained

Copy link
Copy Markdown
Owner

Summary

  • Adds the first unit coverage for the Add service resources dashboard #823 service-resources web side (the server side already has service-resources.test.ts + subsystem-tracker.test.ts; the web helpers/hooks had zero tests).
  • service-resources-format.test.ts (18 tests): formatBytes null/, <1024 passthrough, KB→TB unit ladder incl. the above-TB clamp, and the >=10 → toFixed(0) vs toFixed(1) decimal threshold; formatMs null/<1 ms/rounding/seconds branches; formatUptime d+h / h+m / m-only tiers; stateLabel degraded special case; the full 7-state stateBadgeVariant mapping; metadataLabel camelCase splitting.
  • use-service-resources.test.tsx (9 tests): per-window query keys and request URLs, placeholder data retained across window switches, mutation POST payload asserted from the actual request body, optimistic disable clearing series/history across every cached window, optimistic enable preserving history, empty-cache no-op, full rollback on POST failure, and post-settle invalidation.

Verification

  • 13-mutant battery against both source files: 13/13 caught (unit thresholds, branch drops, hardcoded window, optimistic-update gate, rollback loop, invalidation, POST payload, placeholderData).
  • One general review agent pass on the diff; its must-fix (explicit RTL cleanup() in afterEach — this repo has no vitest auto-cleanup, and a mounted observer's 15s refetchInterval could consume a later test's mock queue) and nits (mutations wrapped in act(), dropped an impossible-cast assertion, fixed a mischaracterized test name) are applied.
  • pnpm run check, full unit suite (web 416 pass), pnpm run finalize:web, pnpm run lint:web (0 errors), E2E 170 pass / 12 skip — all green locally.

🤖 Generated with Claude Code

Adds unit coverage for the #823 service-resources web side, which had
none: service-resources-format.ts (formatBytes unit ladder + decimal
threshold, formatMs branches, formatUptime d/h/m tiers, stateLabel,
the full stateBadgeVariant mapping, metadataLabel camelCase split) and
use-service-resources.ts (per-window query keys + URL, placeholder
data across window switches, mutation POST payload, optimistic
disable/enable across every cached window, error rollback, and
post-settle invalidation). Verified non-vacuous with a 13-mutant
battery (13/13 caught).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@selfcontained
selfcontained merged commit 340dd0b into mainJul 26, 2026
1 check passed
@selfcontained
selfcontained deleted the agt_0845f6728538/job-test-enforcer-a02cbb82 branch July 26, 2026 02:14
Sign up for freeto 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.

1 participant

@selfcontained