Skip to content

test: add tests for resolveFromProjectSearch to increase coverage#206

Merged
BYK merged 2 commits intomainfrom
test/event-view-coverage
Feb 6, 2026
Merged

test: add tests for resolveFromProjectSearch to increase coverage#206
BYK merged 2 commits intomainfrom
test/event-view-coverage

Conversation

@BYK
Copy link
Member

@BYK BYK commented Feb 5, 2026

Summary

Adds unit tests for the resolveFromProjectSearch function in src/commands/event/view.ts to improve patch coverage.

Changes

src/commands/event/view.ts:

  • Export resolveFromProjectSearch function for testing
  • Export ResolvedEventTarget type for testing
  • Add JSDoc documentation for the exported function

test/commands/event/view.test.ts:

  • Add 8 new tests for resolveFromProjectSearch:
    • No projects found: throws ContextError with project name and usage hint
    • Multiple projects found: throws ValidationError with list of orgs and usage example
    • Single project found: returns resolved target with org/project info
  • Use spyOn to mock findProjectsBySlug without complex module mocking

Testing

bun test test/commands/event/view.test.ts
# 18 pass, 0 fail

Motivation

PR #205 had 33% patch coverage, below the 80% threshold. This PR adds tests for the resolveFromProjectSearch function which handles the project-search case when users specify just a project slug without an org.

- 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)
@github-actions
Copy link
Contributor

github-actions bot commented Feb 5, 2026

Semver Impact of This PR

None (no version bump detected)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


Bug Fixes 🐛

  • (alias) Fix alias generation and highlighting for prefix-related slugs by BYK in #203

Internal Changes 🔧

  • (commands) Replace --org/--project flags with positional args for event view by BYK in #205

Other

  • test: add tests for resolveFromProjectSearch to increase coverage by BYK in #206
  • test: add tests for project-cache and env-file modules by BYK in #200

🤖 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.
@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

Codecov Results 📊

✅ Patch coverage is 100.00%. Project has 1996 uncovered lines.
✅ Project coverage is 76.11%. Comparing base (base) to head (head).

Files with missing lines (40)
File Patch % Lines
human.ts 55.31% ⚠️ 391 Missing
resolve-target.ts 15.28% ⚠️ 366 Missing
oauth.ts 25.10% ⚠️ 194 Missing
api-client.ts 70.62% ⚠️ 176 Missing
upgrade.ts 45.49% ⚠️ 139 Missing
view.ts 47.70% ⚠️ 91 Missing
migration.ts 47.44% ⚠️ 82 Missing
browser.ts 4.11% ⚠️ 70 Missing
span-tree.ts 5.00% ⚠️ 57 Missing
telemetry.ts 77.51% ⚠️ 56 Missing
api.ts 89.80% ⚠️ 47 Missing
seer.ts 75.54% ⚠️ 45 Missing
schema.ts 89.56% ⚠️ 40 Missing
seer.ts 79.87% ⚠️ 30 Missing
preload.ts 53.23% ⚠️ 29 Missing
utils.ts 88.94% ⚠️ 25 Missing
detector.ts 90.10% ⚠️ 20 Missing
output.ts 15.00% ⚠️ 17 Missing
code-scanner.ts 95.00% ⚠️ 16 Missing
arg-parsing.ts 90.00% ⚠️ 12 Missing
dsn-cache.ts 94.62% ⚠️ 12 Missing
fix.ts 83.61% ⚠️ 10 Missing
qrcode.ts 33.33% ⚠️ 10 Missing
fs-utils.ts 57.14% ⚠️ 9 Missing
project-root.ts 97.73% ⚠️ 7 Missing
version-check.ts 91.14% ⚠️ 7 Missing
feedback.ts 84.21% ⚠️ 6 Missing
auth.ts 95.52% ⚠️ 6 Missing
upgrade.ts 93.83% ⚠️ 5 Missing
resolver.ts 94.57% ⚠️ 5 Missing
index.ts 95.96% ⚠️ 4 Missing
project-aliases.ts 97.40% ⚠️ 2 Missing
project-root-cache.ts 96.92% ⚠️ 2 Missing
json.ts 33.33% ⚠️ 2 Missing
alias.ts 99.42% ⚠️ 1 Missing
env-file.ts 99.19% ⚠️ 1 Missing
parser.ts 98.63% ⚠️ 1 Missing
colors.ts 97.96% ⚠️ 1 Missing
helpers.ts 94.74% ⚠️ 1 Missing
helpers.ts 94.74% ⚠️ 1 Missing
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

@BYK BYK merged commit a218fc5 into main Feb 6, 2026
24 checks passed
@BYK BYK deleted the test/event-view-coverage branch February 6, 2026 00:29
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

Comments