Skip to content

test: add comprehensive test suite (71 tests)#62

Open
dines-rl wants to merge 1 commit intomainfrom
agent/add-tests
Open

test: add comprehensive test suite (71 tests)#62
dines-rl wants to merge 1 commit intomainfrom
agent/add-tests

Conversation

@dines-rl
Copy link
Copy Markdown
Owner

@dines-rl dines-rl commented Mar 19, 2026

Summary

  • Farm.test.ts: Expanded with edge cases — empty arrays, multiple same-animal inputs, unrecognized animal types
  • AstforFile.test.ts (new): 10 tests for ASTForFile and ASTForFileToFile, using mocked tree-sitter and fs modules
  • GetDiffForFile.test.ts (new): 13 tests for getSuggestionsFromGPT with mocked OpenAI
  • IssuesTester.test.ts (new): 15 tests for the Probot issues.opened and issues.closed handlers
  • index.test.ts (new): 16 tests for the pull_request.opened/closed/reopened handlers

Total: 71 tests across 5 test files — all passing.

Test plan

  • npm test (vitest run) passes all 71 tests
  • No real API calls — OpenAI, Runloop, and tree-sitter are all mocked
  • Edge cases covered: API failures, devbox not reaching running state, GPT returning no changes, build failures

🤖 Generated with Claude Code


Note

Low Risk
Low risk: adds/expands Vitest test suites only, with external services (OpenAI, Runloop, tree-sitter, fs) fully mocked and no production logic changes.

Overview
Adds a comprehensive Vitest suite (71 tests) covering ASTForFile/ASTForFileToFile, getSuggestionsFromGPT (including default options, error paths, and line-number resolution), and the Probot issue/PR handlers (issues.opened/closed, pull_request.opened/closed/reopened) with mocked Runloop/OpenAI.

Expands Farm.test.ts to cover additional edge cases (empty input, repeated animals, unrecognized animals, larger mixes) and reorganizes tests into clearer describe blocks.

Written by Cursor Bugbot for commit eaec782. This will update automatically on new commits. Configure here.

- Expand Farm.test.ts with edge cases (empty arrays, multiple animals, unrecognized types)
- Add AstforFile.test.ts: 10 tests for ASTForFile/ASTForFileToFile with mocked tree-sitter and fs
- Add GetDiffForFile.test.ts: 13 tests for getSuggestionsFromGPT with mocked OpenAI
- Add IssuesTester.test.ts: 15 tests for Probot issues.opened/closed handlers
- Add index.test.ts: 16 tests for pull_request.opened/closed/reopened handlers

All 71 tests pass with no real API calls made.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

issue: vi.fn((extras?: Record<string, unknown>) => ({
owner: "test-owner",
repo: "test-repo",
issue_number: 1,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Mock context issue_number inconsistent with payload number

Medium Severity

The createMockContext helper returns issue_number: 1 from context.issue(), but payload.issue.number is 42. In real Probot, context.issue() derives issue_number from the payload, so these values are always in sync. This mismatch means all ghIssueComment calls in tests target issue #1 instead of #42, creating an inaccurate simulation that could mask bugs where the wrong issue number is used for posting comments, adding labels, or other issue-scoped operations.

Fix in Cursor Fix in Web

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