From acbdc44d005cea63d1e2c45ca3b958364298ffc9 Mon Sep 17 00:00:00 2001 From: silverwind Date: Thu, 23 Jul 2026 09:29:36 +0200 Subject: [PATCH] test(e2e): add pull request merge box test, update AGENTS.md (#38576) Adds browser-level coverage for the pull request merge box, which currently had no tests. Exercises the full merge flow: open the PR, expand the merge form, submit, and assert the merged state. Extracted from https://github.com/go-gitea/gitea/pull/36759. Also updated AGENTS.md with instructions for e2e tests. --------- Signed-off-by: silverwind Co-authored-by: Giteabot --- AGENTS.md | 3 ++- tests/e2e/pull-merge-box.test.ts | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 tests/e2e/pull-merge-box.test.ts diff --git a/AGENTS.md b/AGENTS.md index 5a4ecda6da..703362cec2 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -12,7 +12,8 @@ - Preserve existing code comments, do not remove or rewrite comments that are still relevant - Keep comments short, prefer same-line, explain why, never narrate code - Prefer unit tests over integration tests when logic is testable in isolation -- Aim for sub-2s local runtime for integration and e2e tests +- Aim for sub-2s local runtime per integration test and sub-4s per e2e test +- Prefer using semantic selectors in e2e tests - In TypeScript, use `!` (non-null assertion) instead of `?.`/`??` when a value is known to always exist - For CSS layout, prefer `flex-*` helpers over per-child `tw-ml-*` / `tw-mr-*` margins; fall back to `tw-*` utilities when specificity requires `!important` - Include authorship attribution in issue and pull request comments diff --git a/tests/e2e/pull-merge-box.test.ts b/tests/e2e/pull-merge-box.test.ts new file mode 100644 index 0000000000..3b29e4383e --- /dev/null +++ b/tests/e2e/pull-merge-box.test.ts @@ -0,0 +1,23 @@ +import {env} from 'node:process'; +import {test, expect} from '@playwright/test'; +import {apiCreateFile, apiCreatePR, apiCreateRepo, assertNoJsError, login, randomString} from './utils.ts'; + +const owner = env.GITEA_TEST_E2E_USER; + +test('merge box merges a pull request', async ({page, request}) => { + const repo = `e2e-merge-box-${randomString(8)}`; + const createPR = (async () => { + await apiCreateRepo(request, {name: repo}); + await apiCreateFile(request, owner, repo, 'feat.txt', 'feature\n', {branch: 'main', newBranch: 'feat'}); + return apiCreatePR(request, owner, repo, 'feat', 'main', 'merge box test'); + })(); + const [index] = await Promise.all([createPR, login(page)]); + await page.goto(`/${owner}/${repo}/pulls/${index}`, {waitUntil: 'commit'}); + + // expand the merge form, then submit the merge + await page.getByRole('button', {name: 'Create merge commit'}).click(); + await page.locator('form.form-fetch-action').getByRole('button', {name: 'Create merge commit'}).click(); + + await expect(page.getByText(/successfully merged/i)).toBeVisible(); + await assertNoJsError(page); +});