summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPanagiotis "Ivory" Vasilopoulos <git@n0toose.net>2024-02-23 01:26:17 +0100
committerPanagiotis "Ivory" Vasilopoulos <git@n0toose.net>2024-02-23 21:09:08 +0100
commitbf7fb89178f41c712b8a8863667a442ec1e1c5d4 (patch)
tree1d9da0f24916dd88289bb519d94563bd93e8b9cd /tests
parentMerge pull request '[FEAT] repo search using git grep' (#1594) from snematoda... (diff)
downloadforgejo-bf7fb89178f41c712b8a8863667a442ec1e1c5d4.tar.xz
forgejo-bf7fb89178f41c712b8a8863667a442ec1e1c5d4.zip
[UI] Agit: Add AGit label to AGit-created PRs
Adds a label to Pull Requests that were created using AGit-Flow, in order to prevent situations where a contributor uses AGit-Flow to push new changes - only to realize that they did not use AGit-Flow in the first place, and that they just opened a new PR accidentally (that was me). Also intended to raise general awareness about the feature. Some additional work, such as adding a tooltip, still needs to be done. A small typo fix for a comment and (exclusively) formatting fixes in the copyright header are also included. Refs: https://codeberg.org/forgejo/forgejo/issues/2433
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/git_test.go26
1 files changed, 25 insertions, 1 deletions
diff --git a/tests/integration/git_test.go b/tests/integration/git_test.go
index d02427ffcf..ead649490e 100644
--- a/tests/integration/git_test.go
+++ b/tests/integration/git_test.go
@@ -450,7 +450,7 @@ func doMergeFork(ctx, baseCtx APITestContext, baseBranch, headBranch string) fun
var pr api.PullRequest
var err error
- // Create a test pullrequest
+ // Create a test pull request
t.Run("CreatePullRequest", func(t *testing.T) {
pr, err = doAPICreatePullRequest(ctx, baseCtx.Username, baseCtx.Reponame, baseBranch, headBranch)(t)
assert.NoError(t, err)
@@ -470,6 +470,19 @@ func doMergeFork(ctx, baseCtx APITestContext, baseBranch, headBranch string) fun
}
t.Run("EnsureCanSeePull", doEnsureCanSeePull(headCtx, pr, true))
+ // Confirm that there is no AGit Label
+ // TODO: Refactor and move this check to a function
+ t.Run("AGitLabelIsMissing", func(t *testing.T) {
+ defer tests.PrintCurrentTest(t)()
+
+ session := loginUser(t, ctx.Username)
+
+ req := NewRequest(t, "GET", fmt.Sprintf("/%s/%s/pulls/%d", baseCtx.Username, baseCtx.Reponame, pr.Index))
+ resp := session.MakeRequest(t, req, http.StatusOK)
+ htmlDoc := NewHTMLParser(t, resp.Body)
+ htmlDoc.AssertElement(t, "#agit-label", false)
+ })
+
// Then get the diff string
var diffHash string
var diffLength int
@@ -813,6 +826,17 @@ func doCreateAgitFlowPull(dstPath string, ctx *APITestContext, baseBranch, headB
return
}
+ t.Run("AGitLabelIsPresent", func(t *testing.T) {
+ defer tests.PrintCurrentTest(t)()
+
+ session := loginUser(t, ctx.Username)
+
+ req := NewRequest(t, "GET", fmt.Sprintf("/%s/%s/pulls/%d", url.PathEscape(ctx.Username), url.PathEscape(ctx.Reponame), pr2.Index))
+ resp := session.MakeRequest(t, req, http.StatusOK)
+ htmlDoc := NewHTMLParser(t, resp.Body)
+ htmlDoc.AssertElement(t, "#agit-label", true)
+ })
+
t.Run("AddCommit2", func(t *testing.T) {
err := os.WriteFile(path.Join(dstPath, "test_file"), []byte("## test content \n ## test content 2"), 0o666)
if !assert.NoError(t, err) {