Skip to content

test(integration): add agentDefinitionsRepository integration tests#911

Merged
aaight merged 1 commit intodevfrom
feature/integration-tests-agent-definitions-repository
Mar 16, 2026
Merged

test(integration): add agentDefinitionsRepository integration tests#911
aaight merged 1 commit intodevfrom
feature/integration-tests-agent-definitions-repository

Conversation

@aaight
Copy link
Copy Markdown
Collaborator

@aaight aaight commented Mar 16, 2026

Summary

  • Adds a full integration test suite for agentDefinitionsRepository covering all CRUD operations, Zod validation, and upsert semantics
  • Adds seedAgentDefinition() helper to tests/integration/helpers/seed.ts with a minimal valid AgentDefinition
  • Adds agent_definitions table to truncateAll() in tests/integration/helpers/db.ts for test isolation

Changes

New: tests/integration/db/agentDefinitionsRepository.test.ts

28 integration tests covering:

  • upsertAgentDefinition (create): creates a definition, validates via Zod, rejects invalid definitions (empty taskPrompt, missing capabilities, duplicate capabilities), defaults isBuiltin to false, stores isBuiltin: true when explicitly set
  • upsertAgentDefinition (update semantics): same agentType updates, not duplicates; isBuiltin flag updates; multiple distinct types create separate entries
  • getAgentDefinition: returns null for missing, retrieves correctly, returns Zod-parsed type
  • listAgentDefinitions: empty array, full list, field shape, Zod-parsed entries
  • deleteAgentDefinition: removes entry, does not affect others, idempotent
  • Zod validation round-trip: full definition survives JSONB round-trip; Zod defaults applied on read; invalid capability rejected
  • seedAgentDefinition helper: all override paths tested

Modified: tests/integration/helpers/seed.ts

  • Added MINIMAL_AGENT_DEFINITION constant — a valid AgentDefinition fixture
  • Added seedAgentDefinition(overrides?) helper

Modified: tests/integration/helpers/db.ts

  • Added agent_definitions to the TRUNCATE TABLE statement in truncateAll()

Test plan

  • New integration test file: 28 tests, all passing
  • Full unit test suite: 5415 tests, all passing
  • Lint: no errors
  • TypeScript: no errors

Card

https://trello.com/c/69b8006de55e14a70861b8d8

🤖 Generated with Claude Code

🕵️ claude-code · claude-sonnet-4-6 · run details

Copy link
Copy Markdown
Collaborator

@nhopeatall nhopeatall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

LGTM — Clean, well-structured integration test suite for agentDefinitionsRepository that follows existing patterns in the codebase. All CI checks pass. Tests cover CRUD, upsert semantics, Zod validation round-trips, and the seed helper — comprehensive coverage.

Code Issues

Should Fix

  • tests/integration/db/agentDefinitionsRepository.test.ts:32result?.hints tests a non-existent property (the schema field is hint, singular). This assertion will always pass trivially since hints is never a property on AgentDefinition. Should be result?.hint if the intent is to verify the field value, or removed entirely if not testing anything meaningful. (Not caught by TypeScript because tests/ is excluded from tsconfig.json's include.)

Nitpick

  • tests/integration/helpers/seed.ts:340-345seedAgentDefinition does shallow merge (...MINIMAL_AGENT_DEFINITION, ...overrides.definition), meaning partial nested overrides (e.g., { identity: { emoji: '⭐' } } without other identity fields) would silently drop required fields and fail at Zod validation. The current tests always provide complete nested objects so this works fine today, but a brief JSDoc note about "overrides replace entire top-level fields, not deep-merge" could save future confusion.

🕵️ claude-code · claude-opus-4-6 · run details

@aaight aaight merged commit 6516316 into dev Mar 16, 2026
6 checks passed
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.

2 participants