fix: make "edit pr title & target branch" get correct branch (#39612)

* Fix #39610
* Regression of #39262

Also, the old code is very fragile: `#branch_target` is from translation
string, so refactored it together

---------

Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
wxiaoguangandsilverwind authored and GitHub committed 2026-10-05 20:29:33 +00:00
1 parent 4e2c3e43f2
commit b1726adebb
3 files changed
+36 -8

No files matched your search

+30 -4
View File
@@ -1,8 +1,8 @@
import {env} from 'node:process';
import {test, expect} from '@playwright/test';
import {login, apiCreateRepo, apiCreateFiles, randomString} from './utils.ts';
import {login, apiCreateRepo, apiCreateFiles, apiCreatePR, randomString} from './utils.ts';
test('create a pull request from the compare page', async ({page, request}) => {
test('create a pull request from the compare page and edit its title', async ({page, request}) => {
const repoName = `e2e-pr-create-${randomString(8)}`;
const owner = env.GITEA_TEST_E2E_USER;
await apiCreateRepo(request, {name: repoName});
@@ -17,7 +17,33 @@ test('create a pull request from the compare page', async ({page, request}) => {
await page.getByPlaceholder('Title').fill(title);
await page.getByRole('button', {name: 'Create Pull Request'}).click();
// commit, not full load: the PR title heading is server-rendered, so the assertion can resolve before the heavy diff/timeline finishes
await page.waitForURL(new RegExp(`/${owner}/${repoName}/pulls/\\d+$`), {waitUntil: 'commit'});
await page.waitForURL(new RegExp(`/${owner}/${repoName}/pulls/\\d+$`), {waitUntil: 'domcontentloaded'});
await expect(page.getByRole('heading', {name: title})).toBeVisible();
const titleEditor = page.locator('#issue-title-editor');
await page.locator('#issue-title-display').getByRole('button', {name: 'Edit'}).click();
await titleEditor.getByRole('textbox').fill('edited title');
await titleEditor.getByRole('button', {name: 'Save'}).click();
await expect(page.getByRole('heading', {name: 'edited title'})).toBeVisible();
});
test('change the target branch of a pull request', async ({page, request}) => {
const repoName = `e2e-pr-target-${randomString(8)}`;
const owner = env.GITEA_TEST_E2E_USER;
const createPR = (async () => {
await apiCreateRepo(request, {name: repoName});
await Promise.all([
apiCreateFiles(request, owner, repoName, [{path: 'feat.txt', content: 'feature content\n'}], {branch: 'main', newBranch: 'feat'}),
apiCreateFiles(request, owner, repoName, [{path: 'release.txt', content: 'release content\n'}], {branch: 'main', newBranch: 'release'}),
]);
return apiCreatePR(request, owner, repoName, 'feat', 'main', 'title');
})();
const [index] = await Promise.all([createPR, login(page)]);
await page.goto(`/${owner}/${repoName}/pulls/${index}`, {waitUntil: 'domcontentloaded'});
await page.locator('#issue-title-display').getByRole('button', {name: 'Edit'}).click();
await page.locator('#pull-target-branch').click();
await page.locator('#branch-select').getByText(`${owner}:release`).click();
await page.locator('#issue-title-editor').getByRole('button', {name: 'Save'}).click();
await expect(page.locator('#pull-desc-display')).toContainText('into release');
});