Compare commits

..

2 Commits

Author SHA1 Message Date
agent-company c026d24d11 test: add HTMX fragment assertions to IssueDetail and PullDetail tests
Build and Push / test (pull_request) Successful in 18s
Build and Push / build (pull_request) Has been skipped
Verify that GET /issues/{owner}/{repo}/{index} and
GET /pulls/{owner}/{repo}/{index} with HX-Request: true return bare
content fragments without layout boilerplate (<html>, <!DOCTYPE>,
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) <noreply@anthropic.com>
2026-05-18 21:47:15 +00:00
AI-Manager d34916c276 Merge pull request 'feat: add MergePull() method to Gitea client (#187)' (#210) from feat/merge-pull-client-187 into master
Build and Push / test (push) Successful in 32s
Build and Push / build (push) Failing after 3s
2026-04-20 17:10:14 +00:00
+72
View File
@@ -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, "<html") {
t.Error("HTMX response should not contain <html tag")
}
if contains(body, "<!DOCTYPE") {
t.Error("HTMX response should not contain <!DOCTYPE")
}
if contains(body, `class="bottom-nav"`) {
t.Error("HTMX response should not contain bottom-nav")
}
// HTMX response MUST contain issue-specific content.
if !contains(body, "Test issue #1") {
t.Errorf("expected issue title 'Test issue #1' in HTMX fragment, got: %s", body[:min(300, len(body))])
}
}
func TestIntegration_PullDetail_HTMX(t *testing.T) {
h, srv := newTestHandlerWithMock(t)
defer srv.Close()
mux := http.NewServeMux()
mux.HandleFunc("GET /pulls/{owner}/{repo}/{index}", h.PullDetail)
req := reqWithToken(http.MethodGet, "/pulls/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, "<html") {
t.Error("HTMX response should not contain <html tag")
}
if contains(body, "<!DOCTYPE") {
t.Error("HTMX response should not contain <!DOCTYPE")
}
if contains(body, `class="bottom-nav"`) {
t.Error("HTMX response should not contain bottom-nav")
}
// HTMX response MUST contain PR-specific content.
if !contains(body, "Test PR #1") {
t.Errorf("expected PR title 'Test PR #1' in HTMX fragment, got: %s", body[:min(300, len(body))])
}
}
// --- Issue #138: Integration tests for GET /issues/new and GET /issues/new/labels --- // --- Issue #138: Integration tests for GET /issues/new and GET /issues/new/labels ---
func TestIntegration_NewIssue_WithToken(t *testing.T) { func TestIntegration_NewIssue_WithToken(t *testing.T) {