test: add tests for resolveFromProjectSearch to increase coverage#206
Merged
test: add tests for resolveFromProjectSearch to increase coverage#206
Conversation
- Export resolveFromProjectSearch and ResolvedEventTarget type for testing - Add 8 new tests for resolveFromProjectSearch: - No projects found: throws ContextError with project name - Multiple projects found: throws ValidationError with org list - Single project found: returns resolved target with org/project - Use spyOn to mock findProjectsBySlug without complex module mocking - Tests cover all 3 branches of resolveFromProjectSearch (empty, multiple, single)
Contributor
Semver Impact of This PR⚪ None (no version bump detected) 📋 Changelog PreviewThis is how your changes will appear in the changelog. Bug Fixes 🐛
Internal Changes 🔧
Other
🤖 This preview updates automatically when you update the PR. |
Prevents test isolation issues where the spy on findProjectsBySlug could persist and affect other test files running in the same process.
Contributor
Codecov Results 📊✅ Patch coverage is 100.00%. Project has 1996 uncovered lines. Files with missing lines (40)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 75.82% 76.11% +0.29%
==========================================
Files 65 65 —
Lines 8357 8356 -1
Branches 0 0 —
==========================================
+ Hits 6336 6360 +24
- Misses 2021 1996 -25
- Partials 0 0 —Generated by Codecov Action |
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
Adds unit tests for the
resolveFromProjectSearchfunction insrc/commands/event/view.tsto improve patch coverage.Changes
src/commands/event/view.ts:resolveFromProjectSearchfunction for testingResolvedEventTargettype for testingtest/commands/event/view.test.ts:resolveFromProjectSearch:ContextErrorwith project name and usage hintValidationErrorwith list of orgs and usage examplespyOnto mockfindProjectsBySlugwithout complex module mockingTesting
Motivation
PR #205 had 33% patch coverage, below the 80% threshold. This PR adds tests for the
resolveFromProjectSearchfunction which handles the project-search case when users specify just a project slug without an org.