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.

157 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. // TODO: follow this page and test every link
  31. "/vendor/librejs.html",
  32. }
  33. for _, link := range links {
  34. req := NewRequest(t, "GET", link)
  35. MakeRequest(t, req, http.StatusOK)
  36. }
  37. }
  38. func TestRedirectsNoLogin(t *testing.T) {
  39. defer prepareTestEnv(t)()
  40. var redirects = map[string]string{
  41. "/user2/repo1/commits/master": "/user2/repo1/commits/branch/master",
  42. "/user2/repo1/src/master": "/user2/repo1/src/branch/master",
  43. "/user2/repo1/src/master/file.txt": "/user2/repo1/src/branch/master/file.txt",
  44. "/user2/repo1/src/master/directory/file.txt": "/user2/repo1/src/branch/master/directory/file.txt",
  45. }
  46. for link, redirectLink := range redirects {
  47. req := NewRequest(t, "GET", link)
  48. resp := MakeRequest(t, req, http.StatusFound)
  49. assert.EqualValues(t, path.Join(setting.AppSubURL, redirectLink), test.RedirectURL(resp))
  50. }
  51. }
  52. func testLinksAsUser(userName string, t *testing.T) {
  53. var links = []string{
  54. "/explore/repos",
  55. "/explore/repos?q=test&tab=",
  56. "/explore/users",
  57. "/explore/users?q=test&tab=",
  58. "/explore/organizations",
  59. "/explore/organizations?q=test&tab=",
  60. "/",
  61. "/user/forgot_password",
  62. "/api/swagger",
  63. "/api/v1/swagger",
  64. "/issues",
  65. "/issues?type=your_repositories&repos=[0]&sort=&state=open",
  66. "/issues?type=assigned&repos=[0]&sort=&state=open",
  67. "/issues?type=your_repositories&repos=[0]&sort=&state=closed",
  68. "/issues?type=assigned&repos=[]&sort=&state=closed",
  69. "/issues?type=assigned&sort=&state=open",
  70. "/issues?type=created_by&repos=[1,2]&sort=&state=closed",
  71. "/issues?type=created_by&repos=[1,2]&sort=&state=open",
  72. "/pulls",
  73. "/pulls?type=your_repositories&repos=[2]&sort=&state=open",
  74. "/pulls?type=assigned&repos=[]&sort=&state=open",
  75. "/pulls?type=created_by&repos=[0]&sort=&state=open",
  76. "/pulls?type=your_repositories&repos=[0]&sort=&state=closed",
  77. "/pulls?type=assigned&repos=[0]&sort=&state=closed",
  78. "/pulls?type=created_by&repos=[0]&sort=&state=closed",
  79. "/milestones",
  80. "/milestones?sort=mostcomplete&state=closed",
  81. "/milestones?type=your_repositories&sort=mostcomplete&state=closed",
  82. "/milestones?sort=&repos=[1]&state=closed",
  83. "/milestones?sort=&repos=[1]&state=open",
  84. "/milestones?repos=[0]&sort=mostissues&state=open",
  85. "/notifications",
  86. "/repo/create",
  87. "/repo/migrate",
  88. "/org/create",
  89. "/user2",
  90. "/user2?tab=stars",
  91. "/user2?tab=activity",
  92. "/user/settings",
  93. "/user/settings/account",
  94. "/user/settings/security",
  95. "/user/settings/security/two_factor/enroll",
  96. "/user/settings/keys",
  97. "/user/settings/organization",
  98. "/user/settings/repos",
  99. }
  100. session := loginUser(t, userName)
  101. for _, link := range links {
  102. req := NewRequest(t, "GET", link)
  103. session.MakeRequest(t, req, http.StatusOK)
  104. }
  105. reqAPI := NewRequestf(t, "GET", "/api/v1/users/%s/repos", userName)
  106. respAPI := MakeRequest(t, reqAPI, http.StatusOK)
  107. var apiRepos []*api.Repository
  108. DecodeJSON(t, respAPI, &apiRepos)
  109. var repoLinks = []string{
  110. "",
  111. "/issues",
  112. "/pulls",
  113. "/commits/branch/master",
  114. "/graph",
  115. "/settings",
  116. "/settings/collaboration",
  117. "/settings/branches",
  118. "/settings/hooks",
  119. // FIXME: below links should return 200 but 404 ??
  120. //"/settings/hooks/git",
  121. //"/settings/hooks/git/pre-receive",
  122. //"/settings/hooks/git/update",
  123. //"/settings/hooks/git/post-receive",
  124. "/settings/keys",
  125. "/releases",
  126. "/releases/new",
  127. //"/wiki/_pages",
  128. "/wiki/_new",
  129. }
  130. for _, repo := range apiRepos {
  131. for _, link := range repoLinks {
  132. req := NewRequest(t, "GET", fmt.Sprintf("/%s/%s%s", userName, repo.Name, link))
  133. session.MakeRequest(t, req, http.StatusOK)
  134. }
  135. }
  136. }
  137. func TestLinksLogin(t *testing.T) {
  138. defer prepareTestEnv(t)()
  139. testLinksAsUser("user2", t)
  140. }