chore: refactor the web UI tests for the actions run

- create tests/integration/actions_view_test.go
- extract TestActionsArtifactDeletion from actions_route_test.go
- extract tests misplaced in
  - api_actions_artifact_test.go
  - api_actions_artifact_v4_test.go
- add a tests for the /{owner}/{repo}/actions/runs/{run_index}/artifacts
  because it is useful for debugging
This commit is contained in:
Earl Warren 2025-08-26 17:51:34 +02:00
commit f7b0eb16c8
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
4 changed files with 88 additions and 60 deletions

View file

@ -146,38 +146,3 @@ func TestActionsWebRouteLatestRun(t *testing.T) {
assert.Equal(t, workflow.HTMLURL(), resp.Header().Get("Location"))
})
}
func TestActionsWebRouteArtifactDeletion(t *testing.T) {
onGiteaRun(t, func(t *testing.T, u *url.URL) {
user2 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
// create the repo
repo, _, f := tests.CreateDeclarativeRepo(t, user2, "",
[]unit_model.Type{unit_model.TypeActions}, nil,
[]*files_service.ChangeRepoFile{
{
Operation: "create",
TreePath: ".gitea/workflows/pr.yml",
ContentReader: strings.NewReader("name: test\non:\n push:\njobs:\n test:\n runs-on: ubuntu-latest\n steps:\n - run: echo helloworld\n"),
},
},
)
defer f()
// a run has been created
assert.Equal(t, 1, unittest.GetCount(t, &actions_model.ActionRun{RepoID: repo.ID}))
// Load the run we just created
run := unittest.AssertExistsAndLoadBean(t, &actions_model.ActionRun{RepoID: repo.ID})
err := run.LoadAttributes(t.Context())
require.NoError(t, err)
// Visit it's web view
req := NewRequest(t, "GET", run.HTMLURL())
resp := MakeRequest(t, req, http.StatusOK)
htmlDoc := NewHTMLParser(t, resp.Body)
// Assert that the artifact deletion markup exists
htmlDoc.AssertElement(t, "[data-locale-confirm-delete-artifact]", true)
})
}