feat(ui): support additional job status selection in dropdown menu on Actions tab (#11156)
Some checks are pending
/ release (push) Waiting to run
testing-integration / test-unit (push) Waiting to run
testing-integration / test-sqlite (push) Waiting to run
testing-integration / test-mariadb (v10.6) (push) Waiting to run
testing-integration / test-mariadb (v11.8) (push) Waiting to run
testing / backend-checks (push) Waiting to run
testing / frontend-checks (push) Waiting to run
testing / test-unit (push) Blocked by required conditions
testing / test-e2e (push) Blocked by required conditions
testing / test-remote-cacher (redis) (push) Blocked by required conditions
testing / test-remote-cacher (valkey) (push) Blocked by required conditions
testing / test-remote-cacher (garnet) (push) Blocked by required conditions
testing / test-remote-cacher (redict) (push) Blocked by required conditions
testing / test-mysql (push) Blocked by required conditions
testing / test-pgsql (push) Blocked by required conditions
testing / test-sqlite (push) Blocked by required conditions
testing / security-check (push) Blocked by required conditions
testing / semgrep/ci (push) Waiting to run

### 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.
  - [x] 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

- [x] This change will be noticed by a Forgejo user or admin (feature, bug fix, performance, etc.). I suggest to include a release note for this change.
- [ ] This change is not visible to a Forgejo user or admin (refactor, dependency upgrade, etc.). I think there is no need to add a release note for this change.

### Disclaimer

Generative AI (ChatGPT) was used to debug the e2e test, with copied code lines below threshold of originality.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/11156
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Reviewed-by: Mathieu Fenniak <mfenniak@noreply.codeberg.org>
Reviewed-by: Andreas Ahlenstorf <aahlenst@noreply.codeberg.org>
Co-authored-by: Robert Wolff <mahlzahn@posteo.de>
Co-committed-by: Robert Wolff <mahlzahn@posteo.de>
This commit is contained in:
Robert Wolff 2026-02-11 03:22:53 +01:00 committed by Mathieu Fenniak
parent ec803eb2d3
commit 54d952ee66
3 changed files with 59 additions and 7 deletions

View file

@ -5,6 +5,7 @@ package actions
import (
"context"
"slices"
"forgejo.org/models/db"
repo_model "forgejo.org/models/repo"
@ -13,6 +14,8 @@ import (
"forgejo.org/modules/translation"
webhook_module "forgejo.org/modules/webhook"
"golang.org/x/text/collate"
"golang.org/x/text/language"
"xorm.io/builder"
)
@ -127,14 +130,18 @@ type StatusInfo struct {
// GetStatusInfoList returns a slice of StatusInfo
func GetStatusInfoList(ctx context.Context, lang translation.Locale) []StatusInfo {
// same as those in aggregateJobStatus
allStatus := []Status{StatusSuccess, StatusFailure, StatusWaiting, StatusRunning}
statusInfoList := make([]StatusInfo, 0, 4)
allStatus := []Status{StatusBlocked, StatusCancelled, StatusFailure, StatusRunning, StatusSkipped, StatusSuccess, StatusWaiting}
statusInfoList := make([]StatusInfo, 0, 7)
for _, s := range allStatus {
statusInfoList = append(statusInfoList, StatusInfo{
Status: int(s),
DisplayedStatus: s.LocaleString(lang),
})
}
collator := collate.New(language.Und, collate.IgnoreCase)
slices.SortFunc(statusInfoList, func(a, b StatusInfo) int {
return collator.CompareString(a.DisplayedStatus, b.DisplayedStatus)
})
return statusInfoList
}

View file

@ -0,0 +1,37 @@
// Copyright 2026 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: GPL-3.0-or-later
package actions
import (
"testing"
"forgejo.org/models/unittest"
"forgejo.org/modules/translation"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestActionStatusList(t *testing.T) {
require.NoError(t, unittest.PrepareTestDatabase())
translation.InitLocales(t.Context())
statusInfoList := GetStatusInfoList(t.Context(), translation.NewLocale("en-US"))
assert.Len(t, statusInfoList, 7)
statuses := []string{"Blocked", "Canceled", "Failure", "Running", "Skipped", "Success", "Waiting"}
statusInts := []int{7, 3, 2, 6, 4, 1, 5}
for i, statusString := range statuses {
assert.Equal(t, statusInfoList[i].Status, statusInts[i])
assert.Equal(t, statusInfoList[i].DisplayedStatus, statusString)
}
statusInfoList = GetStatusInfoList(t.Context(), translation.NewLocale("de-DE"))
assert.Len(t, statusInfoList, 7)
statuses = []string{"Abgebrochen", "Blockiert", "Erfolg", "Fehler", "Laufend", "Übersprungen", "Wartend"}
statusInts = []int{3, 7, 1, 2, 6, 4, 5}
for i, statusString := range statuses {
assert.Equal(t, statusInfoList[i].Status, statusInts[i])
assert.Equal(t, statusInfoList[i].DisplayedStatus, statusString)
}
}

View file

@ -203,11 +203,19 @@ test.describe('workflow list dynamic refresh', () => {
await page.locator('#workflow_dispatch_dropdown>button').click();
// Status dropdown
await expect(page.getByText('Waiting')).toBeHidden();
await expect(page.getByText('Failure')).toBeHidden();
await page.locator('#status_dropdown').click();
await expect(page.getByText('Waiting')).toBeVisible();
await expect(page.getByText('Failure')).toBeVisible();
const dropdown = page.locator('#status_dropdown');
const dropdown_menu = dropdown.locator('.menu');
await expect(dropdown_menu).toBeHidden();
await dropdown.click();
await expect(dropdown_menu).toBeVisible();
await expect(dropdown_menu.getByText('All status')).toHaveAttribute('href', /&status=0$/);
await expect(dropdown_menu.getByText('Success')).toHaveAttribute('href', /&status=1$/);
await expect(dropdown_menu.getByText('Failure')).toHaveAttribute('href', /&status=2$/);
await expect(dropdown_menu.getByText('Waiting')).toHaveAttribute('href', /&status=5$/);
await expect(dropdown_menu.getByText('Running')).toHaveAttribute('href', /&status=6$/);
await expect(dropdown_menu.getByText('Blocked')).toHaveAttribute('href', /&status=7$/);
await expect(dropdown_menu.getByText('Canceled')).toHaveAttribute('href', /&status=3$/);
await expect(dropdown_menu.getByText('Skipped')).toHaveAttribute('href', /&status=4$/);
// Actor dropdown
await expect(page.getByText('All actors')).toBeHidden();