forked from forgejo/forgejo
Backport #28716 by wxiaoguang
Gitea prefers to use relative URLs in code (to make multiple domain work
for some users)
So it needs to use `toAbsoluteUrl` to generate a full URL when click
"Reference in New Issues"
And add some comments in the test code
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
(cherry picked from commit def178ce32
)
Conflicts:
tests/integration/issue_test.go
https://codeberg.org/forgejo/forgejo/issues/2158
This commit is contained in:
parent
d416f94b70
commit
01285dc47c
2 changed files with 21 additions and 1 deletions
|
@ -751,3 +751,22 @@ func TestGetContentHistory(t *testing.T) {
|
|||
testCase(t, loginUser(t, "user5"), true)
|
||||
})
|
||||
}
|
||||
|
||||
func TestIssueReferenceURL(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
session := loginUser(t, "user2")
|
||||
|
||||
issue := unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: 1})
|
||||
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: issue.RepoID})
|
||||
|
||||
req := NewRequest(t, "GET", fmt.Sprintf("%s/issues/%d", repo.FullName(), issue.Index))
|
||||
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
|
||||
// the "reference" uses relative URLs, then JS code will convert them to absolute URLs for current origin, in case users are using multiple domains
|
||||
ref, _ := htmlDoc.Find(`.timeline-item.comment.first .reference-issue`).Attr("data-reference")
|
||||
assert.EqualValues(t, "/user2/repo1/issues/1#issue-1", ref)
|
||||
|
||||
ref, _ = htmlDoc.Find(`.timeline-item.comment:not(.first) .reference-issue`).Attr("data-reference")
|
||||
assert.EqualValues(t, "/user2/repo1/issues/1#issuecomment-2", ref)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue