From 713ab7cab43ef7558f78d2341947a8abd27088fa Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Sun, 22 Jun 2025 03:00:59 +0800 Subject: [PATCH] fix test --- routers/web/repo/editor.go | 2 +- tests/integration/editor_test.go | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/routers/web/repo/editor.go b/routers/web/repo/editor.go index 86fbdbb005..8badfb37c8 100644 --- a/routers/web/repo/editor.go +++ b/routers/web/repo/editor.go @@ -152,7 +152,7 @@ func prepareEditorCommitSubmittedForm[T forms.CommitCommonFormInterface](ctx *co ctx.JSONError(ctx.Tr("repo.editor.fork_failed_to_push_branch", targetBranchName)) return nil } - // since we have pushed the branch from base branch, so now we need to commit the changes directly + // we have pushed the base branch as the new branch, now we need to commit the changes directly to the new branch oldBranchName = targetBranchName } diff --git a/tests/integration/editor_test.go b/tests/integration/editor_test.go index d55ce4db94..5260e49b94 100644 --- a/tests/integration/editor_test.go +++ b/tests/integration/editor_test.go @@ -407,7 +407,7 @@ func testForkToEditFile(t *testing.T, session *TestSession, user, owner, repo, b assert.NotEmpty(t, lastCommit) // change a file in the forked repo - req = NewRequestWithValues(t, "POST", formAction, + req = NewRequestWithValues(t, "POST", fmt.Sprintf("/%s/%s-1/_edit/%s/%s?from_base_branch=%s", user, repo, branch, filePath, branch), map[string]string{ "_csrf": GetUserCSRFToken(t, session), "last_commit": lastCommit, @@ -418,7 +418,11 @@ func testForkToEditFile(t *testing.T, session *TestSession, user, owner, repo, b }, ) resp = session.MakeRequest(t, req, http.StatusOK) - assert.Equal(t, fmt.Sprintf("/%s/%s/compare/%s...%s/%s-1:%s-patch-1", owner, repo, branch, user, repo, user), test.RedirectURL(resp)) + assert.Equal(t, fmt.Sprintf("/%s/%s/compare/%s...%s/%s-1:%s", owner, repo, branch, user, repo, newBranchName), test.RedirectURL(resp)) + + req = NewRequest(t, "GET", fmt.Sprintf("/%s/%s-1/src/branch/%s/%s", user, repo, newBranchName, filePath)) + resp = session.MakeRequest(t, req, http.StatusOK) + assert.Contains(t, resp.Body.String(), "new content in fork") } func TestForkToEditFile(t *testing.T) {