Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

explore_user_test.go 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright 2024 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package integration
  4. import (
  5. "net/http"
  6. "testing"
  7. "code.gitea.io/gitea/tests"
  8. "github.com/stretchr/testify/assert"
  9. )
  10. func TestExploreUser(t *testing.T) {
  11. defer tests.PrepareTestEnv(t)()
  12. cases := []struct{ sortOrder, expected string }{
  13. {"", "/explore/users?sort=newest&q="},
  14. {"newest", "/explore/users?sort=newest&q="},
  15. {"oldest", "/explore/users?sort=oldest&q="},
  16. {"alphabetically", "/explore/users?sort=alphabetically&q="},
  17. {"reversealphabetically", "/explore/users?sort=reversealphabetically&q="},
  18. }
  19. for _, c := range cases {
  20. req := NewRequest(t, "GET", "/explore/users?sort="+c.sortOrder)
  21. resp := MakeRequest(t, req, http.StatusOK)
  22. h := NewHTMLParser(t, resp.Body)
  23. href, _ := h.Find(`.ui.dropdown .menu a.active.item[href^="/explore/users"]`).Attr("href")
  24. assert.Equal(t, c.expected, href)
  25. }
  26. // these sort orders shouldn't be supported, to avoid leaking user activity
  27. cases404 := []string{
  28. "/explore/users?sort=lastlogin",
  29. "/explore/users?sort=reverselastlogin",
  30. "/explore/users?sort=leastupdate",
  31. "/explore/users?sort=reverseleastupdate",
  32. }
  33. for _, c := range cases404 {
  34. req := NewRequest(t, "GET", c)
  35. req.Header.Get("Accept: text/html")
  36. MakeRequest(t, req, http.StatusNotFound)
  37. }
  38. }