code.gitea.io/gitea@v1.21.7/tests/integration/repo_activity_test.go (about) 1 // Copyright 2017 The Gitea Authors. All rights reserved. 2 // SPDX-License-Identifier: MIT 3 4 package integration 5 6 import ( 7 "net/http" 8 "net/url" 9 "strings" 10 "testing" 11 12 repo_model "code.gitea.io/gitea/models/repo" 13 "code.gitea.io/gitea/modules/test" 14 15 "github.com/stretchr/testify/assert" 16 ) 17 18 func TestRepoActivity(t *testing.T) { 19 onGiteaRun(t, func(t *testing.T, giteaURL *url.URL) { 20 session := loginUser(t, "user1") 21 22 // Create PRs (1 merged & 2 proposed) 23 testRepoFork(t, session, "user2", "repo1", "user1", "repo1") 24 testEditFile(t, session, "user1", "repo1", "master", "README.md", "Hello, World (Edited)\n") 25 resp := testPullCreate(t, session, "user1", "repo1", "master", "This is a pull title") 26 elem := strings.Split(test.RedirectURL(resp), "/") 27 assert.EqualValues(t, "pulls", elem[3]) 28 testPullMerge(t, session, elem[1], elem[2], elem[4], repo_model.MergeStyleMerge) 29 30 testEditFileToNewBranch(t, session, "user1", "repo1", "master", "feat/better_readme", "README.md", "Hello, World (Edited Again)\n") 31 testPullCreate(t, session, "user1", "repo1", "feat/better_readme", "This is a pull title") 32 33 testEditFileToNewBranch(t, session, "user1", "repo1", "master", "feat/much_better_readme", "README.md", "Hello, World (Edited More)\n") 34 testPullCreate(t, session, "user1", "repo1", "feat/much_better_readme", "This is a pull title") 35 36 // Create issues (3 new issues) 37 testNewIssue(t, session, "user2", "repo1", "Issue 1", "Description 1") 38 testNewIssue(t, session, "user2", "repo1", "Issue 2", "Description 2") 39 testNewIssue(t, session, "user2", "repo1", "Issue 3", "Description 3") 40 41 // Create releases (1 new release) 42 createNewRelease(t, session, "/user2/repo1", "v1.0.0", "v1.0.0", false, false) 43 44 // Open Activity page and check stats 45 req := NewRequest(t, "GET", "/user2/repo1/activity") 46 resp = session.MakeRequest(t, req, http.StatusOK) 47 htmlDoc := NewHTMLParser(t, resp.Body) 48 49 // Should be 1 published release 50 list := htmlDoc.doc.Find("#published-releases").Next().Find("p.desc") 51 assert.Len(t, list.Nodes, 1) 52 53 // Should be 1 merged pull request 54 list = htmlDoc.doc.Find("#merged-pull-requests").Next().Find("p.desc") 55 assert.Len(t, list.Nodes, 1) 56 57 // Should be 2 proposed pull requests 58 list = htmlDoc.doc.Find("#proposed-pull-requests").Next().Find("p.desc") 59 assert.Len(t, list.Nodes, 2) 60 61 // Should be 3 new issues 62 list = htmlDoc.doc.Find("#new-issues").Next().Find("p.desc") 63 assert.Len(t, list.Nodes, 3) 64 }) 65 }