You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
2.2 KiB

  1. // Copyright 2017 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package integrations
  5. import (
  6. "net/http"
  7. "strings"
  8. "testing"
  9. "github.com/stretchr/testify/assert"
  10. )
  11. func TestRepoActivity(t *testing.T) {
  12. prepareTestEnv(t)
  13. session := loginUser(t, "user1")
  14. // Create PRs (1 merged & 2 proposed)
  15. testRepoFork(t, session, "user2", "repo1", "user1", "repo1")
  16. testEditFile(t, session, "user1", "repo1", "master", "README.md", "Hello, World (Edited)\n")
  17. resp := testPullCreate(t, session, "user1", "repo1", "master")
  18. elem := strings.Split(RedirectURL(t, resp), "/")
  19. assert.EqualValues(t, "pulls", elem[3])
  20. testPullMerge(t, session, elem[1], elem[2], elem[4])
  21. testEditFileToNewBranch(t, session, "user1", "repo1", "master", "feat/better_readme", "README.md", "Hello, World (Edited Again)\n")
  22. testPullCreate(t, session, "user1", "repo1", "feat/better_readme")
  23. testEditFileToNewBranch(t, session, "user1", "repo1", "master", "feat/much_better_readme", "README.md", "Hello, World (Edited More)\n")
  24. testPullCreate(t, session, "user1", "repo1", "feat/much_better_readme")
  25. // Create issues (3 new issues)
  26. testNewIssue(t, session, "user2", "repo1", "Issue 1", "Description 1")
  27. testNewIssue(t, session, "user2", "repo1", "Issue 2", "Description 2")
  28. testNewIssue(t, session, "user2", "repo1", "Issue 3", "Description 3")
  29. // Create releases (1 new release)
  30. createNewRelease(t, session, "/user2/repo1", "v1.0.0", "v1.0.0", false, false)
  31. // Open Activity page and check stats
  32. req := NewRequest(t, "GET", "/user2/repo1/activity")
  33. resp = session.MakeRequest(t, req, http.StatusOK)
  34. htmlDoc := NewHTMLParser(t, resp.Body)
  35. // Should be 1 published release
  36. list := htmlDoc.doc.Find("#published-releases").Next().Find("p.desc")
  37. assert.Len(t, list.Nodes, 1)
  38. // Should be 1 merged pull request
  39. list = htmlDoc.doc.Find("#merged-pull-requests").Next().Find("p.desc")
  40. assert.Len(t, list.Nodes, 1)
  41. // Should be 2 merged proposed pull requests
  42. list = htmlDoc.doc.Find("#proposed-pull-requests").Next().Find("p.desc")
  43. assert.Len(t, list.Nodes, 2)
  44. // Should be 3 new issues
  45. list = htmlDoc.doc.Find("#new-issues").Next().Find("p.desc")
  46. assert.Len(t, list.Nodes, 3)
  47. }