From 83e6b0c0c64d831f24c91b4d38162451b30b9c1b Mon Sep 17 00:00:00 2001 From: 0ko <0ko@noreply.codeberg.org> Date: Wed, 29 May 2024 22:46:36 +0500 Subject: [PATCH] Fix localization of release/tag counters on releases page --- options/locale/locale_en-US.ini | 10 ++++++---- templates/repo/release_tag_header.tmpl | 4 ++-- tests/integration/release_test.go | 11 ++++++++++- tests/integration/repo_tag_test.go | 7 ++++--- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 31536b35e9..28f4d4b8ed 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -1231,22 +1231,22 @@ clear_ref = `Clear current reference` filter_branch_and_tag = Filter branch or tag find_tag = Find tag branches = Branches +tag = Tag tags = Tags issues = Issues pulls = Pull requests project_board = Projects packages = Packages actions = Actions +release = Release +releases = Releases labels = Labels +milestones = Milestones org_labels_desc = Organization level labels that can be used with all repositories under this organization org_labels_desc_manage = manage -milestones = Milestones commits = Commits commit = Commit -release = Release -releases = Releases -tag = Tag n_commit_one=%s commit n_commit_few=%s commits @@ -1254,6 +1254,8 @@ n_branch_one=%s branch n_branch_few=%s branches n_tag_one=%s tag n_tag_few=%s tags +n_release_one = %s release +n_release_few = %s releases released_this = released this file.title = %s at %s diff --git a/templates/repo/release_tag_header.tmpl b/templates/repo/release_tag_header.tmpl index 5896fdd19d..f4eeb532e0 100644 --- a/templates/repo/release_tag_header.tmpl +++ b/templates/repo/release_tag_header.tmpl @@ -5,9 +5,9 @@
diff --git a/tests/integration/release_test.go b/tests/integration/release_test.go index ad3c7bf325..48c2b37c91 100644 --- a/tests/integration/release_test.go +++ b/tests/integration/release_test.go @@ -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) } diff --git a/tests/integration/repo_tag_test.go b/tests/integration/repo_tag_test.go index 78e295f203..273d7f713c 100644 --- a/tests/integration/repo_tag_test.go +++ b/tests/integration/repo_tag_test.go @@ -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