From 0fff5f481e3d3b3a2e9accaf00275f673538b158 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Fri, 4 Sep 2026 02:23:27 +0800 Subject: [PATCH] fix: action run list page error (#39212) --- templates/repo/actions/runs_list.tmpl | 2 +- tests/integration/links_test.go | 32 ++++++++++++++++++--------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/templates/repo/actions/runs_list.tmpl b/templates/repo/actions/runs_list.tmpl index b1c7623531e..0ddc9dd36d7 100644 --- a/templates/repo/actions/runs_list.tmpl +++ b/templates/repo/actions/runs_list.tmpl @@ -18,7 +18,7 @@
- {{$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 $run.Repo}}
diff --git a/tests/integration/links_test.go b/tests/integration/links_test.go index d81a6d5ad55..4836cb4e038 100644 --- a/tests/integration/links_test.go +++ b/tests/integration/links_test.go @@ -9,18 +9,24 @@ import ( "path" "testing" + "gitea.dev/models/actions" + "gitea.dev/models/db" "gitea.dev/modules/setting" api "gitea.dev/modules/structs" "gitea.dev/modules/test" "gitea.dev/tests" "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) resp := session.MakeRequest(t, req, http.StatusOK) 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) { @@ -215,26 +221,30 @@ func testLinksAsUser(t *testing.T) { func testLinksRepoCommon(t *testing.T) { // repo1 has enabled almost features, so we can test most links repoLink := "/user2/repo1" - links := []string{ - "/actions", - "/packages", - "/projects", + + err := db.Insert(t.Context(), &actions.ActionRun{Title: "", RepoID: 1}) + require.NoError(t, err) + + links := map[string][]string{ + "/actions": {"(empty commit message)"}, + "/packages": {}, + "/projects": {}, } // anonymous user - for _, link := range links { - assertLinkPageComplete(t, nil, repoLink+link) + for link, strs := range links { + assertLinkPageComplete(t, nil, repoLink+link, strs...) } // admin/owner user session := loginUser(t, "user1") - for _, link := range links { - assertLinkPageComplete(t, session, repoLink+link) + for link, strs := range links { + assertLinkPageComplete(t, session, repoLink+link, strs...) } // non-admin non-owner user session = loginUser(t, "user2") - for _, link := range links { - assertLinkPageComplete(t, session, repoLink+link) + for link, strs := range links { + assertLinkPageComplete(t, session, repoLink+link, strs...) } }