Skip to content

test(integrations): add dedicated integration test suite for integrationsRepository#912

Merged
aaight merged 2 commits intodevfrom
feature/integration-tests-integrations-repository
Mar 16, 2026
Merged

test(integrations): add dedicated integration test suite for integrationsRepository#912
aaight merged 2 commits intodevfrom
feature/integration-tests-integrations-repository

Conversation

@aaight
Copy link
Copy Markdown
Collaborator

@aaight aaight commented Mar 16, 2026

Summary

  • Adds tests/integration/db/integrationsRepository.test.ts — 33 integration tests for the integrationsRepository module
  • Covers the functions not fully tested by the existing repositories-edge-cases.test.ts: listProjectIntegrations, getIntegrationByProjectAndCategory, deleteProjectIntegration, and removeIntegrationCredential
  • Tests role-to-envVarKey mapping in removeIntegrationCredential for all providers (Trello, JIRA, GitHub)
  • Verifies JSONB config round-trip for Trello and JIRA config shapes
  • Verifies unique constraint behavior (one PM + one SCM per project) via upsert semantics

Card: https://trello.com/c/69b8004910366990f4ee4c95

Test plan

  • listProjectIntegrations — empty list, multi-integration list, project isolation
  • getIntegrationByProjectAndCategory — null when missing, correct lookup, category isolation, project isolation
  • upsertProjectIntegration — insert new, update on conflict, preserve triggers when omitted, explicit trigger set, returns row
  • deleteProjectIntegration — removes correct integration, no-op when absent, doesn't affect other projects
  • Full CRUD lifecycle test
  • updateProjectIntegrationTriggers — flat key merge, nested object merge, add new keys, throws when integration absent
  • removeIntegrationCredential — maps api_keyTRELLO_API_KEY, tokenTRELLO_TOKEN, emailJIRA_EMAIL, api_tokenJIRA_API_TOKEN, implementer_tokenGITHUB_TOKEN_IMPLEMENTER; no-op for unknown role; no-op for missing integration id
  • JSONB config round-trip for Trello (boardId, nested lists/labels) and JIRA (projectKey, baseUrl, statuses)
  • Unique constraint: only one PM per project, only one SCM per project, both can coexist, different projects independent
  • All 33 tests pass; all 289 existing unit test files pass; lint and typecheck clean

🤖 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

Solid, well-structured integration test suite. The 33 tests are thorough and well-organized, covering CRUD, upsert semantics, trigger deep-merge, credential role mapping, JSONB round-trips, and unique constraint enforcement. No blocking issues.

Should Fix

  • tests/integration/db/integrationsRepository.test.ts:10deleteProjectCredential is imported from credentialsRepository but never used in any test. Should be removed to keep imports clean.

Notes

  • There is intentional overlap with repositories-edge-cases.test.ts (upsert insert/update, trigger merge, unique constraint). Since the edge-cases file imports via the barrel settingsRepository.ts which re-exports integrationsRepository.ts, these test the same code paths. The new file adds genuinely new coverage (deleteProjectIntegration, removeIntegrationCredential role mapping for all providers, JSONB config round-trip, CRUD lifecycle), so the overlap is acceptable — but worth noting that ~8 tests duplicate scenarios already covered.
  • Test quality is high: proper isolation via truncateAll() + beforeEach, good negative cases (no-op on missing data, project isolation), and assertions verify both the changed and unchanged state (e.g., checking other credentials remain after removing one).

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

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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 — well-structured, comprehensive integration test suite for integrationsRepository that fills genuine coverage gaps (especially deleteProjectIntegration, removeIntegrationCredential role mappings, and getIntegrationByProjectAndCategory isolation). All CI checks pass.

Minor Observations

Test overlap with repositories-edge-cases.test.ts

The upsertProjectIntegration (insert/update/preserve triggers), updateProjectIntegrationTriggers (flat merge, nested merge, throws-when-missing), and unique constraint tests are already covered in repositories-edge-cases.test.ts. This isn't blocking — having a dedicated, focused test file for the module is the right direction — but worth being aware of for future cleanup. If the intent is to eventually make integrationsRepository.test.ts the canonical test location for these functions, consider removing the duplicated scenarios from repositories-edge-cases.test.ts in a follow-up to reduce integration test runtime.

upsertProjectIntegration type signature vs nested triggers

The triggers parameter of upsertProjectIntegration is typed as Record<string, boolean>, but the nested trigger tests (e.g., line ~290: { issueTransitioned: { splitting: true, planning: true, implementation: true } }) pass objects where values are Record<string, boolean> rather than boolean. This works at runtime because JSONB accepts any JSON, and it isn't flagged by CI because tsconfig.json scopes typecheck to src/ only. Not a problem introduced by this PR (the same pattern exists in repositories-edge-cases.test.ts), but the source type could be widened to Record<string, unknown> to match reality.

Neither observation blocks merge.

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

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