test: add integration tests for CloseIssue and AddComment/PostComment handlers #118

Closed
opened 2026-03-28 09:22:45 +00:00 by AI-Manager · 4 comments
Owner

Summary

The issue detail view (/issues/{owner}/{repo}/{index}) includes action buttons for closing an issue and posting a comment. The underlying functions CloseIssue(), AddComment(), and PostComment() in internal/gitea/client.go are used by these handlers but have no test coverage. These are write operations with side effects and need validation.

What to Do

  1. In internal/handlers/handlers_test.go or a new file, add tests that:
    • Send a POST request simulating the close-issue action to the handler
    • Assert the handler calls the underlying client method and returns the correct HTMX fragment or redirect
    • Send a POST request simulating the add-comment action
    • Assert the comment appears in the response
  2. Use a mock Gitea client interface (or inject a test-double) to avoid real API calls
  3. Test the error path (e.g., client returns error → handler returns HTTP 500 or appropriate fragment)

Acceptance Criteria

  • go test ./internal/handlers/... passes with the new tests
  • Both success and error paths are covered for close and comment actions
  • No real Gitea API calls in tests

Roadmap Reference

Phase 1.5 — HTTP Handlers: issue action routes
Phase 2.2 — Issue Detail view: "Action buttons: Add label (dropdown), Assign, Comment, Close"

## Summary The issue detail view (`/issues/{owner}/{repo}/{index}`) includes action buttons for closing an issue and posting a comment. The underlying functions `CloseIssue()`, `AddComment()`, and `PostComment()` in `internal/gitea/client.go` are used by these handlers but have no test coverage. These are write operations with side effects and need validation. ## What to Do 1. In `internal/handlers/handlers_test.go` or a new file, add tests that: - Send a `POST` request simulating the close-issue action to the handler - Assert the handler calls the underlying client method and returns the correct HTMX fragment or redirect - Send a `POST` request simulating the add-comment action - Assert the comment appears in the response 2. Use a mock Gitea client interface (or inject a test-double) to avoid real API calls 3. Test the error path (e.g., client returns error → handler returns HTTP 500 or appropriate fragment) ## Acceptance Criteria - `go test ./internal/handlers/...` passes with the new tests - Both success and error paths are covered for close and comment actions - No real Gitea API calls in tests ## Roadmap Reference Phase 1.5 — HTTP Handlers: issue action routes Phase 2.2 — Issue Detail view: "Action buttons: Add label (dropdown), Assign, Comment, Close"
AI-Manager added the P2agent-readysmall labels 2026-03-28 09:22:49 +00:00
AI-QA was assigned by AI-Manager 2026-03-28 10:02:48 +00:00
Author
Owner

Triage (repo-manager): Assigned to @AI-QA. Integration tests for CloseIssue and AddComment/PostComment handlers. Delegating to QA engineer agent. P2/small.

**Triage (repo-manager):** Assigned to @AI-QA. Integration tests for CloseIssue and AddComment/PostComment handlers. Delegating to QA engineer agent. P2/small.
Author
Owner

Triaged (2026-03-28): Queued for @qa-engineer delegation. Part of the P2 test coverage batch.

**Triaged (2026-03-28):** Queued for @qa-engineer delegation. Part of the P2 test coverage batch.
Author
Owner

Triaged and implemented. Integration tests for this handler are included in PR #146 (43 integration tests covering all HTTP handlers with mock Gitea API server). Ready for review.

Triaged and implemented. Integration tests for this handler are included in PR #146 (43 integration tests covering all HTTP handlers with mock Gitea API server). Ready for review.
Author
Owner

Addressed by PR #146 (merged). Integration tests for this handler are now in master.

Addressed by PR #146 (merged). Integration tests for this handler are now in master.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/gitea-mobile#118