Skip to content

Add pr-review e2e test and speed up e2e tests#37345

Merged
wxiaoguang merged 9 commits intogo-gitea:mainfrom
silverwind:e2e-pr-flow-tests
Apr 24, 2026
Merged

Add pr-review e2e test and speed up e2e tests#37345
wxiaoguang merged 9 commits intogo-gitea:mainfrom
silverwind:e2e-pr-flow-tests

Conversation

@silverwind
Copy link
Copy Markdown
Member

@silverwind silverwind commented Apr 21, 2026

  • add pr-review e2e test
  • speed up most tests by logging in via POST to avoid the login form, login form is still exercised in a dedicated test
  • speed up most tests be removing post-test cleanup, unnecessary because each repo is created with a unique name
  • misc parallelization and api call reduction
  • total suite runtime is about the same as before

This PR was written with the help of Claude Opus 4.7

Covers the highest-recurrence UI regressions from the last ~500 issues:
- pr-merge: default / delete-branch toggle / squash / conflicted
- pr-commits: new commit appears on reload
- pr-review: top-level / inline reply (go-gitea#35994) / approve / reject / self-review
- diff viewer: file-box render + split/unified toggle

Also rewrites `login` in `tests/e2e/utils.ts` to use a direct form POST
instead of driving the browser UI, which speeds up every existing e2e
test that logs in. `events.test.ts` gets an explicit `page.goto('/')`
since `login` no longer navigates.

New helpers in `utils.ts`: apiCreatePR, apiMergePR, apiCreateReview,
branch+file consolidation via `{branch, newBranch}` option on
apiCreateFile, optional `message` for deterministic commit summaries.

Co-Authored-By: Claude (Opus 4.7) <noreply@anthropic.com>
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Apr 21, 2026
@silverwind silverwind changed the title Add e2e tests for PR merge, commits, diff and review flows Add addiotional PR e2e tests and speed up all tests Apr 21, 2026
@silverwind silverwind changed the title Add addiotional PR e2e tests and speed up all tests Add additional pr e2e tests and speed up Apr 21, 2026
Keep `login.test.ts::login form and logout` as the sole test that
exercises the browser login form (since `utils.ts::login` now uses a
direct form POST).

Co-Authored-By: Claude (Opus 4.7) <noreply@anthropic.com>
@silverwind silverwind marked this pull request as draft April 21, 2026 19:28
silverwind and others added 2 commits April 21, 2026 21:34
- Collapse pr-merge/pr-commits/pr-review/diff-viewer to one test each;
  inline setup helpers. pr-review consolidates reply(go-gitea#35994) + approve
  into one flow with a mid-test session swap.
- Remove apiDeleteRepo/apiDeleteUser calls across 11 pre-existing tests
  — the e2e server is a per-run mktemp workdir killed on exit, and tests
  use randomString suffixes, so cleanup was pure overhead.
- Repurpose login.test.ts "login form and logout" to drive the browser
  login UI (utils.ts::login is now a direct form POST, no UI coverage).
- Drop MergeStyle/ReviewEvent type aliases and the now-unused apiMergePR
  helper; inline plain string on apiCreateReview's event param.

Co-Authored-By: Claude (Opus 4.7) <noreply@anthropic.com>
- events.test.ts::stopwatch: move loginUser into Promise.all with the
  repo/issue/stopwatch chain
- file-view-render.test.ts::asciicast: replace apiCreateFile+apiCreateBranch
  with a single apiCreateFile({newBranch}) — Gitea's file API creates the
  first commit on the specified branch when the repo is empty

Co-Authored-By: Claude (Opus 4.7) <noreply@anthropic.com>
@silverwind silverwind requested a review from Copilot April 21, 2026 19:40
@silverwind silverwind marked this pull request as ready for review April 21, 2026 19:40

This comment was marked as outdated.

@silverwind silverwind changed the title Add additional pr e2e tests and speed up Add pr-review e2e test and speed up Apr 21, 2026
silverwind and others added 2 commits April 21, 2026 21:58
Drop diff-viewer, pr-commits, pr-merge test files. Fold their assertions
into the single pr-review flow that already loads /files:
- diff-file-box header + add-code row (was diff-viewer)
- Commits tab badge count (was pr-commits)
- .diff-detail-stats changed-file count (was diff-viewer)

The reply-to-inline-comment (go-gitea#35994) and approve paths were the
highest-value; the dropped tests were cheap to fold in since /files
already rendered.

Co-Authored-By: Claude (Opus 4.7) <noreply@anthropic.com>
- apiCreateFile: base64-encode via Buffer UTF-8 instead of btoa to
  avoid Latin-1 range errors on non-ASCII content
- apiCreateReview: make options object optional (= {}); drop unused
  return value

Co-Authored-By: Claude (Opus 4.7) <noreply@anthropic.com>
@silverwind silverwind added the skip-changelog This PR is irrelevant for the (next) changelog, for example bug fixes for unreleased features. label Apr 23, 2026
@silverwind silverwind requested a review from bircni April 23, 2026 22:11
@silverwind silverwind changed the title Add pr-review e2e test and speed up Add pr-review e2e test and speed up e2e tests Apr 24, 2026
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Apr 24, 2026
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Apr 24, 2026
@wxiaoguang wxiaoguang enabled auto-merge (squash) April 24, 2026 07:39
@wxiaoguang
Copy link
Copy Markdown
Contributor

Tests are still flaky

https://github.com/go-gitea/gitea/actions/runs/24878089698/attempts/1



  1) [firefox] › tests/e2e/events.test.ts:51:3 › events › logout propagation ───────────────────────

    Error: expect(locator).toBeVisible() failed

    Locator: getByRole('link', { name: 'Sign In' })
    Expected: visible
    Timeout: 20000ms
    Error: element(s) not found

    Call log:
      - Expect "toBeVisible" with timeout 20000ms
      - waiting for getByRole('link', { name: 'Sign In' })


      71 |
      72 |     // page2 should be redirected via the logout event
    > 73 |     await expect(page2.getByRole('link', {name: 'Sign In'})).toBeVisible();
         |                                                              ^
      74 |
      75 |     await context.close();
      76 |   });
        at /home/runner/work/gitea/gitea/tests/e2e/events.test.ts:73:62

    Error Context: tests/e2e-output/events-events-logout-propagation-firefox/error-context.md

  1 failed
    [firefox] › tests/e2e/events.test.ts:51:3 › events › logout propagation ────────────────────────

