Skip to content

test: add coverage for agents API, agent service, task-run repo, meeting analytics, and SSE health payload#28

Merged
JLRansom merged 1 commit into
masterfrom
test/update-coverage-latest
Mar 19, 2026
Merged

test: add coverage for agents API, agent service, task-run repo, meeting analytics, and SSE health payload#28
JLRansom merged 1 commit into
masterfrom
test/update-coverage-latest

Conversation

@JLRansom
Copy link
Copy Markdown
Owner

Summary

  • Exports buildSystemPrompt and buildUserPrompt from agentService.ts as testable pure helpers (no behaviour change)
  • Adds makeTestAgent and makeTestMeeting factory helpers to __tests__/helpers/test-utils.ts
  • 5 new test files covering all gaps identified in the spec:
File Tests What's covered
__tests__/integration/agents-api.test.ts 8 GET/POST /api/agents — happy paths, validation (missing fields, invalid type enum), 404 on non-existent project
__tests__/unit/task-run-repo.test.ts 14 dbGetTaskRunsByAgent (filtering, isolation, ordering, shape) + dbGetRecentTaskRunsByAgent (time boundary, empty window, boundary-inclusive, cross-agent isolation)
__tests__/unit/meeting-analytics.test.ts 7 dbGetMeetingAnalytics — empty project, token/cost aggregation, daily grouping, concluded-only filter, project isolation, date range, null-field handling
__tests__/unit/agent-service.test.ts 13 buildSystemPrompt (role-specific content, distinctness), buildUserPrompt (context injection, directory, role-specific sections), double-scheduling guard in assignAgentToTask
__tests__/integration/stream-health-payload.test.ts 5 getStreamPayload().agentHealth — key presence, per-agent entry, AgentHealthMetrics shape, hasEnoughData: false for sparse agents, hasEnoughData: true with populated metrics for rich agents

Result: 161 → 213 tests, all passing. Zero new type errors.

Design decisions

  • buildSystemPrompt/buildUserPrompt are exported with export function — smallest possible surface-area change to make pure logic directly testable.
  • makeTestMeeting messages use meeting.id (post-spread) for meetingId FK, not the pre-spread local variable — avoids FK constraint failures when callers pass an id override.
  • seedMeeting in the meeting analytics test calls dbUpdateMeetingMessage after dbAddMeetingMessage for token/cost fields — mirroring how production code sets stats after streaming completes.
  • Stream health test anchors timestamps to Date.now() (not a fixed past date) so runs always fall within the 7-day rolling window regardless of when the suite runs.

Test plan

  • npm run test:run — 213/213 passing
  • npm run type-check — no new errors (5 pre-existing errors unchanged)

🤖 Generated with Claude Code

…ing analytics, and SSE health payload

- Export buildSystemPrompt and buildUserPrompt from agentService.ts as pure helpers for direct testing
- Add makeTestAgent and makeTestMeeting factory helpers to test-utils.ts
- New: __tests__/integration/agents-api.test.ts — 8 tests covering GET/POST /api/agents (happy path, validation errors, 404 on missing project)
- New: __tests__/unit/task-run-repo.test.ts — 14 tests for dbGetTaskRunsByAgent and dbGetRecentTaskRunsByAgent (filtering, isolation, boundary conditions, shape validation)
- New: __tests__/unit/meeting-analytics.test.ts — 7 tests for dbGetMeetingAnalytics (empty project, token/cost sums, daily grouping, status filter, project isolation, date range, null handling)
- New: __tests__/unit/agent-service.test.ts — 13 tests for buildSystemPrompt, buildUserPrompt, and the double-scheduling guard in assignAgentToTask
- New: __tests__/integration/stream-health-payload.test.ts — 5 tests verifying agentHealth map shape, per-agent entry presence, and hasEnoughData flag for sparse vs. rich agents

Total: 213 tests (161 → +52), all passing.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@JLRansom JLRansom merged commit 6d22d4b into master Mar 19, 2026
2 checks passed
@JLRansom JLRansom deleted the test/update-coverage-latest branch March 19, 2026 02:38
Sign up for free to 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