mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-08-22 02:11:12 +00:00
If a change is part of a force-push and the commit(s) have a CI status, this will now be shown after the hashes. `interactiveBorder` has been lowered as it was possible to activate the hover state for both commits. It would be unreasonable to test this within Playwright and thus this needs to be manually tested. On a pull request page that contains a force-push you will notice: a) the (de)activation area for force-pushes is now smaller, and; b) it is not possible to activate the hover state/popup for both commits. ExecuteTemplate function from @gusted https://codeberg.org/forgejo/forgejo/pulls/5168 https://codeberg.org/forgejo/forgejo/pulls/2884 Close #4932 Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8655 Reviewed-by: Otto <otto@codeberg.org> Reviewed-by: 0ko <0ko@noreply.codeberg.org> Co-authored-by: Squel <squeljur+git@gmail.com> Co-committed-by: Squel <squeljur+git@gmail.com>
63 lines
2.1 KiB
Go
63 lines
2.1 KiB
Go
// Copyright 20124 The Forgejo Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package integration
|
|
|
|
import (
|
|
"net/http"
|
|
"net/url"
|
|
"testing"
|
|
|
|
actions_model "forgejo.org/models/actions"
|
|
"forgejo.org/models/db"
|
|
issues_model "forgejo.org/models/issues"
|
|
repo_model "forgejo.org/models/repo"
|
|
"forgejo.org/models/unittest"
|
|
user_model "forgejo.org/models/user"
|
|
"forgejo.org/modules/setting"
|
|
"forgejo.org/modules/test"
|
|
"forgejo.org/services/actions"
|
|
"forgejo.org/services/automerge"
|
|
"forgejo.org/tests"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestActionsAutomerge(t *testing.T) {
|
|
onGiteaRun(t, func(t *testing.T, u *url.URL) {
|
|
defer test.MockVariableValue(&setting.Actions.Enabled, true)()
|
|
|
|
ctx := db.DefaultContext
|
|
|
|
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
|
|
pr := unittest.AssertExistsAndLoadBean(t, &issues_model.PullRequest{ID: 2})
|
|
job := unittest.AssertExistsAndLoadBean(t, &actions_model.ActionRunJob{ID: 292})
|
|
|
|
assert.False(t, pr.HasMerged, "PR should not be merged")
|
|
assert.Equal(t, issues_model.PullRequestStatusMergeable, pr.Status, "PR should be mergeable")
|
|
|
|
scheduled, err := automerge.ScheduleAutoMerge(ctx, user, pr, repo_model.MergeStyleMerge, "Dummy", false)
|
|
|
|
require.NoError(t, err, "PR should be scheduled for automerge")
|
|
assert.True(t, scheduled, "PR should be scheduled for automerge")
|
|
|
|
actions.CreateCommitStatus(ctx, job)
|
|
|
|
pr = unittest.AssertExistsAndLoadBean(t, &issues_model.PullRequest{ID: 2})
|
|
|
|
assert.True(t, pr.HasMerged, "PR should be merged")
|
|
},
|
|
)
|
|
}
|
|
|
|
func TestForcePushCommitStatus(t *testing.T) {
|
|
defer unittest.OverrideFixtures("tests/integration/fixtures/TestForcePushCommitStatus/")()
|
|
defer tests.PrepareTestEnv(t)()
|
|
|
|
req := NewRequest(t, "GET", "/user2/commitsonpr/pulls/1")
|
|
resp := MakeRequest(t, req, http.StatusOK)
|
|
htmlDoc := NewHTMLParser(t, resp.Body)
|
|
htmlDoc.AssertElement(t, ".forced-push [data-tippy='commit-statuses']:nth-of-type(3) svg.commit-status.octicon-dot-fill", true)
|
|
htmlDoc.AssertElement(t, ".forced-push [data-tippy='commit-statuses']:nth-of-type(5) svg.commit-status.octicon-check", true)
|
|
}
|