diff --git a/templates/repo/issue/filter_list.tmpl b/templates/repo/issue/filter_list.tmpl index f774d517ea..0e1d8f8036 100644 --- a/templates/repo/issue/filter_list.tmpl +++ b/templates/repo/issue/filter_list.tmpl @@ -148,7 +148,7 @@ <div class="menu"> <a rel="nofollow" class="{{if or (eq .SortType "relevance") (not .SortType)}}active {{end}}item" href="?q={{$.Keyword}}&type={{$.ViewType}}&sort=relevency&state={{$.State}}&labels={{.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}&fuzzy={{$.IsFuzzy}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">{{ctx.Locale.Tr "repo.issues.filter_sort.relevance"}}</a> {{$o := .}} - {{range $opt := StringUtils.Make "latest" "oldest" "recentupdate" "mostcomment" "leastcomment" "nearduedate" "farduedate"}} + {{range $opt := StringUtils.Make "latest" "oldest" "recentupdate" "leastupdate" "mostcomment" "leastcomment" "nearduedate" "farduedate"}} {{$text := ctx.Locale.Tr (printf "repo.issues.filter_sort.%s" $opt)}} <a rel="nofollow" class="{{if eq $o.SortType $opt}}active {{end}}item" href="?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$opt}}&state={{$.State}}&labels={{$o.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}&fuzzy={{$.IsFuzzy}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">{{$text}}</a> {{end}} diff --git a/tests/integration/repo_test.go b/tests/integration/repo_test.go index 2d12df700b..d17456e0fa 100644 --- a/tests/integration/repo_test.go +++ b/tests/integration/repo_test.go @@ -1048,6 +1048,42 @@ func TestFileHistoryPager(t *testing.T) { }) } +func TestRepoIssueSorting(t *testing.T) { + defer tests.PrepareTestEnv(t)() + + t.Run("Dropdown content", func(t *testing.T) { + defer tests.PrintCurrentTest(t)() + + req := NewRequest(t, "GET", "/user2/repo1/issues") + resp := MakeRequest(t, req, http.StatusOK) + htmlDoc := NewHTMLParser(t, resp.Body) + + assert.Equal(t, + 9, + htmlDoc.Find(`.list-header-sort .menu a`).Length(), + "Wrong amount of sort options in dropdown") + + menuItemsHTML := htmlDoc.Find(`.list-header-sort .menu`).Text() + locale := translation.NewLocale("en-US") + for _, key := range []string{ + "relevance", + "latest", + "oldest", + "recentupdate", + "leastupdate", + "mostcomment", + "leastcomment", + "nearduedate", + "farduedate", + } { + assert.Contains(t, + menuItemsHTML, + locale.Tr("repo.issues.filter_sort."+key), + "Sort option %s ('%s') not found in dropdown", key, locale.Tr("repo.issues.filter_sort."+key)) + } + }) +} + func TestRepoIssueFilterLinks(t *testing.T) { defer tests.PrepareTestEnv(t)()