feat: add close/reopen and comment actions to issue detail view
Add SetIssueState client method and handler for toggling issue state
between open and closed via PATCH API. Add AddComment client method
wrapping PostComment. Register new routes POST /issues/{owner}/{repo}/{index}/state
and POST /issues/{owner}/{repo}/{index}/comments. Update issue_detail.html
template with comment form (HTMX inline append) and close/reopen button
(HTMX inline swap of state badge).
Closes leeworks-agents/gitea-mobile#29
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -135,6 +135,54 @@ func TestSubmitReview_MissingEventType(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetIssueState_InvalidState(t *testing.T) {
|
||||
h := newTestHandler()
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc("POST /issues/{owner}/{repo}/{index}/state", h.SetIssueState)
|
||||
|
||||
req := httptest.NewRequest(http.MethodPost, "/issues/org/repo/1/state", nil)
|
||||
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||
w := httptest.NewRecorder()
|
||||
|
||||
mux.ServeHTTP(w, req)
|
||||
|
||||
if w.Code != http.StatusBadRequest {
|
||||
t.Errorf("status = %d, want %d", w.Code, http.StatusBadRequest)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetIssueState_InvalidIndex(t *testing.T) {
|
||||
h := newTestHandler()
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc("POST /issues/{owner}/{repo}/{index}/state", h.SetIssueState)
|
||||
|
||||
req := httptest.NewRequest(http.MethodPost, "/issues/org/repo/abc/state", nil)
|
||||
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||
w := httptest.NewRecorder()
|
||||
|
||||
mux.ServeHTTP(w, req)
|
||||
|
||||
if w.Code != http.StatusBadRequest {
|
||||
t.Errorf("status = %d, want %d", w.Code, http.StatusBadRequest)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAddComment_EmptyBody(t *testing.T) {
|
||||
h := newTestHandler()
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc("POST /issues/{owner}/{repo}/{index}/comments", h.AddComment)
|
||||
|
||||
req := httptest.NewRequest(http.MethodPost, "/issues/org/repo/1/comments", nil)
|
||||
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||
w := httptest.NewRecorder()
|
||||
|
||||
mux.ServeHTTP(w, req)
|
||||
|
||||
if w.Code != http.StatusBadRequest {
|
||||
t.Errorf("status = %d, want %d", w.Code, http.StatusBadRequest)
|
||||
}
|
||||
}
|
||||
|
||||
func contains(s, substr string) bool {
|
||||
return len(s) >= len(substr) && searchString(s, substr)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user