1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-11-21 08:31:27 -05:00

Merge pull request 'fix: Add recentupdated as recognized sort option' (#5613) from gusted/forgejo-add-recentupdated-case into forgejo

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/5613
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
Reviewed-by: Otto <otto@codeberg.org>
This commit is contained in:
Gusted 2024-10-20 10:57:20 +00:00
commit 215700fc83
6 changed files with 44 additions and 7 deletions

View file

@ -91,6 +91,8 @@
size: 0
is_fsck_enabled: true
close_issues_via_commit_in_any_branch: false
created_unix: 1700000001
updated_unix: 1700000001
-
id: 4
@ -152,6 +154,8 @@
size: 0
is_fsck_enabled: true
close_issues_via_commit_in_any_branch: false
created_unix: 1700000002
updated_unix: 1700000002
-
id: 6
@ -182,6 +186,8 @@
size: 0
is_fsck_enabled: true
close_issues_via_commit_in_any_branch: false
created_unix: 1710000001
updated_unix: 1710000001
-
id: 7
@ -212,6 +218,8 @@
size: 0
is_fsck_enabled: true
close_issues_via_commit_in_any_branch: false
created_unix: 1710000003
updated_unix: 1710000003
-
id: 8
@ -242,6 +250,8 @@
size: 0
is_fsck_enabled: true
close_issues_via_commit_in_any_branch: false
created_unix: 1710000002
updated_unix: 1710000002
-
id: 9
@ -968,6 +978,8 @@
size: 0
is_fsck_enabled: true
close_issues_via_commit_in_any_branch: false
created_unix: 1700000003
updated_unix: 1700000003
-
id: 33

View file

@ -299,8 +299,8 @@ func TestAccessibleReposEnv_RepoIDs(t *testing.T) {
require.NoError(t, err)
assert.Equal(t, expectedRepoIDs, repoIDs)
}
testSuccess(2, []int64{3, 5, 32})
testSuccess(4, []int64{3, 32})
testSuccess(2, []int64{32, 5, 3})
testSuccess(4, []int64{32, 3})
}
func TestAccessibleReposEnv_Repos(t *testing.T) {
@ -318,8 +318,8 @@ func TestAccessibleReposEnv_Repos(t *testing.T) {
}
assert.Equal(t, expectedRepos, repos)
}
testSuccess(2, []int64{3, 5, 32})
testSuccess(4, []int64{3, 32})
testSuccess(2, []int64{32, 5, 3})
testSuccess(4, []int64{32, 3})
}
func TestAccessibleReposEnv_MirrorRepos(t *testing.T) {

View file

@ -36,6 +36,7 @@ var OrderByMap = map[string]map[string]db.SearchOrderBy{
var OrderByFlatMap = map[string]db.SearchOrderBy{
"newest": OrderByMap["desc"]["created"],
"oldest": OrderByMap["asc"]["created"],
"recentupdate": OrderByMap["desc"]["updated"],
"leastupdate": OrderByMap["asc"]["updated"],
"reversealphabetically": OrderByMap["desc"]["alpha"],
"alphabetically": OrderByMap["asc"]["alpha"],

View file

@ -16,11 +16,10 @@ func TestRepoLastUpdatedTime(t *testing.T) {
user := "user2"
session := loginUser(t, user)
req := NewRequest(t, "GET", path.Join("explore", "repos"))
req := NewRequest(t, "GET", "/explore/repos?q=repo1")
resp := session.MakeRequest(t, req, http.StatusOK)
doc := NewHTMLParser(t, resp.Body)
node := doc.doc.Find(".flex-item-body").First()
{
buf := ""
findTextNonNested(t, node, &buf)

View file

@ -28,6 +28,7 @@ func TestOrgRepos(t *testing.T) {
users = []string{"user1", "user2"}
cases = map[string][]string{
"alphabetically": {"repo21", "repo3", "repo5"},
"recentupdate": {"repo21", "repo5", "repo3"},
"reversealphabetically": {"repo5", "repo3", "repo21"},
}
)

View file

@ -812,3 +812,27 @@ func TestUserTOTPEnrolled(t *testing.T) {
assert.True(t, called)
})
}
func TestUserRepos(t *testing.T) {
defer tests.PrepareTestEnv(t)()
cases := map[string][]string{
"alphabetically": {"repo6", "repo7", "repo8"},
"recentupdate": {"repo7", "repo8", "repo6"},
"reversealphabetically": {"repo8", "repo7", "repo6"},
}
session := loginUser(t, "user10")
for sortBy, repos := range cases {
req := NewRequest(t, "GET", "/user10?sort="+sortBy)
resp := session.MakeRequest(t, req, http.StatusOK)
htmlDoc := NewHTMLParser(t, resp.Body)
sel := htmlDoc.doc.Find("a.name")
assert.Len(t, repos, len(sel.Nodes))
for i := 0; i < len(repos); i++ {
assert.EqualValues(t, repos[i], strings.TrimSpace(sel.Eq(i).Text()))
}
}
}