@wxiaoguang wxiaoguang merged commit aa0707c into go-gitea:main Apr 24, 2026
26 checks passed
@wxiaoguang wxiaoguang deleted the e2e-pr-flow-tests branch April 24, 2026 08:20
@GiteaBot GiteaBot added this to the 1.27.0 milestone Apr 24, 2026
silverwind added a commit to mohammad-rj/gitea that referenced this pull request Apr 24, 2026
* origin/main: (127 commits)
  Refactor pull request view (1) (go-gitea#37380)
  Improve AGENTS.md (go-gitea#37382)
  Remove dead CSS (go-gitea#37376)
  Add pr-review e2e test and speed up e2e tests (go-gitea#37345)
  Drop Fomantic tab, checkbox and form patches (go-gitea#37377)
  fix: dump with default zip type produces uncompressed zip (go-gitea#37401)
  Allow fast-forward-only merge when signed commits are required (go-gitea#37335)
  Introduce `ActionRunAttempt` to represent each execution of a run (go-gitea#37119)
  Move review request functions to a standalone file (go-gitea#37358)
  Fix repo init README EOL (go-gitea#37388)
  Fix org team assignee/reviewer lookups for team member permissions (go-gitea#37365)
  Remove external service dependencies in migration tests (go-gitea#36866)
  Extend issue context popup beyond markdown content (go-gitea#36908)
  fix: commit status reporting (go-gitea#37372)
  Support for Custom URI Schemes in OAuth2 Redirect URIs (go-gitea#37356)
  Fix cmd tests by mocking builtin paths (go-gitea#37369)
  chore: upgrade Go version in devcontainer image to 1.26 (go-gitea#37374)
  Fix button layout shift when collapsing file tree in editor (go-gitea#37363)
  Update `Block a user` form (go-gitea#37359)
  Remove IsValidExternalURL/IsAPIURL and use IsValidURL at call sites (go-gitea#37364)
  ...

# Conflicts:
#	modules/eventsource/event.go
#	tests/e2e/events.test.ts
silverwind added a commit to TheFox0x7/gitea that referenced this pull request Apr 24, 2026
* origin/main:
  feat(security): set X-Content-Type-Options: nosniff by default (go-gitea#37354)
  Refactor pull request view (1) (go-gitea#37380)
  Improve AGENTS.md (go-gitea#37382)
  Remove dead CSS (go-gitea#37376)
  Add pr-review e2e test and speed up e2e tests (go-gitea#37345)
  Drop Fomantic tab, checkbox and form patches (go-gitea#37377)
silverwind added a commit to silverwind/gitea that referenced this pull request Apr 25, 2026
* origin/main: (51 commits)
  Fix color regressions, add `priority` color (go-gitea#37417)
  [skip ci] Updated translations via Crowdin
  Stabilize e2e logout propagation test (go-gitea#37403)
  refactor: serve site manifest via `/assets/site-manifest.json` endpoint (go-gitea#37405)
  feat(security): set X-Content-Type-Options: nosniff by default (go-gitea#37354)
  Refactor pull request view (1) (go-gitea#37380)
  Improve AGENTS.md (go-gitea#37382)
  Remove dead CSS (go-gitea#37376)
  Add pr-review e2e test and speed up e2e tests (go-gitea#37345)
  Drop Fomantic tab, checkbox and form patches (go-gitea#37377)
  fix: dump with default zip type produces uncompressed zip (go-gitea#37401)
  Allow fast-forward-only merge when signed commits are required (go-gitea#37335)
  Introduce `ActionRunAttempt` to represent each execution of a run (go-gitea#37119)
  Move review request functions to a standalone file (go-gitea#37358)
  Fix repo init README EOL (go-gitea#37388)
  Fix org team assignee/reviewer lookups for team member permissions (go-gitea#37365)
  Remove external service dependencies in migration tests (go-gitea#36866)
  Extend issue context popup beyond markdown content (go-gitea#36908)
  fix: commit status reporting (go-gitea#37372)
  Support for Custom URI Schemes in OAuth2 Redirect URIs (go-gitea#37356)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. skip-changelog This PR is irrelevant for the (next) changelog, for example bug fixes for unreleased features. type/testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants