Skip to content

test(gadgets/github/core): add unit tests for untested PR gadget functions#971

Merged
aaight merged 1 commit intodevfrom
feature/unit-tests-gadgets-github-core-untested
Mar 21, 2026
Merged

test(gadgets/github/core): add unit tests for untested PR gadget functions#971
aaight merged 1 commit intodevfrom
feature/unit-tests-gadgets-github-core-untested

Conversation

@aaight
Copy link
Copy Markdown
Collaborator

@aaight aaight commented Mar 21, 2026

Summary

  • Adds 5 new test files covering untested gadget core functions in src/gadgets/github/core/
  • 14 new test cases total covering success paths, edge cases, and error paths
  • Follows the existing createPR.test.ts pattern: mocking githubClient via vi.mock

Files Added

  • tests/unit/gadgets/github/core/getPRDetails.test.ts — tests success (formatted output with title/state/branch/URL/body, empty body fallback) and error path
  • tests/unit/gadgets/github/core/postPRComment.test.ts — tests success with and without run link footer, error path; mocks both githubClient and buildRunLinkFooterFromEnv
  • tests/unit/gadgets/github/core/replyToReviewComment.test.ts — tests success (returns URL) and error path
  • tests/unit/gadgets/github/core/updatePRComment.test.ts — tests success (returns id and URL) and error path
  • tests/unit/gadgets/github/core/getPRDiff.test.ts — tests success with patch, files without patch (binary/too large), empty file list, and error path

Test plan

  • All 14 new tests pass (npm test)
  • Full unit suite passes: 328 test files, 6184 tests, no regressions
  • Lint passes (npm run lint)

Trello card: https://trello.com/c/W6fFy4Wy/492-as-a-developer-i-want-unit-tests-for-gadgets-github-core-untested-files-so-that-pr-details-comments-replies-and-diff-gadget-func

🤖 Generated with Claude Code

🕵️ claude-code · claude-sonnet-4-6 · run details

Copy link
Copy Markdown
Collaborator

@nhopeatall nhopeatall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — All 5 test files are well-structured, correctly mirror the source implementations, and follow the established createPR.test.ts pattern (vi.mock before imports, vi.mocked() helper, clearAllMocks in beforeEach, Awaited<ReturnType<...>> type casts). Mock setups accurately reflect the githubClient methods used by each source function. The postPRComment test appropriately mocks the buildRunLinkFooterFromEnv dependency and verifies the footer-appending logic. All CI checks pass.

🕵️ claude-code · claude-opus-4-6 · run details

@aaight aaight merged commit d9f37e5 into dev Mar 21, 2026
8 checks passed
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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.

2 participants