package gitea import ( "strings" "testing" ) func TestBuildSupersededBody(t *testing.T) { original := "# Review\n\nLooks good.\n\n" sentinel := "" newURL := "https://gitea.example.com/owner/repo/pulls/1#pullrequestreview-99" result := buildSupersededBody(original, "abcdef1234567890", newURL, sentinel) // Should contain the struck-through banner if !strings.Contains(result, "~~Original review~~") { t.Error("missing struck-through banner") } // Should contain superseded notice with link if !strings.Contains(result, "**Superseded**") { t.Error("missing superseded notice") } if !strings.Contains(result, "[see current review]("+newURL+")") { t.Error("missing link to new review") } // Should contain collapsed original if !strings.Contains(result, "
") { t.Error("missing details/collapse") } // Should contain short commit SHA if !strings.Contains(result, "abcdef12") { t.Error("missing short SHA") } // Should NOT contain full SHA in summary (it's truncated to 8) if strings.Contains(result, "abcdef1234567890") { t.Error("should truncate SHA to 8 chars") } // Should contain the original body inside details if !strings.Contains(result, original) { t.Error("original body not preserved in collapsed section") } // Should end with sentinel if !strings.Contains(result, sentinel) { t.Error("missing sentinel") } } func TestBuildSupersededBodyShortSHA(t *testing.T) { // Short SHA should pass through without panic result := buildSupersededBody("body", "abc", "https://example.com/review", "") if !strings.Contains(result, "abc") { t.Error("short SHA not preserved") } }