Skip to content

test: add unit tests for agent hooks and page components #875

@Aureliolo

Description

@Aureliolo

Context

PR #874 added the Agent Profiles list and detail pages with thorough store/utility/property tests (78 new tests). However, the data composition hooks and page components have no unit tests.

Missing test files

Critical (established precedent in Dashboard page)

  1. web/src/__tests__/hooks/useAgentsData.test.ts -- follow useDashboardData.test.ts pattern: mock useWebSocket, mock usePolling, verify mount fetch, verify channel bindings, verify return shape
  2. web/src/__tests__/hooks/useAgentDetailData.test.ts -- verify mount/unmount lifecycle (clearDetail on unmount), derived data memoization, fetchMoreActivity offset calculation
  3. web/src/__tests__/pages/AgentsPage.test.tsx -- follow DashboardPage.test.tsx pattern: mock the hook, test loading/error/normal rendering states
  4. web/src/__tests__/pages/AgentDetailPage.test.tsx -- test skeleton/not-found/full-render states, verify useParams integration

Important

  1. ActivityLog.test.tsx -- verify load-more button visibility and click handler
  2. AgentGridView.test.tsx -- verify empty state and link URL encoding
  3. AgentFilters.test.tsx -- verify store integration and empty-to-null mapping

Acceptance criteria

  • All 4 critical test files created following existing patterns
  • At least 3 important test files created
  • All tests pass with npm --prefix web run test

Found during PR #874 review (pr-test-analyzer agent).

Metadata

Metadata

Assignees

No one assigned

    Labels

    spec:human-interactionDESIGN_SPEC Section 13 - Human Interaction Layertype:testTest coverage, test infrastructurev0.5Minor version v0.5v0.5.0Patch release v0.5.0

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions