From c026d24d11178d6eca575ab06b793b4e07fd6726 Mon Sep 17 00:00:00 2001 From: agent-company Date: Mon, 18 May 2026 21:47:15 +0000 Subject: [PATCH] test: add HTMX fragment assertions to IssueDetail and PullDetail tests Verify that GET /issues/{owner}/{repo}/{index} and GET /pulls/{owner}/{repo}/{index} with HX-Request: true return bare content fragments without layout boilerplate (, , bottom-nav), while still containing the correct issue/PR-specific content. Closes leeworks-agents/gitea-mobile#217 Co-Authored-By: Claude Opus 4.6 (1M context) --- internal/handlers/integration_test.go | 72 +++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/internal/handlers/integration_test.go b/internal/handlers/integration_test.go index b5dcd3e..eb1d067 100644 --- a/internal/handlers/integration_test.go +++ b/internal/handlers/integration_test.go @@ -489,6 +489,78 @@ func TestIntegration_PullDetail_InvalidIndex(t *testing.T) { } } +// --- Issue #217: HTMX fragment assertions for IssueDetail and PullDetail --- + +func TestIntegration_IssueDetail_HTMX(t *testing.T) { + h, srv := newTestHandlerWithMock(t) + defer srv.Close() + + mux := http.NewServeMux() + mux.HandleFunc("GET /issues/{owner}/{repo}/{index}", h.IssueDetail) + + req := reqWithToken(http.MethodGet, "/issues/test-org/repo1/1", "") + req.Header.Set("HX-Request", "true") + w := httptest.NewRecorder() + + mux.ServeHTTP(w, req) + + if w.Code != http.StatusOK { + t.Errorf("status = %d, want %d", w.Code, http.StatusOK) + } + body := w.Body.String() + + // HTMX response must NOT contain layout boilerplate. + if contains(body, "