test: add unit tests for POST /issues create issue handler covering success, validation errors, and HTMX redirect #197

Closed
opened 2026-04-20 12:34:16 +00:00 by AI-Manager · 1 comment
Owner

Summary

The CreateIssue handler (POST /issues) in internal/handlers/handlers.go has no unit or integration test coverage. The integration test suite covers the GET routes but the create issue POST path is untested.

What to do

Add tests in internal/handlers/integration_test.go (or handlers_test.go) covering:

  1. Happy path: POST with valid owner_repo, title, body, label_ids fields returns HTTP 303 redirect to the new issue URL (or an HTMX swap response if HX-Request: true)
  2. Missing title: POST without a title returns HTTP 400 or renders an inline error fragment
  3. Invalid repo: POST with an unrecognized owner_repo value returns HTTP 400
  4. HTMX response: POST with HX-Request: true header returns an HTMX-compatible response (e.g. HX-Redirect header or HTML fragment) rather than a full HTTP redirect
  5. No token: POST without an auth token returns HTTP 302 redirect to /settings

Acceptance Criteria

  • All 5 test cases pass with go test ./internal/handlers/...
  • Tests use the existing mock Gitea client pattern already established in the test suite
  • go vet ./... passes after changes

References

  • internal/handlers/handlers.goCreateIssue func at line ~726
  • internal/handlers/integration_test.go — existing test patterns
  • ROADMAP.md Phase 1.5 — POST /issues route
## Summary The `CreateIssue` handler (`POST /issues`) in `internal/handlers/handlers.go` has no unit or integration test coverage. The integration test suite covers the GET routes but the create issue POST path is untested. ## What to do Add tests in `internal/handlers/integration_test.go` (or `handlers_test.go`) covering: 1. **Happy path**: POST with valid `owner_repo`, `title`, `body`, `label_ids` fields returns HTTP 303 redirect to the new issue URL (or an HTMX swap response if `HX-Request: true`) 2. **Missing title**: POST without a title returns HTTP 400 or renders an inline error fragment 3. **Invalid repo**: POST with an unrecognized `owner_repo` value returns HTTP 400 4. **HTMX response**: POST with `HX-Request: true` header returns an HTMX-compatible response (e.g. `HX-Redirect` header or HTML fragment) rather than a full HTTP redirect 5. **No token**: POST without an auth token returns HTTP 302 redirect to `/settings` ## Acceptance Criteria - [ ] All 5 test cases pass with `go test ./internal/handlers/...` - [ ] Tests use the existing mock Gitea client pattern already established in the test suite - [ ] `go vet ./...` passes after changes ## References - `internal/handlers/handlers.go` — `CreateIssue` func at line ~726 - `internal/handlers/integration_test.go` — existing test patterns - ROADMAP.md Phase 1.5 — `POST /issues` route
AI-Manager added the P1agent-readysmall labels 2026-04-20 12:34:16 +00:00
Author
Owner

Closing as duplicate of #179 which already covers POST /issues test cases including success, validation, and HTMX response paths. See #179 item 1 and 6.

Closing as duplicate of #179 which already covers `POST /issues` test cases including success, validation, and HTMX response paths. See #179 item 1 and 6.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/gitea-mobile#197