You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

156 lines
4.4 KiB

[UI] IssuePage multi repo select (#8741) * Make repository list @ issues/PR page persist Will partially fix #6355 * Enable multiple selections in repo list @ issues/PR page Part of issue #6355 * Add RepoIDs to UserIssueStatsOptions to make "type" count correct when selecting one/multiple repos. * Replace variable "repo" with list "repos[]" and enable multiple selections of repositories from list by including/excluding RepoIDs in list. * * Remove redundant code * Add 'All' button Improves functionality of the page, so that backtracking is not necessary to reset the page * Remove redundant variable Completely replace 'RepoID' with 'RepoIDs' and remove redundant code * Add RepoIDs to label link * Revert part of code to previous version to troubleshoot build failure * Implement old and new pieces of code whilst adhering to multi select * Attempt to join the two versions Last commit passed tests but doesn't work in practice, this works in practice and hopefully passes the tests. * Update tests to desired state * Fix pagination implementation and tests * Pass repoIDs as `repos=[1,2,3...]` instead of several `repos[]=..` * Update tests file to reflect new functionality * Update template with new `repos` format * Implement new solution to show constant "total issues" count for "All" button * Correct behavior when passing zero to array * Comment out test url returning 404 This keeps returning 404 in the test despite working in practice, for the sake of running more tests I am commenting it out * Comment out another test url returning 404 Last attempt, if more tests crash I will uncomment the urls and request assistance. * Reenable tests and test fix * Re-enable tests * Make selecting "In your repositories" reset selection as passing IDs of repos belonging to other profiles causes breakage * Remove unnecessary (with multi-selection enable) code * Drop repo from repo map and total count if permission denied * Remove extra parenthesis * make template work again * find bug! * forgot the '#' at bugfixing * delete unused RepoID * compile regex only one time * make fmt * local variable = capital letter lower * check if repos query pattern is correct * pagination remove last , - make regex work again * use Replace instead of ReplaceAll; del delete * fix test * how did this test binary got in?!? dont forgot the "-p" at git add * ! * dont replace -> cut fisrt & last string Co-Authored-By: zeripath <art27@cantab.net> * jet another regex dont mind as long as it has the same result and is performatn ... Co-Authored-By: zeripath <art27@cantab.net> * dont use nonexisting repo for test * exclude /issues?type=created_by from test * add table to querys use same syntax in each query (table.colum) * add new issue for test * dont make a workaround or something else this need a refactor itself and is out of scope for this PR * fix misspell * CI.redo() * englisch txt update Co-Authored-By: zeripath <art27@cantab.net> * add sugestions * Tweak & Fix * CI.restart()
5 years ago
[UI] IssuePage multi repo select (#8741) * Make repository list @ issues/PR page persist Will partially fix #6355 * Enable multiple selections in repo list @ issues/PR page Part of issue #6355 * Add RepoIDs to UserIssueStatsOptions to make "type" count correct when selecting one/multiple repos. * Replace variable "repo" with list "repos[]" and enable multiple selections of repositories from list by including/excluding RepoIDs in list. * * Remove redundant code * Add 'All' button Improves functionality of the page, so that backtracking is not necessary to reset the page * Remove redundant variable Completely replace 'RepoID' with 'RepoIDs' and remove redundant code * Add RepoIDs to label link * Revert part of code to previous version to troubleshoot build failure * Implement old and new pieces of code whilst adhering to multi select * Attempt to join the two versions Last commit passed tests but doesn't work in practice, this works in practice and hopefully passes the tests. * Update tests to desired state * Fix pagination implementation and tests * Pass repoIDs as `repos=[1,2,3...]` instead of several `repos[]=..` * Update tests file to reflect new functionality * Update template with new `repos` format * Implement new solution to show constant "total issues" count for "All" button * Correct behavior when passing zero to array * Comment out test url returning 404 This keeps returning 404 in the test despite working in practice, for the sake of running more tests I am commenting it out * Comment out another test url returning 404 Last attempt, if more tests crash I will uncomment the urls and request assistance. * Reenable tests and test fix * Re-enable tests * Make selecting "In your repositories" reset selection as passing IDs of repos belonging to other profiles causes breakage * Remove unnecessary (with multi-selection enable) code * Drop repo from repo map and total count if permission denied * Remove extra parenthesis * make template work again * find bug! * forgot the '#' at bugfixing * delete unused RepoID * compile regex only one time * make fmt * local variable = capital letter lower * check if repos query pattern is correct * pagination remove last , - make regex work again * use Replace instead of ReplaceAll; del delete * fix test * how did this test binary got in?!? dont forgot the "-p" at git add * ! * dont replace -> cut fisrt & last string Co-Authored-By: zeripath <art27@cantab.net> * jet another regex dont mind as long as it has the same result and is performatn ... Co-Authored-By: zeripath <art27@cantab.net> * dont use nonexisting repo for test * exclude /issues?type=created_by from test * add table to querys use same syntax in each query (table.colum) * add new issue for test * dont make a workaround or something else this need a refactor itself and is out of scope for this PR * fix misspell * CI.redo() * englisch txt update Co-Authored-By: zeripath <art27@cantab.net> * add sugestions * Tweak & Fix * CI.restart()
5 years ago
  1. // Copyright 2017 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package integrations
  5. import (
  6. "fmt"
  7. "net/http"
  8. "path"
  9. "testing"
  10. "code.gitea.io/gitea/modules/setting"
  11. api "code.gitea.io/gitea/modules/structs"
  12. "code.gitea.io/gitea/modules/test"
  13. "github.com/stretchr/testify/assert"
  14. )
  15. func TestLinksNoLogin(t *testing.T) {
  16. defer prepareTestEnv(t)()
  17. var links = []string{
  18. "/explore/repos",
  19. "/explore/repos?q=test&tab=",
  20. "/explore/users",
  21. "/explore/users?q=test&tab=",
  22. "/explore/organizations",
  23. "/explore/organizations?q=test&tab=",
  24. "/",
  25. "/user/sign_up",
  26. "/user/login",
  27. "/user/forgot_password",
  28. "/api/swagger",
  29. "/api/v1/swagger",
  30. }
  31. for _, link := range links {
  32. req := NewRequest(t, "GET", link)
  33. MakeRequest(t, req, http.StatusOK)
  34. }
  35. }
  36. func TestRedirectsNoLogin(t *testing.T) {
  37. defer prepareTestEnv(t)()
  38. var redirects = map[string]string{
  39. "/user2/repo1/commits/master": "/user2/repo1/commits/branch/master",
  40. "/user2/repo1/src/master": "/user2/repo1/src/branch/master",
  41. "/user2/repo1/src/master/file.txt": "/user2/repo1/src/branch/master/file.txt",
  42. "/user2/repo1/src/master/directory/file.txt": "/user2/repo1/src/branch/master/directory/file.txt",
  43. "/user/avatar/Ghost/-1": "/img/avatar_default.png",
  44. }
  45. for link, redirectLink := range redirects {
  46. req := NewRequest(t, "GET", link)
  47. resp := MakeRequest(t, req, http.StatusFound)
  48. assert.EqualValues(t, path.Join(setting.AppSubURL, redirectLink), test.RedirectURL(resp))
  49. }
  50. }
  51. func testLinksAsUser(userName string, t *testing.T) {
  52. var links = []string{
  53. "/explore/repos",
  54. "/explore/repos?q=test&tab=",
  55. "/explore/users",
  56. "/explore/users?q=test&tab=",
  57. "/explore/organizations",
  58. "/explore/organizations?q=test&tab=",
  59. "/",
  60. "/user/forgot_password",
  61. "/api/swagger",
  62. "/api/v1/swagger",
  63. "/issues",
  64. "/issues?type=your_repositories&repos=[0]&sort=&state=open",
  65. "/issues?type=assigned&repos=[0]&sort=&state=open",
  66. "/issues?type=your_repositories&repos=[0]&sort=&state=closed",
  67. "/issues?type=assigned&repos=[]&sort=&state=closed",
  68. "/issues?type=assigned&sort=&state=open",
  69. "/issues?type=created_by&repos=[1,2]&sort=&state=closed",
  70. "/issues?type=created_by&repos=[1,2]&sort=&state=open",
  71. "/pulls",
  72. "/pulls?type=your_repositories&repos=[2]&sort=&state=open",
  73. "/pulls?type=assigned&repos=[]&sort=&state=open",
  74. "/pulls?type=created_by&repos=[0]&sort=&state=open",
  75. "/pulls?type=your_repositories&repos=[0]&sort=&state=closed",
  76. "/pulls?type=assigned&repos=[0]&sort=&state=closed",
  77. "/pulls?type=created_by&repos=[0]&sort=&state=closed",
  78. "/milestones",
  79. "/milestones?sort=mostcomplete&state=closed",
  80. "/milestones?type=your_repositories&sort=mostcomplete&state=closed",
  81. "/milestones?sort=&repos=[1]&state=closed",
  82. "/milestones?sort=&repos=[1]&state=open",
  83. "/milestones?repos=[0]&sort=mostissues&state=open",
  84. "/notifications",
  85. "/repo/create",
  86. "/repo/migrate",
  87. "/org/create",
  88. "/user2",
  89. "/user2?tab=stars",
  90. "/user2?tab=activity",
  91. "/user/settings",
  92. "/user/settings/account",
  93. "/user/settings/security",
  94. "/user/settings/security/two_factor/enroll",
  95. "/user/settings/keys",
  96. "/user/settings/organization",
  97. "/user/settings/repos",
  98. }
  99. session := loginUser(t, userName)
  100. for _, link := range links {
  101. req := NewRequest(t, "GET", link)
  102. session.MakeRequest(t, req, http.StatusOK)
  103. }
  104. reqAPI := NewRequestf(t, "GET", "/api/v1/users/%s/repos", userName)
  105. respAPI := MakeRequest(t, reqAPI, http.StatusOK)
  106. var apiRepos []*api.Repository
  107. DecodeJSON(t, respAPI, &apiRepos)
  108. var repoLinks = []string{
  109. "",
  110. "/issues",
  111. "/pulls",
  112. "/commits/branch/master",
  113. "/graph",
  114. "/settings",
  115. "/settings/collaboration",
  116. "/settings/branches",
  117. "/settings/hooks",
  118. // FIXME: below links should return 200 but 404 ??
  119. //"/settings/hooks/git",
  120. //"/settings/hooks/git/pre-receive",
  121. //"/settings/hooks/git/update",
  122. //"/settings/hooks/git/post-receive",
  123. "/settings/keys",
  124. "/releases",
  125. "/releases/new",
  126. //"/wiki/_pages",
  127. "/wiki/_new",
  128. }
  129. for _, repo := range apiRepos {
  130. for _, link := range repoLinks {
  131. req := NewRequest(t, "GET", fmt.Sprintf("/%s/%s%s", userName, repo.Name, link))
  132. session.MakeRequest(t, req, http.StatusOK)
  133. }
  134. }
  135. }
  136. func TestLinksLogin(t *testing.T) {
  137. defer prepareTestEnv(t)()
  138. testLinksAsUser("user2", t)
  139. }