mirror of
https://github.com/go-gitea/gitea.git
synced 2026-09-08 14:03:24 +09:00
@@ -14,7 +14,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="item-main">
|
<div class="item-main">
|
||||||
<div class="item-title">
|
<div class="item-title">
|
||||||
{{$title := or $run.Title (ctx.Locale.Tr "actions.runs.empty_commit_message")}}
|
{{$title := or $run.Title (ctx.Locale.TrString "actions.runs.empty_commit_message")}}
|
||||||
{{ctx.RenderUtils.RenderCommitMessageLinkSubject $title $run.Link $.Repository}}
|
{{ctx.RenderUtils.RenderCommitMessageLinkSubject $title $run.Link $.Repository}}
|
||||||
</div>
|
</div>
|
||||||
<div class="item-body">
|
<div class="item-body">
|
||||||
|
|||||||
@@ -9,18 +9,24 @@ import (
|
|||||||
"path"
|
"path"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"gitea.dev/models/actions"
|
||||||
|
"gitea.dev/models/db"
|
||||||
"gitea.dev/modules/setting"
|
"gitea.dev/modules/setting"
|
||||||
api "gitea.dev/modules/structs"
|
api "gitea.dev/modules/structs"
|
||||||
"gitea.dev/modules/test"
|
"gitea.dev/modules/test"
|
||||||
"gitea.dev/tests"
|
"gitea.dev/tests"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func assertLinkPageComplete(t *testing.T, session *TestSession, link string) {
|
func assertLinkPageComplete(t *testing.T, session *TestSession, link string, containStrings ...string) {
|
||||||
req := NewRequest(t, "GET", link)
|
req := NewRequest(t, "GET", link)
|
||||||
resp := session.MakeRequest(t, req, http.StatusOK)
|
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||||
assert.True(t, test.IsNormalPageCompleted(resp.Body.String()), "Page did not complete: "+link)
|
assert.True(t, test.IsNormalPageCompleted(resp.Body.String()), "Page did not complete: "+link)
|
||||||
|
for _, s := range containStrings {
|
||||||
|
assert.Contains(t, resp.Body.String(), s, "Page does not contain expected string: "+s)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLinks(t *testing.T) {
|
func TestLinks(t *testing.T) {
|
||||||
@@ -179,26 +185,30 @@ func testLinksAsUser(t *testing.T) {
|
|||||||
func testLinksRepoCommon(t *testing.T) {
|
func testLinksRepoCommon(t *testing.T) {
|
||||||
// repo1 has enabled almost features, so we can test most links
|
// repo1 has enabled almost features, so we can test most links
|
||||||
repoLink := "/user2/repo1"
|
repoLink := "/user2/repo1"
|
||||||
links := []string{
|
|
||||||
"/actions",
|
err := db.Insert(t.Context(), &actions.ActionRun{Title: "", RepoID: 1})
|
||||||
"/packages",
|
require.NoError(t, err)
|
||||||
"/projects",
|
|
||||||
|
links := map[string][]string{
|
||||||
|
"/actions": {"(empty commit message)"},
|
||||||
|
"/packages": {},
|
||||||
|
"/projects": {},
|
||||||
}
|
}
|
||||||
|
|
||||||
// anonymous user
|
// anonymous user
|
||||||
for _, link := range links {
|
for link, strs := range links {
|
||||||
assertLinkPageComplete(t, nil, repoLink+link)
|
assertLinkPageComplete(t, nil, repoLink+link, strs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// admin/owner user
|
// admin/owner user
|
||||||
session := loginUser(t, "user1")
|
session := loginUser(t, "user1")
|
||||||
for _, link := range links {
|
for link, strs := range links {
|
||||||
assertLinkPageComplete(t, session, repoLink+link)
|
assertLinkPageComplete(t, session, repoLink+link, strs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// non-admin non-owner user
|
// non-admin non-owner user
|
||||||
session = loginUser(t, "user2")
|
session = loginUser(t, "user2")
|
||||||
for _, link := range links {
|
for link, strs := range links {
|
||||||
assertLinkPageComplete(t, session, repoLink+link)
|
assertLinkPageComplete(t, session, repoLink+link, strs...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user