Commit graph

23585 commits

Author SHA1 Message Date
zokki
4247c37300 fix(api): deactivate issue api for disabled or external issue-tracker (#8829)
- When the issue unit is disabled for a repository, don't allow issue related APIs.
- Added integration tests.
- Resolves #8408

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8829
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: zokki <zokki.softwareschmiede@gmail.com>
Co-committed-by: zokki <zokki.softwareschmiede@gmail.com>
2025-09-03 16:13:40 +02:00
Antonin Delpeuch
8f4ebab023 tests: increase checkAccessibility timeout to 2s (#9137)
Because the flakiness of this check seems to be also present in Firefox, this is an attempt at reducing the flakiness, as an alternative to #9118.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9137
Reviewed-by: Mathieu Fenniak <mfenniak@noreply.codeberg.org>
Co-authored-by: Antonin Delpeuch <antonin@delpeuch.eu>
Co-committed-by: Antonin Delpeuch <antonin@delpeuch.eu>
2025-09-02 16:08:58 +02:00
charles25565
cba500459f fix: casing of URL for Pagure migration page (#9127)
## 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...
  - [ ] 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

- [x] I do not want this change to show in the release notes.
- [ ] 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.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9127
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
Co-authored-by: charles25565 <c4a@monocles.eu>
Co-committed-by: charles25565 <c4a@monocles.eu>
2025-09-02 09:50:42 +02:00
zokki
9162c82150 fix: preserved 'Custom access' even after no permissions (#8943)
fixes #5382

Co-authored-by: Otto <otto@codeberg.org>
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8943
Reviewed-by: Otto <otto@codeberg.org>
Co-authored-by: zokki <zokki.softwareschmiede@gmail.com>
Co-committed-by: zokki <zokki.softwareschmiede@gmail.com>
2025-09-01 15:19:17 +02:00
patdyn
9a423c0e67 Fix migration failing when importing either issues or PRs but not the other (#8892)
Related to https://codeberg.org/Codeberg/Community/issues/1944

* Allowed the githubdownloaderv3 to know whether issues and, or PRs are requested to migrate
* Used this information to decide to filter for "/pulls/" or "/issues"
  * Or not to filter at all if issues == true && prs == true
* Added isolated test for the downloader and for the uploader
* Created a new test_repo in github.com/forgejo and set it up properly together with @Gusted
* Updated github_downloader_test with the new URLs and test data from the repo
* Recorded the API calls for local testing
* Added a minimal gitbucket test (which uses the github downloader under the hood)

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8892
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: patdyn <patdyn@noreply.codeberg.org>
Co-committed-by: patdyn <patdyn@noreply.codeberg.org>
2025-09-01 14:05:10 +02:00
Maxim Slipenko
ed3b70cbb9 feat: allow any README for .profile (#8798)
closes #1624

Co-authored-by: Maxim Slipenko <maks1ms@altlinux.org>
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8798
Reviewed-by: Otto <otto@codeberg.org>
Co-authored-by: Maxim Slipenko <maks1ms@noreply.codeberg.org>
Co-committed-by: Maxim Slipenko <maks1ms@noreply.codeberg.org>
2025-09-01 13:58:00 +02:00
dawe
a87153b089 fix(ui): clear fields when canceling adding ssh key (#8990)
- Add javascript to clear fields upon clicking the cancel button inside the panel for adding new SSH keys.
- Add E2E test.
- Resolves #8915

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8990
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: dawe <dawedawe@posteo.de>
Co-committed-by: dawe <dawedawe@posteo.de>
2025-09-01 09:24:42 +02:00
forgejo-release-manager
bd59fa4df3 chore(release-notes): Forgejo v11.0.4 (#9105)
https://codeberg.org/forgejo/forgejo/milestone/22043
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9105
Reviewed-by: 0ko <0ko@noreply.codeberg.org>
Co-authored-by: forgejo-release-manager <contact-forgejo-release-manager@forgejo.org>
Co-committed-by: forgejo-release-manager <contact-forgejo-release-manager@forgejo.org>
2025-08-31 14:48:38 +02:00
forgejo-release-manager
6ae943758f chore(release-notes): Forgejo v12.0.2 (#9104)
https://codeberg.org/forgejo/forgejo/milestone/22489
Co-authored-by: 0ko <0ko@noreply.codeberg.org>
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9104
Reviewed-by: 0ko <0ko@noreply.codeberg.org>
Co-authored-by: forgejo-release-manager <contact-forgejo-release-manager@forgejo.org>
Co-committed-by: forgejo-release-manager <contact-forgejo-release-manager@forgejo.org>
2025-08-31 14:48:32 +02:00
0ko
af7066de64 chore(i18n): migrate migration descriptions to json (#9041)
Followup to https://codeberg.org/forgejo/forgejo/pulls/8987

* migrate strings, get rid of the `repo.` prefix
* simplify template and test

Followup to https://codeberg.org/forgejo/forgejo/pulls/8736#issuecomment-6801385

* restore lost translations

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9041
Reviewed-by: Beowulf <beowulf@beocode.eu>
2025-08-31 08:19:19 +02:00
0ko
9b54852aad merge commit: i18n: update of translations from Codeberg Translate (#9013)
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9013
Reviewed-by: 0ko <0ko@noreply.codeberg.org>
2025-08-31 07:23:10 +02:00
Codeberg Translate
436402a91e
i18n: update of translations from Codeberg Translate
Co-authored-by: 0ko <0ko@noreply.codeberg.org>
Co-authored-by: Benedikt Straub <benedikt-straub@web.de>
Co-authored-by: Codeberg Translate <translate@codeberg.org>
Co-authored-by: Edgarsons <edgarsons@noreply.codeberg.org>
Co-authored-by: EifionLlwyd <eifionllwyd@noreply.codeberg.org>
Co-authored-by: Fjuro <fjuro@alius.cz>
Co-authored-by: Gusted <postmaster@gusted.xyz>
Co-authored-by: Juno Takano <jutty@noreply.codeberg.org>
Co-authored-by: Languages add-on <noreply-addon-languages@weblate.org>
Co-authored-by: Outbreak2096 <outbreak2096@noreply.codeberg.org>
Co-authored-by: SomeTr <sometr@noreply.codeberg.org>
Co-authored-by: Vyxie <kitakita@disroot.org>
Co-authored-by: Wuzzy <wuzzy@disroot.org>
Co-authored-by: artnay <artnay@noreply.codeberg.org>
Co-authored-by: bespinas <bespinas@noreply.codeberg.org>
Co-authored-by: chlorine <chlorine@noreply.codeberg.org>
Co-authored-by: ikks <ikks@noreply.codeberg.org>
Co-authored-by: justbispo <justbispo@noreply.codeberg.org>
Co-authored-by: oatbiscuits <oatbiscuits@noreply.codeberg.org>
Co-authored-by: xtex <xtexchooser@duck.com>
Co-authored-by: zaid1442011 <zaid1442011@noreply.codeberg.org>
Translate-URL: https://translate.codeberg.org/projects/forgejo/forgejo-next/cs/
Translate-URL: https://translate.codeberg.org/projects/forgejo/forgejo-next/de/
Translate-URL: https://translate.codeberg.org/projects/forgejo/forgejo-next/es/
Translate-URL: https://translate.codeberg.org/projects/forgejo/forgejo-next/fi/
Translate-URL: https://translate.codeberg.org/projects/forgejo/forgejo-next/fil/
Translate-URL: https://translate.codeberg.org/projects/forgejo/forgejo-next/lv/
Translate-URL: https://translate.codeberg.org/projects/forgejo/forgejo-next/nds/
Translate-URL: https://translate.codeberg.org/projects/forgejo/forgejo-next/nl/
Translate-URL: https://translate.codeberg.org/projects/forgejo/forgejo-next/pt_BR/
Translate-URL: https://translate.codeberg.org/projects/forgejo/forgejo-next/pt_PT/
Translate-URL: https://translate.codeberg.org/projects/forgejo/forgejo-next/ru/
Translate-URL: https://translate.codeberg.org/projects/forgejo/forgejo-next/uk/
Translate-URL: https://translate.codeberg.org/projects/forgejo/forgejo-next/zh_Hans/
Translate-URL: https://translate.codeberg.org/projects/forgejo/forgejo/ar/
Translate-URL: https://translate.codeberg.org/projects/forgejo/forgejo/ca/
Translate-URL: https://translate.codeberg.org/projects/forgejo/forgejo/cs/
Translate-URL: https://translate.codeberg.org/projects/forgejo/forgejo/es/
Translate-URL: https://translate.codeberg.org/projects/forgejo/forgejo/fil/
Translate-URL: https://translate.codeberg.org/projects/forgejo/forgejo/lv/
Translate-URL: https://translate.codeberg.org/projects/forgejo/forgejo/nds/
Translate-URL: https://translate.codeberg.org/projects/forgejo/forgejo/pt_BR/
Translate-URL: https://translate.codeberg.org/projects/forgejo/forgejo/pt_PT/
Translate-URL: https://translate.codeberg.org/projects/forgejo/forgejo/ru/
Translate-URL: https://translate.codeberg.org/projects/forgejo/forgejo/uk/
Translate-URL: https://translate.codeberg.org/projects/forgejo/forgejo/zh_Hans/
Translation: Forgejo/forgejo
Translation: Forgejo/forgejo-next
2025-08-31 04:51:49 +00:00
Mathieu Fenniak
5596cd8d7a fix: very long commit messages cause pushed commits to fail to display on the action feed on MySQL (#9098)
When adding "user pushed to ..." and "user synced commits to ..." messages to the activity feed, the `actionNotifier` currently records the entire commit message into the `action.content` field, but when displaying the commit in the activity feed only the first line of the message is displayed.  This change tweaks the JSON `Message` field to be abbreviated using the `abbreviatedComment` function, which will include only the first 200 characters of the first line of the commit message.  This will reduce wasted storage in the `action` table to persist duplicated messages that aren't fully displayed in the UI anyway.

Fixes #8447, which is an error that occurs in this method due to the 64K character limit in `TEXT` fields in MySQL and the possibility of syncing FEED_MAX_COMMIT_NUM (default 5) long commit messages and exceeding this limit.

Automated testing is bolted onto existing tests.  I've cloned the entire structures before mutating them to ensure the mutations don't affect the webhook notifier.

## 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.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9098
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
Co-authored-by: Mathieu Fenniak <mathieu@fenniak.net>
Co-committed-by: Mathieu Fenniak <mathieu@fenniak.net>
2025-08-30 22:23:43 +02:00
0ko
654b6bf041 fix(i18n/en): update a few source strings (#9092)
Followup to https://codeberg.org/forgejo/forgejo/pulls/9064

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9092
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
2025-08-30 19:50:03 +02:00
0ko
18cd9b5efa feat(ui): implement hover for switch (#9057)
Followup to https://codeberg.org/forgejo/forgejo/issues/6459

Preview:
- https://codeberg.org/attachments/cc12a227-c6eb-4ab5-91ad-0ef967f88c7a
- https://codeberg.org/attachments/a13c8cb6-f654-430c-a6c6-990a2a7f0911

Changes:
- hovered items now have background painted with transition
- added E2E testing: mostly for CSS logic introduced in this PR but also a bit for existing functionality
- variable --color-active is now consistently non-transparent: it already was in forgejo-dark but is now in all themes
- some code improvements in switch.css

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9057
Reviewed-by: Beowulf <beowulf@beocode.eu>
2025-08-30 18:54:11 +02:00
Earl Warren
9ed225b100 fix: delete old auth token upon replacing primary email (#9076)
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9076
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Reviewed-by: 0ko <0ko@noreply.codeberg.org>
2025-08-30 13:16:37 +02:00
Earl Warren
48e29ff861 fix: ensure GetUserByEmail only considers validated emails (#9075)
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9075
Reviewed-by: 0ko <0ko@noreply.codeberg.org>
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
2025-08-30 13:16:03 +02:00
Earl Warren
1b13fda06b fix: email comments are removed from email addresses (#9074)
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9074
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Reviewed-by: 0ko <0ko@noreply.codeberg.org>
2025-08-30 13:15:30 +02:00
Earl Warren
39607fca1d fix: consistently enforce 2FA on OpenID 2.0 (#9073)
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9073
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
2025-08-30 13:14:54 +02:00
Earl Warren
b982fde455 fix: only redirect to a new owner (organization or user) if the user has permissions to view the new owner (#9072)
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9072
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Reviewed-by: 0ko <0ko@noreply.codeberg.org>
2025-08-30 13:14:06 +02:00
Earl Warren
608f9ee8e6 fix: validate CSRF on non-safe methods (#9071)
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9071
Reviewed-by: 0ko <0ko@noreply.codeberg.org>
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
2025-08-30 13:13:29 +02:00
Earl Warren
c064ce4ad0 fix: require password login for creation of new token (#9070)
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9070
Reviewed-by: 0ko <0ko@noreply.codeberg.org>
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
2025-08-30 13:12:54 +02:00
Earl Warren
829062808a fix: use credentials helpers for git clones (#9067)
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9067
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
2025-08-30 13:12:11 +02:00
Earl Warren
3bf52efe63 fix: don't allow credentials in migrate/push mirror URL (#9064)
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9064
Reviewed-by: 0ko <0ko@noreply.codeberg.org>
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
2025-08-30 13:11:15 +02:00
Gusted
d2a6e2362a
chore: add delete old auth token unit test
Also make use of subtests to make reading this test a tad easier.
2025-08-30 09:54:38 +02:00
Gusted
5ce1b564dc
fix: delete old auth token upon replacing primary email 2025-08-30 09:54:32 +02:00
Gusted
7287495064
chore: add user by email unit tests 2025-08-30 09:50:29 +02:00
Gusted
e746cc80a4
fix: generate correct SQL query for GetUserByEmail
xorm ignores any boolean values that are set in the struct given via
`Get`: 7654b7b749/internal/statements/statement.go (L384-L390)
2025-08-30 09:50:23 +02:00
famfo
a511e37572
chore: add email blocklist unit test 2025-08-30 09:45:19 +02:00
famfo
cf1fda81f6
fix: properly validate email containing comments
Originally reported by jomo (https://jomo.tv). A malicious actor could
register with an email address containing a comment, for example
"attacker@evil (comment@broken)". This commit fixes this issue by only
operating on normalized email addresses.

Signed-off-by: famfo <famfo@famfo.xyz>
2025-08-30 09:45:14 +02:00
Gusted
90e974cd24
fix: do 2FA on OpenID connect 2025-08-30 09:41:20 +02:00
Gusted
1fc1f24cad
chore: add repo redirect unit test 2025-08-30 09:37:38 +02:00
Gusted
ca7fcacddc
fix: do permission check for repository redirect 2025-08-30 09:37:34 +02:00
Gusted
50837322cc
chore: add unit test 2025-08-30 09:37:30 +02:00
Gusted
4019b99217
fix: do visibility check for user redirect lookup 2025-08-30 09:37:25 +02:00
Gusted
5fdd6ce9a6
chore: add integration test
Verify that PUT/DELETE requests return invalid CSRF token when no CSRF
token is given with the request.
2025-08-30 09:32:49 +02:00
Gusted
4dfb3facb4
fix: validate CSRF on non-safe methods
- CSRF has to be validated for any request that can change the state, in
practice this means any HTTP request where the method isn't
GET/HEAD/OPTIONS.
- The code only considered POST to be a state-changing request.
- Forgejo has several PUT/DELETE (that changes state) routes for which
no CSRF was being validated.
- Change the code to validate CSRF for all non-"safe" methods.
2025-08-30 09:32:43 +02:00
Gusted
7bf7c0cb61
chore: add integration test
Add a test that verifies that you cannot create new tokens via basic
OAuth2 and basic access token.
2025-08-30 09:27:33 +02:00
Gusted
85e839e21d
fix: require password login for creation of new token
- The creation of new API tokens for users via the API is guarded behind
a extra check. This extra makes sure the user is authorized via the
reverse proxy method (if enabled) or via basic authorization.
- For, what seems to me, historical reasons the basic authorization also
handles logging in via the API token.
- This results in a API token (with `write:user` scope) or OAuth2 token
being able to create a new API token with escalated privileges.
- Add a new condition to this check to ensure the user logged in via
password.
- Change error to better indicate what went wrong.
2025-08-30 09:27:28 +02:00
Gusted
f7fb1226a4
chore: unbreak existing tests
Because the user:password is no longer automatically set as upstream
origin, we have to set it manually if we want push to work.
2025-08-30 08:52:34 +02:00
Gusted
9fb75a141d
chore: add migration credentials integration test 2025-08-30 08:52:29 +02:00
Gusted
1c66c4e11a
chore: add extra shell escape tests 2025-08-30 08:52:25 +02:00
Gusted
900ea0ce5a
chore: add clone credential unit test
Verify it still works and the askpass file implementation is employed by Git.
2025-08-30 08:52:20 +02:00
Gusted
f7f7d086e4
fix: use credentials helpers for git clones
- When cloning with credentials is used, don't set the credentials in
the URL and pass that to Git, instead use Git credential helper to pass
the credential. This avoids the credentials to be leaked through the
process list.
2025-08-30 08:52:15 +02:00
Gusted
374a29fd35
chore: add integration test
Demonstrate that the it's not possible to migrate or add a push mirror
from a URL that contains credentials.
2025-08-30 08:07:26 +02:00
Gusted
9f955b300b
fix: don't allow credentials in migrate/push mirror URL
Do not allow credentials to be present in the URLs that are provided for
migrations and push mirrors. They have to be given via the dedicated
input fields. Give a error when this happens.

There's nothing wrong with trying have the backend "correct" this, but
would be a larger patch than necessary in the context of a security fix.
This can be done in public.
2025-08-30 08:07:23 +02:00
Gusted
d00200dc3e
chore: add integration test
Demonstrate that the credential isn't shown in the flash message
2025-08-30 08:07:21 +02:00
Gergely Nagy
145dea59bb
fix: sanitize OriginalURL before displaying it
While `repo.OriginalURL` is supposed to be sanitized, with username and
passwords removed, it appears that is not always the case, and sometimes
we may encounter original URLs that aren't sanitized. While that is
possibly a historical artifact, we should still treat it with care.

As such, before displaying `repo.OriginalURL` as an info flash when
syncing a pull repository, sanitize the URL first, to be on the safe
side.

Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
2025-08-30 08:07:17 +02:00
BtbN
9828aca733 feat: github compatability for removing label from issue API (#8831)
On GitHub, `DELETE /repos/{owner}/{repo}/issues/{index}/labels/{id}` takes the label name, not id:

https://docs.github.com/en/rest/issues/labels?apiVersion=2022-11-28#remove-a-label-from-an-issue

This breaks workflows and actions that interact with labels and delete them.
It also makes the API quite difficult to use, always having to query the ID first before deleting a label from an issue, potentially with two API calls, because it could be a repo or org label.

For backwards compatibility, if no label with the given name is found, and the name converts to an int without error, it'll still be looked up by ID.

The API on GitHub also does not return 204, but 200, with the label it just removed from the issue as content. So this is returned when `application/vnd.github+json` is set in the `Accept` request header.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8831
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: BtbN <btbn@btbn.de>
Co-committed-by: BtbN <btbn@btbn.de>
2025-08-30 03:29:23 +02:00
Mathieu Fenniak
86ce1477c1 test(e2e): improve reliability of workflow list dynamic refresh test (#9059)
The "refresh does not break interacting with open drop-downs" is flaky.  It attempts to verify that a refresh of the "Actions" list page does not occur when the user is currently navigating the dropdowns on the page, as htmx would replace their dropdowns mid-action.  It does this by clicking on the dropdowns, verifying the dropdown text is visible, simulating a refresh, and verifying that the dropdown text is still visible.

Example failure log:
```
  1) [chromium] › tests/e2e/actions.test.e2e.ts:173:3 › workflow list dynamic refresh › refresh does not break interacting with open drop-downs

    Error: Timed out 3000ms waiting for expect(locator).toBeVisible()

    Locator: getByText('Waiting')
    Expected: visible
    Received: hidden
    Call log:
      - Expect "toBeVisible" with timeout 3000ms
      - waiting for getByText('Waiting')
        7 × locator resolved to <a class="item" href="?workflow=test-dispatch.yml&actor=0&status=5">↵⇆⇆⇆⇆⇆⇆⇆Waiting↵⇆⇆⇆⇆⇆⇆</a>
          - unexpected value "hidden"

      194 |     await expect(page.getByText('Failure')).toBeVisible();
      195 |     await simulatePollingInterval(page);
    > 196 |     await expect(page.getByText('Waiting')).toBeVisible();
          |                                             ^
      197 |     await expect(page.getByText('Failure')).toBeVisible();
      198 |
      199 |     // Actor dropdown
        at /workspace/forgejo/forgejo/tests/e2e/actions.test.e2e.ts:196:45
```

The dropdown list stops refreshes if there are any `[aria-expanded=true]` elements on the page:
ab6ea6a743/templates/repo/actions/list.tmpl (L31-L33)

But fomantic doesn't set the `aria-expanded` attribute immediately on mouseup; it delays for up to 100ms:
f8a332c2e6/web_src/js/modules/fomantic/dropdown.js (L241-L246)

The easiest fix is to align the test's expectations with the underlying code, which is to verify that the `aria-expanded=true` element is present in the test before proceeding with the simulated refresh.

Before this change, this test would fail as frequently as 10-out-of-10 in local runs, but usually more around 70% (albeit closer to 0% in a playwright ui).  After this change, I've executed the test with zero failures in 100 back-to-back runs with `npx playwright test ./tests/e2e/actions.test.e2e.ts --project chromium --repeat-each 100`.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9059
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: Mathieu Fenniak <mathieu@fenniak.net>
Co-committed-by: Mathieu Fenniak <mathieu@fenniak.net>
2025-08-30 01:38:38 +02:00