Skip to content

test(db): add integration tests for agentTriggerConfigsRepository#904

Merged
aaight merged 1 commit intodevfrom
feature/integration-tests-agent-trigger-configs-repo
Mar 16, 2026
Merged

test(db): add integration tests for agentTriggerConfigsRepository#904
aaight merged 1 commit intodevfrom
feature/integration-tests-agent-trigger-configs-repo

Conversation

@aaight
Copy link
Copy Markdown
Collaborator

@aaight aaight commented Mar 16, 2026

Summary

  • Add full integration test suite (tests/integration/db/agentTriggerConfigsRepository.test.ts) covering all repository functions for agentTriggerConfigs
  • 32 test cases covering CRUD, upsert conflict resolution, bulk transactional upsert, JSONB round-trips, cascade deletes, and cross-project isolation
  • Follows established patterns: beforeEach with truncateAll() + seedOrg() + seedProject(), uses seedTriggerConfig() helper from tests/integration/helpers/seed.ts

Test coverage

  • CRUD: upsertTriggerConfig creates new records with correct defaults; getTriggerConfig / getTriggerConfigById retrieve by composite key and primary key; updateTriggerConfig modifies enabled and parameters; deleteTriggerConfig removes by ID and returns boolean
  • Upsert conflict resolution: Upserting the same (projectId, agentType, triggerEvent) updates the existing row instead of creating a duplicate
  • Bulk upsert: bulkUpsertTriggerConfigs inserts/updates multiple configs in a single transaction; handles empty input gracefully
  • JSONB round-trip: Nested parameter objects ({ authorMode, threshold, nested: { labels, priority }, flag }) persist and read back correctly through both upsertTriggerConfig and updateTriggerConfig
  • Cascade delete: Deleting a project via FK removes all its trigger configs (ON DELETE CASCADE)
  • Cross-project isolation: getTriggerConfigsByProject, getTriggerConfig, getTriggerConfigsByProjectAndAgent, and deleteTriggerConfigsByProject all scope results to the specified project

Test plan

  • All 32 new integration tests pass
  • All 5404 existing unit tests pass
  • Lint passes (biome check — no errors)
  • TypeScript type check passes (zero errors)

Trello card: https://trello.com/c/7Gw8RnEY/418-as-a-developer-i-want-integration-tests-for-agenttriggerconfigsrepository-so-that-crud-upsert-conflicts-bulk-operations-and-cros

🤖 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.

LGTM — Thorough integration test suite that follows established project patterns (beforeEach with truncateAll/seedOrg/seedProject, consistent use of seedTriggerConfig helper). All 10 repository functions are well-covered with 32 test cases spanning CRUD, upsert conflict resolution, bulk operations, JSONB round-trips, cascade deletes, and cross-project isolation. CI is green across all checks.

One minor stylistic note (not blocking): the cascade delete test uses dynamic await import(...) for getDb, projects, and eq (lines 497-499) while all other integration tests use static imports at the top of the file. This works correctly but is inconsistent with the rest of the test suite. Not worth holding up the PR.

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

@aaight aaight merged commit ad11ba8 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