fix: display the list of tasks in the runner edit page (#7650)
A regression was introduced in Forgejo v11.0 that caused the edit page of a runner (e.g. https://example.org/admin/actions/runners/434) to no longer display the tasks associated with the runner. Fixes https://codeberg.org/forgejo/forgejo/issues/7643 --- When the fix is absent, the tests fail like so: ``` --- FAIL: TestRunnerDetails (0.03s) --- FAIL: TestRunnerDetails/first_page (0.00s) runners_test.go:36: Error Trace: /home/earl-warren/software/forgejo/routers/web/shared/actions/runners_test.go:36 Error: "[]" should have 30 item(s), but has 0 Test: TestRunnerDetails/first_page --- FAIL: TestRunnerDetails/second_and_last_page (0.00s) runners_test.go:43: Error Trace: /home/earl-warren/software/forgejo/routers/web/shared/actions/runners_test.go:43 Error: "[]" should have 10 item(s), but has 0 Test: TestRunnerDetails/second_and_last_page FAIL FAIL forgejo.org/routers/web/shared/actions 0.170s ``` ## Checklist The [contributor guide](https://forgejo.org/docs/next/contributor/) contains information that will be helpful to first time contributors. There also are a few [conditions for merging Pull Requests in Forgejo repositories](https://codeberg.org/forgejo/governance/src/branch/main/PullRequestsAgreement.md). You are also welcome to join the [Forgejo development chatroom](https://matrix.to/#/#forgejo-development:matrix.org). ### Tests - I added test coverage for Go changes... - [x] in their respective `*_test.go` for unit tests. - [ ] in the `tests/integration` directory if it involves interactions with a live Forgejo server. - I added test coverage for JavaScript changes... - [ ] in `web_src/js/*.test.js` if it can be unit tested. - [ ] in `tests/e2e/*.test.e2e.js` if it requires interactions with a live Forgejo server (see also the [developer guide for JavaScript testing](https://codeberg.org/forgejo/forgejo/src/branch/forgejo/tests/e2e/README.md#end-to-end-tests)). ### Documentation - [ ] I created a pull request [to the documentation](https://codeberg.org/forgejo/docs) to explain to Forgejo users how to use this change. - [x] I did not document these changes and I do not expect someone else to do it. ### Release notes - [ ] I do not want this change to show in the release notes. - [x] I want the title to show in the release notes with a link to this pull request. - [ ] I want the content of the `release-notes/<pull request number>.md` to be be used for the release notes instead of the title. <!--start release-notes-assistant--> ## Release notes <!--URL:https://codeberg.org/forgejo/forgejo--> - User Interface bug fixes - [PR](https://codeberg.org/forgejo/forgejo/pulls/7650): <!--number 7650 --><!--line 0 --><!--description ZGlzcGxheSB0aGUgbGlzdCBvZiB0YXNrcyBpbiB0aGUgcnVubmVyIGVkaXQgcGFnZQ==-->display the list of tasks in the runner edit page<!--description--> <!--end release-notes-assistant--> <!--start release-notes-assistant--> ## Release notes <!--URL:https://codeberg.org/forgejo/forgejo--> - User Interface bug fixes - [PR](https://codeberg.org/forgejo/forgejo/pulls/7650): <!--number 7650 --><!--line 0 --><!--description ZGlzcGxheSB0aGUgbGlzdCBvZiB0YXNrcyBpbiB0aGUgcnVubmVyIGVkaXQgcGFnZQ==-->display the list of tasks in the runner edit page<!--description--> <!--end release-notes-assistant--> Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7650 Reviewed-by: cobak78 <cobak78@noreply.codeberg.org> Co-authored-by: Earl Warren <contact@earl-warren.org> Co-committed-by: Earl Warren <contact@earl-warren.org>
This commit is contained in:
		
					parent
					
						
							
								7e489eed25
							
						
					
				
			
			
				commit
				
					
						a0115cf10f
					
				
			
		
					 5 changed files with 231 additions and 1 deletions
				
			
		| 
						 | 
					@ -0,0 +1,7 @@
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					  id: 1004
 | 
				
			||||||
 | 
					  uuid: "fb857e63-c0ce-4571-a6c9-fde26c128073"
 | 
				
			||||||
 | 
					  name: "Global runner"
 | 
				
			||||||
 | 
					  owner_id: 0
 | 
				
			||||||
 | 
					  repo_id: 0
 | 
				
			||||||
 | 
					  deleted: 0
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,160 @@
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					  id: 1
 | 
				
			||||||
 | 
					  runner_id: 1004
 | 
				
			||||||
 | 
					  token_hash: a1
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					  id: 2
 | 
				
			||||||
 | 
					  runner_id: 1004
 | 
				
			||||||
 | 
					  token_hash: a2
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					  id: 3
 | 
				
			||||||
 | 
					  runner_id: 1004
 | 
				
			||||||
 | 
					  token_hash: a3
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					  id: 4
 | 
				
			||||||
 | 
					  runner_id: 1004
 | 
				
			||||||
 | 
					  token_hash: a4
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					  id: 5
 | 
				
			||||||
 | 
					  runner_id: 1004
 | 
				
			||||||
 | 
					  token_hash: a5
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					  id: 6
 | 
				
			||||||
 | 
					  runner_id: 1004
 | 
				
			||||||
 | 
					  token_hash: a6
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					  id: 7
 | 
				
			||||||
 | 
					  runner_id: 1004
 | 
				
			||||||
 | 
					  token_hash: a7
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					  id: 8
 | 
				
			||||||
 | 
					  runner_id: 1004
 | 
				
			||||||
 | 
					  token_hash: a8
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					  id: 9
 | 
				
			||||||
 | 
					  runner_id: 1004
 | 
				
			||||||
 | 
					  token_hash: a9
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					  id: 10
 | 
				
			||||||
 | 
					  runner_id: 1004
 | 
				
			||||||
 | 
					  token_hash: a10
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					  id: 11
 | 
				
			||||||
 | 
					  runner_id: 1004
 | 
				
			||||||
 | 
					  token_hash: a11
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					  id: 12
 | 
				
			||||||
 | 
					  runner_id: 1004
 | 
				
			||||||
 | 
					  token_hash: a12
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					  id: 13
 | 
				
			||||||
 | 
					  runner_id: 1004
 | 
				
			||||||
 | 
					  token_hash: a13
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					  id: 14
 | 
				
			||||||
 | 
					  runner_id: 1004
 | 
				
			||||||
 | 
					  token_hash: a14
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					  id: 15
 | 
				
			||||||
 | 
					  runner_id: 1004
 | 
				
			||||||
 | 
					  token_hash: a15
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					  id: 16
 | 
				
			||||||
 | 
					  runner_id: 1004
 | 
				
			||||||
 | 
					  token_hash: a16
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					  id: 17
 | 
				
			||||||
 | 
					  runner_id: 1004
 | 
				
			||||||
 | 
					  token_hash: a17
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					  id: 18
 | 
				
			||||||
 | 
					  runner_id: 1004
 | 
				
			||||||
 | 
					  token_hash: a18
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					  id: 19
 | 
				
			||||||
 | 
					  runner_id: 1004
 | 
				
			||||||
 | 
					  token_hash: a19
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					  id: 20
 | 
				
			||||||
 | 
					  runner_id: 1004
 | 
				
			||||||
 | 
					  token_hash: a20
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					  id: 21
 | 
				
			||||||
 | 
					  runner_id: 1004
 | 
				
			||||||
 | 
					  token_hash: a21
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					  id: 22
 | 
				
			||||||
 | 
					  runner_id: 1004
 | 
				
			||||||
 | 
					  token_hash: a22
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					  id: 23
 | 
				
			||||||
 | 
					  runner_id: 1004
 | 
				
			||||||
 | 
					  token_hash: a23
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					  id: 24
 | 
				
			||||||
 | 
					  runner_id: 1004
 | 
				
			||||||
 | 
					  token_hash: a24
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					  id: 25
 | 
				
			||||||
 | 
					  runner_id: 1004
 | 
				
			||||||
 | 
					  token_hash: a25
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					  id: 26
 | 
				
			||||||
 | 
					  runner_id: 1004
 | 
				
			||||||
 | 
					  token_hash: a26
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					  id: 27
 | 
				
			||||||
 | 
					  runner_id: 1004
 | 
				
			||||||
 | 
					  token_hash: a27
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					  id: 28
 | 
				
			||||||
 | 
					  runner_id: 1004
 | 
				
			||||||
 | 
					  token_hash: a28
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					  id: 29
 | 
				
			||||||
 | 
					  runner_id: 1004
 | 
				
			||||||
 | 
					  token_hash: a29
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					  id: 30
 | 
				
			||||||
 | 
					  runner_id: 1004
 | 
				
			||||||
 | 
					  token_hash: a30
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					  id: 31
 | 
				
			||||||
 | 
					  runner_id: 1004
 | 
				
			||||||
 | 
					  token_hash: a31
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					  id: 32
 | 
				
			||||||
 | 
					  runner_id: 1004
 | 
				
			||||||
 | 
					  token_hash: a32
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					  id: 33
 | 
				
			||||||
 | 
					  runner_id: 1004
 | 
				
			||||||
 | 
					  token_hash: a33
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					  id: 34
 | 
				
			||||||
 | 
					  runner_id: 1004
 | 
				
			||||||
 | 
					  token_hash: a34
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					  id: 35
 | 
				
			||||||
 | 
					  runner_id: 1004
 | 
				
			||||||
 | 
					  token_hash: a35
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					  id: 36
 | 
				
			||||||
 | 
					  runner_id: 1004
 | 
				
			||||||
 | 
					  token_hash: a36
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					  id: 37
 | 
				
			||||||
 | 
					  runner_id: 1004
 | 
				
			||||||
 | 
					  token_hash: a37
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					  id: 38
 | 
				
			||||||
 | 
					  runner_id: 1004
 | 
				
			||||||
 | 
					  token_hash: a38
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					  id: 39
 | 
				
			||||||
 | 
					  runner_id: 1004
 | 
				
			||||||
 | 
					  token_hash: a39
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					  id: 40
 | 
				
			||||||
 | 
					  runner_id: 1004
 | 
				
			||||||
 | 
					  token_hash: a40
 | 
				
			||||||
							
								
								
									
										17
									
								
								routers/web/shared/actions/main_test.go
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								routers/web/shared/actions/main_test.go
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,17 @@
 | 
				
			||||||
 | 
					// Copyright 2025 The Forgejo Authors.
 | 
				
			||||||
 | 
					// SPDX-License-Identifier: GPL-3.0-or-later
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					package actions
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"testing"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"forgejo.org/models/unittest"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						_ "forgejo.org/models"
 | 
				
			||||||
 | 
						_ "forgejo.org/models/forgefed"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func TestMain(m *testing.M) {
 | 
				
			||||||
 | 
						unittest.MainTest(m)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -79,7 +79,6 @@ func RunnerDetails(ctx *context.Context, page int, runnerID, ownerID, repoID int
 | 
				
			||||||
			Page:     page,
 | 
								Page:     page,
 | 
				
			||||||
			PageSize: 30,
 | 
								PageSize: 30,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		Status:   []actions_model.Status{actions_model.StatusUnknown}, // Unknown means all
 | 
					 | 
				
			||||||
		RunnerID: runner.ID,
 | 
							RunnerID: runner.ID,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										47
									
								
								routers/web/shared/actions/runners_test.go
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								routers/web/shared/actions/runners_test.go
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,47 @@
 | 
				
			||||||
 | 
					// Copyright 2025 The Forgejo Authors.
 | 
				
			||||||
 | 
					// SPDX-License-Identifier: GPL-3.0-or-later
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					package actions
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"net/http"
 | 
				
			||||||
 | 
						"testing"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						actions_model "forgejo.org/models/actions"
 | 
				
			||||||
 | 
						"forgejo.org/models/unittest"
 | 
				
			||||||
 | 
						user_model "forgejo.org/models/user"
 | 
				
			||||||
 | 
						"forgejo.org/services/contexttest"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"github.com/stretchr/testify/assert"
 | 
				
			||||||
 | 
						"github.com/stretchr/testify/require"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func TestRunnerDetails(t *testing.T) {
 | 
				
			||||||
 | 
						defer unittest.OverrideFixtures("routers/web/shared/actions/fixtures/TestRunnerDetails")()
 | 
				
			||||||
 | 
						require.NoError(t, unittest.PrepareTestDatabase())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
 | 
				
			||||||
 | 
						runner := unittest.AssertExistsAndLoadBean(t, &actions_model.ActionRunner{ID: 1004})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						t.Run("permission denied", func(t *testing.T) {
 | 
				
			||||||
 | 
							ctx, resp := contexttest.MockContext(t, "/admin/actions/runners")
 | 
				
			||||||
 | 
							RunnerDetails(ctx, 1, runner.ID, user.ID, 0)
 | 
				
			||||||
 | 
							assert.Equal(t, http.StatusNotFound, resp.Code)
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						t.Run("first page", func(t *testing.T) {
 | 
				
			||||||
 | 
							ctx, resp := contexttest.MockContext(t, "/admin/actions/runners")
 | 
				
			||||||
 | 
							page := 1
 | 
				
			||||||
 | 
							RunnerDetails(ctx, page, runner.ID, 0, 0)
 | 
				
			||||||
 | 
							require.Equal(t, http.StatusOK, resp.Code)
 | 
				
			||||||
 | 
							assert.Len(t, ctx.GetData()["Tasks"], 30)
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						t.Run("second and last page", func(t *testing.T) {
 | 
				
			||||||
 | 
							ctx, resp := contexttest.MockContext(t, "/admin/actions/runners")
 | 
				
			||||||
 | 
							page := 2
 | 
				
			||||||
 | 
							RunnerDetails(ctx, page, runner.ID, 0, 0)
 | 
				
			||||||
 | 
							require.Equal(t, http.StatusOK, resp.Code)
 | 
				
			||||||
 | 
							assert.Len(t, ctx.GetData()["Tasks"], 10)
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue