summaryrefslogtreecommitdiffstats
path: root/tests/integration
diff options
context:
space:
mode:
authoroliverpool <3864879+oliverpool@users.noreply.github.com>2023-04-18 21:11:17 +0200
committerGitHub <noreply@github.com>2023-04-18 21:11:17 +0200
commitbb2783860b8db033f9dcbd223a6c8b5a5c1044ac (patch)
tree3107ddfb1418ca3e2ab07041c75fe61640d18955 /tests/integration
parent75b9845420bb5686fc212272a4d9a07543eaced7 (diff)
downloadgitea-bb2783860b8db033f9dcbd223a6c8b5a5c1044ac.tar.gz
gitea-bb2783860b8db033f9dcbd223a6c8b5a5c1044ac.zip
fix calReleaseNumCommitsBehind (#24148)
`repoCtx.CommitsCount` is not reliably the commit count of the default branch (Repository.GetCommitsCount depends on what is currently displayed). For instance on the releases page the commit count is correct: https://codeberg.org/Codeberg/pages-server/releases ![2023-04-15-215027](https://user-images.githubusercontent.com/3864879/232250500-6c05dc00-7030-4ec9-87f1-18c7797d36bf.png) However it is not on the single page: https://codeberg.org/Codeberg/pages-server/releases/tag/v4.6.2 ![2023-04-15-215036](https://user-images.githubusercontent.com/3864879/232250503-620c8038-7c2c-45a1-b99d-cb994ef955a6.png) This PR fixes this by removing a "fast branch" which was using this field (I think this field should be removed, since it is a bit unpredictable - but this would mean a larger refactoring PR). _contributed in the context of @forgejo_ --------- Co-authored-by: Giteabot <teabot@gitea.io> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'tests/integration')
-rw-r--r--tests/integration/api_repo_test.go6
-rw-r--r--tests/integration/release_test.go33
2 files changed, 32 insertions, 7 deletions
diff --git a/tests/integration/api_repo_test.go b/tests/integration/api_repo_test.go
index 76ceb779e0..b3a184eddd 100644
--- a/tests/integration/api_repo_test.go
+++ b/tests/integration/api_repo_test.go
@@ -82,9 +82,9 @@ func TestAPISearchRepo(t *testing.T) {
}{
{
name: "RepositoriesMax50", requestURL: "/api/v1/repos/search?limit=50&private=false", expectedResults: expectedResults{
- nil: {count: 31},
- user: {count: 31},
- user2: {count: 31},
+ nil: {count: 32},
+ user: {count: 32},
+ user2: {count: 32},
},
},
{
diff --git a/tests/integration/release_test.go b/tests/integration/release_test.go
index 9f971d4c85..8e3f96c93b 100644
--- a/tests/integration/release_test.go
+++ b/tests/integration/release_test.go
@@ -134,7 +134,7 @@ func TestCreateReleasePaging(t *testing.T) {
func TestViewReleaseListNoLogin(t *testing.T) {
defer tests.PrepareTestEnv(t)()
- repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
+ repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 57, OwnerName: "user2", LowerName: "repo-release"})
link := repo.Link() + "/releases"
@@ -143,18 +143,43 @@ func TestViewReleaseListNoLogin(t *testing.T) {
htmlDoc := NewHTMLParser(t, rsp.Body)
releases := htmlDoc.Find("#release-list li.ui.grid")
- assert.Equal(t, 2, releases.Length())
+ assert.Equal(t, 3, releases.Length())
- links := make([]string, 0, 5)
+ links := make([]string, 0, 3)
+ commitsToMain := make([]string, 0, 3)
releases.Each(func(i int, s *goquery.Selection) {
link, exist := s.Find(".release-list-title a").Attr("href")
if !exist {
return
}
links = append(links, link)
+
+ commitsToMain = append(commitsToMain, s.Find(".ahead > a").Text())
})
- assert.EqualValues(t, []string{"/user2/repo1/releases/tag/v1.0", "/user2/repo1/releases/tag/v1.1"}, links)
+ assert.EqualValues(t, []string{
+ "/user2/repo-release/releases/tag/v2.0",
+ "/user2/repo-release/releases/tag/v1.1",
+ "/user2/repo-release/releases/tag/v1.0",
+ }, links)
+ assert.EqualValues(t, []string{
+ "0 commits",
+ "1 commits", // should be 3 commits ahead and 2 commits behind, but not implemented yet
+ "3 commits",
+ }, commitsToMain)
+}
+
+func TestViewSingleReleaseNoLogin(t *testing.T) {
+ defer tests.PrepareTestEnv(t)()
+
+ req := NewRequest(t, "GET", "/user2/repo-release/releases/tag/v1.0")
+ resp := MakeRequest(t, req, http.StatusOK)
+
+ htmlDoc := NewHTMLParser(t, resp.Body)
+ // check the "number of commits to main since this release"
+ releaseList := htmlDoc.doc.Find("#release-list .ahead > a")
+ assert.EqualValues(t, 1, releaseList.Length())
+ assert.EqualValues(t, "3 commits", releaseList.First().Text())
}
func TestViewReleaseListLogin(t *testing.T) {