From cfc72c7b809beb10fb466d44dda11d3380639f0a Mon Sep 17 00:00:00 2001 From: JakobDev Date: Tue, 23 Jul 2024 19:00:11 +0200 Subject: [PATCH] Add another test --- tests/integration/repo_sync_fork_test.go | 25 ++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/integration/repo_sync_fork_test.go b/tests/integration/repo_sync_fork_test.go index bc48a7b804..5f88aa6836 100644 --- a/tests/integration/repo_sync_fork_test.go +++ b/tests/integration/repo_sync_fork_test.go @@ -90,3 +90,28 @@ func TestWebRepoSyncForkBranch(t *testing.T) { syncForkTest(t, "SyncForkBranch", "sync_fork/master", true) }) } + +func TestWebRepoSyncForkHomepage(t *testing.T) { + onGiteaRun(t, func(*testing.T, *url.URL) { + forkName := "SyncForkHomepage" + user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 20}) + + baseRepo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1}) + baseUser := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: baseRepo.OwnerID}) + + session := loginUser(t, user.Name) + token := getTokenForLoggedInUser(t, session, auth_model.AccessTokenScopeWriteRepository) + + /// Create a new fork + req := NewRequestWithJSON(t, "POST", fmt.Sprintf("/api/v1/repos/%s/%s/forks", baseUser.Name, baseRepo.LowerName), &api.CreateForkOption{Name: &forkName}).AddTokenAuth(token) + MakeRequest(t, req, http.StatusAccepted) + + // Make a commit on the base branch + err := createOrReplaceFileInBranch(baseUser, baseRepo, "sync_fork.txt", "master", "Hello") + require.NoError(t, err) + + resp := session.MakeRequest(t, NewRequestf(t, "GET", "/%s/%s", user.Name, forkName), http.StatusOK) + + assert.Contains(t, resp.Body.String(), "This branch is 1 commit behind user2/repo1:master") + }) +}