[v10.0/forgejo] fix: render issue titles consistently (#6717)

**Backport:** https://codeberg.org/forgejo/forgejo/pulls/6715

- Render the issue titles in dashboard feed in consistent manner, by using the existing `RenderIssueTitle`.
- Added integration tests (not exhaustive for all comment types, but exhaustive enough for the current code where some comment types are grouped together).
- Resolves forgejo/forgejo#6705

Co-authored-by: Gusted <postmaster@gusted.xyz>
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6717
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: forgejo-backport-action <forgejo-backport-action@noreply.codeberg.org>
Co-committed-by: forgejo-backport-action <forgejo-backport-action@noreply.codeberg.org>
This commit is contained in:
forgejo-backport-action 2025-01-29 08:24:37 +00:00 committed by Gusted
parent 7ee19b4c6c
commit 114d8975b5
4 changed files with 68 additions and 16 deletions

View file

@ -5,12 +5,21 @@ package integration
import (
"net/http"
"net/url"
"strconv"
"strings"
"testing"
"code.gitea.io/gitea/models/db"
unit_model "code.gitea.io/gitea/models/unit"
"code.gitea.io/gitea/models/unittest"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/translation"
issue_service "code.gitea.io/gitea/services/issue"
files_service "code.gitea.io/gitea/services/repository/files"
"code.gitea.io/gitea/tests"
"github.com/PuerkitoBio/goquery"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
@ -28,3 +37,45 @@ func TestUserDashboardActionLinks(t *testing.T) {
assert.EqualValues(t, locale.TrString("new_migrate.link"), strings.TrimSpace(links.Find("a[href='/repo/migrate']").Text()))
assert.EqualValues(t, locale.TrString("new_org.link"), strings.TrimSpace(links.Find("a[href='/org/create']").Text()))
}
func TestDashboardTitleRendering(t *testing.T) {
onGiteaRun(t, func(t *testing.T, u *url.URL) {
user4 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 4})
sess := loginUser(t, user4.Name)
repo, _, f := tests.CreateDeclarativeRepo(t, user4, "",
[]unit_model.Type{unit_model.TypePullRequests, unit_model.TypeIssues}, nil,
[]*files_service.ChangeRepoFile{
{
Operation: "create",
TreePath: "test.txt",
ContentReader: strings.NewReader("Just some text here"),
},
},
)
defer f()
issue := createIssue(t, user4, repo, "`:exclamation:` not rendered", "Hi there!")
pr := createPullRequest(t, user4, repo, "testing", "`:exclamation:` not rendered")
_, err := issue_service.CreateIssueComment(db.DefaultContext, user4, repo, issue, "hi", nil)
require.NoError(t, err)
_, err = issue_service.CreateIssueComment(db.DefaultContext, user4, repo, pr.Issue, "hi", nil)
require.NoError(t, err)
testIssueClose(t, sess, repo.OwnerName, repo.Name, strconv.Itoa(int(issue.Index)), false)
testIssueClose(t, sess, repo.OwnerName, repo.Name, strconv.Itoa(int(pr.Issue.Index)), true)
response := sess.MakeRequest(t, NewRequest(t, "GET", "/"), http.StatusOK)
htmlDoc := NewHTMLParser(t, response.Body)
count := 0
htmlDoc.doc.Find("#activity-feed .flex-item-main .title").Each(func(i int, s *goquery.Selection) {
count++
assert.EqualValues(t, ":exclamation: not rendered", s.Text())
})
assert.EqualValues(t, 6, count)
})
}