Skip to content

test(pm-discovery): cover error branches from resolvePMCredentials refactor#1187

Merged
zbigniewsobiecki merged 1 commit intodevfrom
chore/boost-pm-discovery-coverage
Apr 24, 2026
Merged

test(pm-discovery): cover error branches from resolvePMCredentials refactor#1187
zbigniewsobiecki merged 1 commit intodevfrom
chore/boost-pm-discovery-coverage

Conversation

@zbigniewsobiecki
Copy link
Copy Markdown
Member

Summary

Five new unit tests pinning the guard branches introduced in #1184's resolvePMCredentials refactor. 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

  • 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 is silently coerced to empty
  • configToCredentials throwing is swallowed with a console.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 — clean
  • npm run lint — clean

🤖 Generated with Claude Code

…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
Copy link
Copy Markdown

codecov Bot commented Apr 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@zbigniewsobiecki zbigniewsobiecki merged commit dae512e into dev Apr 24, 2026
9 checks passed
@zbigniewsobiecki zbigniewsobiecki deleted the chore/boost-pm-discovery-coverage branch April 24, 2026 13:12
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.

1 participant