Skip to content

Commit 82e4ccc

Browse files
snematodabadhezi
authored andcommitted
port(gitea): Retain issue/pull sort type (go-gitea#8067)
port of [gitea#34559](go-gitea#34559) initial work attributed to [badhezi](https://github.com/badhezi) Co-authored-by: badhezi <zlilaharon@gmail.com> Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8067 Reviewed-by: Beowulf <beowulf@beocode.eu> Reviewed-by: Gusted <gusted@noreply.codeberg.org> Co-authored-by: Shiny Nematoda <snematoda.751k2@aleeas.com> Co-committed-by: Shiny Nematoda <snematoda.751k2@aleeas.com>
1 parent 8f2c08b commit 82e4ccc

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

templates/repo/issue/search.tmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<input type="hidden" name="project" value="{{$.ProjectID}}">
99
<input type="hidden" name="assignee" value="{{$.AssigneeID}}">
1010
<input type="hidden" name="poster" value="{{$.PosterID}}">
11+
<input type="hidden" name="sort" value="{{$.SortType}}">
1112
{{end}}
1213
{{if .PageIsPullList}}
1314
{{template "shared/search/combo" dict "Value" .Keyword "Placeholder" (ctx.Locale.Tr "search.pull_kind") "Tooltip" (ctx.Locale.Tr "explore.go_to")}}

tests/integration/issue_test.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,6 +1438,47 @@ func TestIssueCount(t *testing.T) {
14381438
assert.Contains(t, allCount, "2\u00a0All")
14391439
}
14401440

1441+
func TestIssueDefaultValues(t *testing.T) {
1442+
defer tests.PrepareTestEnv(t)()
1443+
1444+
links := []string{"/user2/repo1/issues", "/user2/repo1/pulls"}
1445+
values := []url.Values{
1446+
{
1447+
"type": {"created_by"},
1448+
},
1449+
{
1450+
"poster": {"1"},
1451+
},
1452+
{
1453+
"sort": {"latest"},
1454+
},
1455+
{
1456+
"type": {"all"},
1457+
"sort": {"latest"},
1458+
"poster": {"1"},
1459+
},
1460+
{
1461+
"type": {"assigned"},
1462+
"sort": {"oldest"},
1463+
"poster": {"1"},
1464+
},
1465+
}
1466+
1467+
for _, link := range links {
1468+
t.Run(link[13:], func(t *testing.T) {
1469+
for _, value := range values {
1470+
req := NewRequestf(t, "GET", "%s?%s", link, value.Encode())
1471+
resp := MakeRequest(t, req, http.StatusOK)
1472+
1473+
htmlDoc := NewHTMLParser(t, resp.Body)
1474+
for name := range value {
1475+
assert.Equal(t, value.Get(name), htmlDoc.GetInputValueByName(name))
1476+
}
1477+
}
1478+
})
1479+
}
1480+
}
1481+
14411482
func TestIssuePostersSearch(t *testing.T) {
14421483
defer tests.PrepareTestEnv(t)()
14431484

0 commit comments

Comments
 (0)