test(pm-discovery): cover error branches from resolvePMCredentials refactor#1187
Merged
zbigniewsobiecki merged 1 commit intodevfrom Apr 24, 2026
Merged
Conversation
…ntials refactor #1184 extracted `promoteConfigCredentials` + `loadIntegrationAndManifest` helpers but added five guard branches none of the new tests exercised (codecov patch coverage on that PR was 58.33%, below the 80% target). This commit pins each branch directly so the patch is in the green: - UNAUTHORIZED when projectId is set but effectiveOrgId is null - NOT_FOUND when no PM integration is configured for the project - NOT_FOUND when the saved integration belongs to a different provider - configToCredentials returning a non-object (string/null/array) is silently coerced to empty — resolved bag ends up project_credentials-only - configToCredentials throwing is swallowed with a console.warn; discovery still returns project_credentials — a broken hook cannot brick the wizard All five are behavioural contracts the original `resolvePMCredentials` upheld through inline conditionals; the refactor preserved them but moved them into the helpers. These tests make the contract explicit. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Five new unit tests pinning the guard branches introduced in #1184's
resolvePMCredentialsrefactor. The refactor preserved behaviour but moved the guards into helper functions (promoteConfigCredentials,loadIntegrationAndManifest) that the new tests didn't reach, dropping codecov patch coverage to 58.33% on that PR.Branches pinned
projectIdis set buteffectiveOrgIdis nullconfigToCredentialsreturning a non-object is silently coerced to emptyconfigToCredentialsthrowing is swallowed with aconsole.warn; discovery still returns project_credentials (so a broken hook cannot brick the wizard)Test plan
npx vitest run --project unit-api tests/unit/api/pm-discovery.test.ts— 27 pass (+5 new)npm run typecheck— cleannpm run lint— clean🤖 Generated with Claude Code