Fix localization of release/tag counters on releases page

This commit is contained in:
0ko 2024-05-29 22:46:36 +05:00
parent 95ccbb5995
commit 83e6b0c0c6
4 changed files with 22 additions and 10 deletions

View file

@ -1,4 +1,5 @@
// Copyright 2017 The Gitea Authors. All rights reserved.
// Copyright 2024 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package integration
@ -6,6 +7,7 @@ package integration
import (
"fmt"
"net/http"
"strconv"
"testing"
"time"
@ -66,6 +68,13 @@ func checkLatestReleaseAndCount(t *testing.T, session *TestSession, repoURL, ver
titleText := htmlDoc.doc.Find("#release-list > li .detail h4 a").First().Text()
assert.EqualValues(t, version, titleText)
// Check release count in the counter on the Release/Tag switch, as well as that the tab is highlighted
if count < 10 { // Only check values less than 10, should be enough attempts before this test cracks
// 10 is the pagination limit, but the counter can have more than that
releaseTab := htmlDoc.doc.Find(".repository.releases .ui.compact.menu a.active.item[href$='/releases']")
assert.Contains(t, releaseTab.Text(), strconv.Itoa(count)+" release") // Could be "1 release" or "4 releases"
}
releaseList := htmlDoc.doc.Find("#release-list > li")
assert.EqualValues(t, count, releaseList.Length())
}
@ -77,7 +86,7 @@ func TestViewReleases(t *testing.T) {
req := NewRequest(t, "GET", "/user2/repo1/releases")
session.MakeRequest(t, req, http.StatusOK)
// if CI is to slow this test fail, so lets wait a bit
// if CI is too slow this test fail, so lets wait a bit
time.Sleep(time.Millisecond * 100)
}

View file

@ -50,12 +50,13 @@ func TestTagViewWithoutRelease(t *testing.T) {
req := NewRequestf(t, "GET", "/%s/releases/tag/no-release", repo.FullName())
resp := MakeRequest(t, req, http.StatusOK)
// Test that the tags sub-menu is active
// Test that the tags sub-menu is active and has a counter
htmlDoc := NewHTMLParser(t, resp.Body)
htmlDoc.AssertElement(t, ".small-menu-items .active.item[href*='/tags']", true)
tagsTab := htmlDoc.Find(".small-menu-items .active.item[href$='/tags']")
assert.Contains(t, tagsTab.Text(), "4 tags")
// Test that the release sub-menu isn't active
releaseLink := htmlDoc.Find(".small-menu-items .item[href*='/releases']")
releaseLink := htmlDoc.Find(".small-menu-items .item[href$='/releases']")
assert.False(t, releaseLink.HasClass("active"))
// Test that the title is displayed