feat(tests): add integration tests for triggers, webhooks, credentials, and personas#551
Conversation
|
🤖 Just a sec, looking into that PR for you Progress: [██░░░░░░░░] 16% (iteration 11/70) 🔧 CI Fix Update (1 min) I've identified that the CI failures are due to a Last updated: iteration 11 · respond-to-ci |
CI Failure AnalysisRoot CauseBoth failing CI checks ( This is an npm registry infrastructure issue, not related to the code changes in this PR. VerificationAll checks pass locally:
Action Taken
|
|
🤖 Just a sec, looking into PR #551 now Progress: [███░░░░░░░] 34% (iteration 24/70) 🔍 Code Review Update (1 min) I've completed a thorough review of the provided code, focusing on identifying unused imports and ensuring proper test cleanup. I've noted that Last updated: iteration 24 · review |
nhopeatall
left a comment
There was a problem hiding this comment.
Summary
LGTM — Well-structured integration test suite covering important areas (triggers, webhooks, credentials, personas, PM provider switching, and DB edge cases). Tests are thorough, properly isolated via truncateAll() in beforeEach, and CI is green.
Should Fix (non-blocking)
-
Unused imports in
repositories-edge-cases.test.ts:eq(from drizzle-orm),getDb, andorganizations(from schema) are imported but never used. These are likely leftover from an earlier iteration and will be flagged by stricter lint rules if enabled. Not blocking since lint CI passes. -
assertFound<T>()duplicated across 3 files: The identical helper function is copy-pasted intrigger-registry.test.ts,github-personas.test.ts, andpm-provider-switching.test.ts. Consider extracting it totests/integration/helpers/alongside the existingdb.tsandseed.tshelpers, especially since the PR description mentions it as a deliberate pattern for Biome compliance.
| import { eq } from 'drizzle-orm'; | ||
| import { beforeEach, describe, expect, it } from 'vitest'; | ||
| import { getDb } from '../../../src/db/client.js'; | ||
| import { loadConfigFromDb } from '../../../src/db/repositories/configRepository.js'; |
There was a problem hiding this comment.
Nit: getDb, eq (line 8), and organizations (line 31) are imported but never used in this file. These are likely leftovers from development.
There was a problem hiding this comment.
Fixed — removed unused eq, getDb, and organizations imports in e7c6f7e.
| } from '../../src/db/repositories/configRepository.js'; | ||
|
|
||
| /** Assert that a value is defined (not null/undefined), throwing if not. */ | ||
| function assertFound<T>(value: T | null | undefined, msg = 'Expected value to be defined'): T { |
There was a problem hiding this comment.
Nit: assertFound is duplicated identically in 3 test files (here, github-personas.test.ts:30, and pm-provider-switching.test.ts:26). Consider extracting it to tests/integration/helpers/ alongside seed.ts and db.ts.
There was a problem hiding this comment.
Fixed — extracted assertFound<T>() to tests/integration/helpers/assert.ts and updated all 3 test files to import from the shared module in e7c6f7e.
|
@aaight address code review concerns |
Request AddressedWhat was askedAddress code review concerns from the PR review. Changes Made
Verification
|
Remove unused `eq`, `getDb`, and `organizations` imports from repositories-edge-cases.test.ts. Extract duplicated `assertFound<T>()` helper from 3 test files into tests/integration/helpers/assert.ts. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
🤖 On it — checking the integration tests for PR 551 Progress: [███░░░░░░░] 29% (iteration 20/70) 🔍 Code Review Update (1 min) I've completed my review of PR #551, focusing on the integration tests for triggers. I examined existing integration test patterns and compared the new webhook-logging test with Last updated: iteration 20 · review |
nhopeatall
left a comment
There was a problem hiding this comment.
Summary
LGTM — Well-structured integration tests that meaningfully extend coverage across triggers, webhooks, credentials, and personas. Tests follow established patterns (seed helpers, truncateAll, beforeEach isolation) and CI is green.
Observations
Minor duplication with existing tests (not blocking)
The new webhook-logging.test.ts has significant overlap with the existing tests/integration/db/webhookLogsRepository.test.ts — both test insertWebhookLog, listWebhookLogs filtering/pagination, pruneWebhookLogs, getWebhookLogStats, and getWebhookLogById. The new file adds a few extra cases (per-source logs for GitHub/JIRA, bodyRaw, seedWebhookLog helper) but ~70% of the test surface is duplicated. Similarly, some credential resolution tests overlap with credentialResolution.test.ts. This isn't harmful — it just adds execution time without proportional coverage gain. Could be consolidated in a future cleanup pass.
Test quality
- Good use of
assertFound<T>()helper to avoid non-null assertions — clean alternative to!that complies with Biome rules vi.stubEnv()for encryption tests is the right approach (scoped to test, auto-restored)- Dynamic
import()in encryption tests is a reasonable workaround to pick up the stubbed env var - The
pm-provider-switching.test.ts"defaults to Trello" test (line ~140) manually reimplements the default logic instead of callingcreatePMProvider— it's technically testing its own code rather than the actual registry, but the intent is documented in comments and it's a minor observation
|
@aaight The new webhook-logging.test.ts has significant overlap with the existing tests/integration/db/webhookLogsRepository.test.ts — both test insertWebhookLog, listWebhookLogs filtering/pagination, pruneWebhookLogs, getWebhookLogStats, and getWebhookLogById. The new file adds a few extra cases (per-source logs for GitHub/JIRA, bodyRaw, seedWebhookLog helper) but ~70% of the test surface is duplicated. Similarly, some credential resolution tests overlap with credentialResolution.test.ts. This isn't harmful — it just adds execution time without proportional coverage gain. Could be consolidated |
|
🤔 Let me dig into that test duplication issue Progress: [██████░░░░] 57% (iteration 40/70) 💬 PR Comment Response Update (4 min) I've successfully consolidated duplicate integration tests, removing 449 lines of code and adding 17 lines for file headers/comments. All unit tests and pre-commit hooks passed. I've pushed the changes to the repository and am now updating the PR comments to reflect the completed task. Last updated: iteration 40 · respond-to-pr-comment |
Remove ~70% duplicated test surface from webhook-logging.test.ts and multi-provider-credentials.test.ts that overlapped with existing webhookLogsRepository.test.ts, credentialsRepository.test.ts, and credentialResolution.test.ts. Kept only the unique value-add tests: - webhook-logging: per-source GitHub/JIRA logs, bodyRaw, project resolution - multi-provider-credentials: multi-project isolation, PM/SCM isolation, dual-persona tokens, 3-project cross-contamination checks Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Consolidated in e28342a. Removed ~70% of duplicated test surface (449 lines removed):
|
|
🤖 On it — checking the integration tests for PR 551 Progress: [████░░░░░░] 40% (iteration 28/70) 🔍 Code Review Update (review) [████░░░░░░] 40% (iteration 28/70) Last updated: iteration 28 · review |
nhopeatall
left a comment
There was a problem hiding this comment.
Summary
LGTM — Well-structured integration test suite that covers important untested areas (triggers, credentials, personas, PM switching, webhook logging) with real DB-backed configurations. Tests are passing, CI is green, and the code follows existing patterns.
Notes
A few minor observations (not blocking):
-
repositories-edge-cases.test.ts— Some overlap with existing tests: The "organization settings" and "cascade defaults upsert" sections partially duplicate what's already tested insettingsRepository.test.ts(updateOrganization,getOrganization,upsertCascadeDefaults). The edge-case framing (e.g., testing vialoadConfigFromDbrather thangetCascadeDefaults) adds value, but worth noting the overlap. -
pm-provider-switching.test.ts:140-152— "defaults to Trello" test doesn't exercisecreatePMProvider: The test manually replicates thepm.type ?? 'trello'logic inline rather than callingcreatePMProvider()orpmRegistry.createProvider(). This makes the test a tautology — it's testing its own implementation rather than the production code. A real integration test would construct a minimalProjectConfigand pass it tocreatePMProvider(). -
github-personas.test.ts:289-304&pm-provider-switching.test.ts:315-329— Conditional assertions: Several tests useif (trigger.matches(ctx)) { ... } else { expect(trigger.matches(ctx)).toBe(false); }which always passes regardless of whethermatches()returns true or false. This weakens the assertion — if the behavior changes, the test silently takes the other branch rather than failing. In cases where you expect a specific outcome, assert it directly. -
assertFoundhelper is clean: Good approach to comply with Biome'snoNonNullAssertionrule while maintaining type narrowing. The error messages could be more specific (e.g.,assertFound(project, 'Project not found for board-123')) but the default is fine for test code.
Overall, the test coverage additions are valuable and well-organized. The resolveIntegrationCredential usage (DB-direct, bypassing env vars) is a smart choice for test isolation, and the credential isolation/cross-contamination tests cover important security-relevant behavior.
|
@aaight address the minor observations |
Request AddressedWhat was askedAddress the minor observations from the code review. Changes Made
Not changed (informational observations)
Verification
|
…ercise createPMProvider - Replace if/else conditional assertions in github-personas and pm-provider-switching tests with direct expect() calls that fail if behavior changes (addresses review observation #3) - Replace manual pm.type ?? 'trello' reimplementation with actual createPMProvider() call in "defaults to Trello" test (addresses review observation #2) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Addressed in 0c5042c. Two changes:
These changes ensure tests will actually fail if the behavior changes, rather than silently taking the other branch. |
|
🤖 On it — checking the CI failures for PR 551 Progress: [███░░░░░░░] 26% (iteration 18/70) 🔧 CI Fix Update (1 min) I've identified that the CI failure was due to a transient Last updated: iteration 18 · respond-to-ci |
|
🤖 On it — checking the integration tests for PR 551 Progress: [████░░░░░░] 40% (iteration 28/70) 🔍 Code Review Update (1 min) Last updated: iteration 28 · review |
nhopeatall
left a comment
There was a problem hiding this comment.
Summary
LGTM — Well-structured integration tests covering important areas (triggers, webhooks, credentials, personas, PM provider switching). The tests use real DB-backed configs, follow existing patterns, and CI passes cleanly.
Notes
- The
assertFound<T>()helper is a clean approach to satisfy Biome'snoNonNullAssertionrule while providing better error messages than!. - Tests correctly trace the full data flow: seed integration → DB-backed
ProjectConfig(viaconfigMapper) → triggermatches()/handle()— validating the real resolution pipeline rather than just mocking. - The decision to use
resolveIntegrationCredential(DB-direct) instead ofgetIntegrationCredential(checks env first) is the right call for test isolation. - Minor:
repositories-edge-cases.test.ts:278uses a dynamicimport()forresolveIntegrationCredentialeven though a static import at the top of the file would be cleaner. Not blocking. - Some tests in
repositories-edge-cases.test.ts(getOrganizationnull check,updateOrganization) overlap with existingsettingsRepository.test.ts, but the new file's value is in the edge cases (4-level config cascade, deep merge, cascade deletes) not the basic CRUD tests.
Summary
Adds 6 new integration test files covering key areas of the CASCADE platform that lacked integration test coverage. These tests complement the existing 9 DB repository tests and bring the total integration test count from 155 to 267.
tests/integration/trigger-registry.test.ts(17 tests): TriggerRegistry core operations, Trello card-moved/label triggers with real DB config, and config toggle behaviortests/integration/webhook-logging.test.ts(21 tests): WebhookLog CRUD, filtering, stats aggregation, and pruningtests/integration/multi-provider-credentials.test.ts(14 tests): Per-project credential isolation, PM/SCM isolation, dual-persona token resolution,resolveAllIntegrationCredentials, and encryption round-tripstests/integration/db/repositories-edge-cases.test.ts(22 tests): 4-level agent config cascade, credential CRUD,upsertProjectIntegration,updateProjectIntegrationTriggersdeep merge, cascade deletes, andupsertCascadeDefaultstests/integration/github-personas.test.ts(26 tests): Persona token resolution from DB,isCascadeBot()with[bot]suffix variants,getPersonaForLogin(),getPersonaForAgentType(), PRReviewSubmittedTrigger loop prevention, and ReviewRequestedTrigger modestests/integration/pm-provider-switching.test.ts(12 tests):createPMProviderprovider type detection, Trello→JIRA provider switching, Trello and JIRA trigger dispatch with real DB config, andpmRegistryoperationsKey decisions
resolveIntegrationCredentialandresolveOrgCredential(DB-direct) instead ofgetIntegrationCredential/getOrgCredentialwhich checkprocess.envfirst, to avoid env var interference in testsassertFound<T>()helper instead of non-null assertions (!) to comply with Biome'snoNonNullAssertionruleuq_project_integrations_project_categoryprevents two PM integrations per project)MY_UNIQUE_CUSTOM_TEST_KEY_XYZ) to avoid collision with environment variables present in the test environmentTest plan
npm run test:integration)npm run lint)npm run typecheck)Card: https://trello.com/c/699f2e4ad32b60324c8a9d01
🤖 Generated with Claude Code