Skip to content

Add unit coverage for the #752 agents-view routing/hook layer - #847

Merged
selfcontained merged 1 commit into
mainfrom
agt_de1bb3990c8b/job-test-enforcer-8cf1e70b
Jul 29, 2026
Merged

Add unit coverage for the #752 agents-view routing/hook layer#847
selfcontained merged 1 commit into
mainfrom
agt_de1bb3990c8b/job-test-enforcer-8cf1e70b

Conversation

@selfcontained

Copy link
Copy Markdown
Owner

Summary

Recurring test-enforcer run. Local suite was green on first pass (10th consecutive run): check ok; unit server 2362 pass / 8 skip, web 481→500, extension 60, scripts 4; E2E 174 pass / 12 skip (run twice, 1.1m). CI scan clean — all recent failures are known branch-local issues, no flakes. With the suite stable, this run closes the next_focus coverage gap: the #752 whiteboard-era routing/hook layer, previously untested.

Tests added (19 → 18 after review dedup)

  • apps/web/src/lib/agent-routes.test.ts — pins the three agent URL helpers to their literal paths, the contract shared by the router config in App.tsx, the useMatch patterns, and every navigate() call site.
  • apps/web/src/hooks/use-agents-view-routing.test.tsx (11 tests) — drives the hook through a real MemoryRouter with a location/navigate probe instead of mocking the router:
    • invalid-agent redirect: waits for agentsLoaded, respects a validated id, no-ops on bare /agents, and its replace: true semantics are probed by clearing routeAgentId (mirroring useParams after the redirect) and asserting back-navigation cannot resurrect the dead agent URL
    • legacy /feedback/:itemId and /review/:summaryAgentId deep links collapse onto the agent route, gated on load
    • changesMatch/whiteboardMatch flags for all three tab locations
    • onTabChange navigation across all three tabs, its replace-not-push history behavior, and the no-route-agent no-op
  • apps/web/src/hooks/use-whiteboard.test.tsx (6 tests) — query-key shape, enabled gate stays idle on a null agent id, versioned endpoint URL asserted, null→id transition starts the fetch, staleTime: Infinity remount serves cache without refetching, and per-agent cache separation.

Verification

  • 13-mutant battery against the three source files: 13/13 caught. One mutant (dropping replace: true from the invalid-agent redirect) initially survived because the redirect effect re-fires and masks the pushed entry; the test was strengthened with a double back-navigation probe rather than weakening the assertion.
  • Review agent pass: 0 must-fix, 1 should-fix (explicit apiMock.mockReset() in afterEachvi.restoreAllMocks() stops resetting module-factory vi.fn() mocks in vitest 3), applied along with two nits (removed a redundant assertion-implied test, replaced an as Promise<never> cast with typed mockResolvedValueOnce queues).
  • Full validation after fixes: unit suites green, finalize:web clean, E2E 174 pass / 12 skip.

🤖 Generated with Claude Code

Covers the previously untested whiteboard-era routing pieces:
- agent-routes.test.ts pins the three agent URL helpers to their literal
paths (the contract shared by the router config, useMatch patterns, and
navigate call sites).
- use-agents-view-routing.test.tsx drives the hook through a real
MemoryRouter: invalid-agent redirect gating (loading / validated id) and
its replace semantics probed via history back-navigation, legacy
feedback/review deep-link collapse, tab match flags, and onTabChange
navigation including its replace behavior and no-agent no-op.
- use-whiteboard.test.tsx covers the query-key shape, the enabled gate on
a null agent id, the versioned endpoint URL, staleTime-Infinity remount
caching, and per-agent cache separation.
A 13-mutant battery against the three source files is fully caught.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@selfcontained
selfcontained merged commit 7780b8d into mainJul 29, 2026
1 check passed
@selfcontained
selfcontained deleted the agt_de1bb3990c8b/job-test-enforcer-8cf1e70b branch July 29, 2026 02:22
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