From 9701e5e0ff9d895d83dd09a6d32c388047f7d9bf Mon Sep 17 00:00:00 2001 From: Gusted Date: Sun, 17 Nov 2024 02:06:51 +0100 Subject: [PATCH] fix: remember fuzzy for open/close state - Remember if fuzzy was set or not for the open/close/all states. - Use `fuzzy=false` for test, as `fuzzy=true` is the default (this is the opposite of all the other values). - Remove `ctx.Link` prefix for open/close states, this makes them suspectible to the existing tests (the other filter links are also in the format of simply having `?xx=xx&yy=yy`). - Fix typo in test name. --- routers/web/repo/issue.go | 14 +++++++------- tests/integration/repo_test.go | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go index 6a485b0066..e67980a9a9 100644 --- a/routers/web/repo/issue.go +++ b/routers/web/repo/issue.go @@ -457,16 +457,16 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption opt ctx.Data["OpenCount"] = issueStats.OpenCount ctx.Data["ClosedCount"] = issueStats.ClosedCount ctx.Data["AllCount"] = issueStats.AllCount - linkStr := "%s?q=%s&type=%s&sort=%s&state=%s&labels=%s&milestone=%d&project=%d&assignee=%d&poster=%d&archived=%t" - ctx.Data["AllStatesLink"] = fmt.Sprintf(linkStr, ctx.Link, + linkStr := "?q=%s&type=%s&sort=%s&state=%s&labels=%s&milestone=%d&project=%d&assignee=%d&poster=%d&fuzzy=%t&archived=%t" + ctx.Data["AllStatesLink"] = fmt.Sprintf(linkStr, url.QueryEscape(keyword), url.QueryEscape(viewType), url.QueryEscape(sortType), "all", url.QueryEscape(selectLabels), - milestoneID, projectID, assigneeID, posterID, archived) - ctx.Data["OpenLink"] = fmt.Sprintf(linkStr, ctx.Link, + milestoneID, projectID, assigneeID, posterID, isFuzzy, archived) + ctx.Data["OpenLink"] = fmt.Sprintf(linkStr, url.QueryEscape(keyword), url.QueryEscape(viewType), url.QueryEscape(sortType), "open", url.QueryEscape(selectLabels), - milestoneID, projectID, assigneeID, posterID, archived) - ctx.Data["ClosedLink"] = fmt.Sprintf(linkStr, ctx.Link, + milestoneID, projectID, assigneeID, posterID, isFuzzy, archived) + ctx.Data["ClosedLink"] = fmt.Sprintf(linkStr, url.QueryEscape(keyword), url.QueryEscape(viewType), url.QueryEscape(sortType), "closed", url.QueryEscape(selectLabels), - milestoneID, projectID, assigneeID, posterID, archived) + milestoneID, projectID, assigneeID, posterID, isFuzzy, archived) ctx.Data["SelLabelIDs"] = labelIDs ctx.Data["SelectLabels"] = selectLabels ctx.Data["ViewType"] = viewType diff --git a/tests/integration/repo_test.go b/tests/integration/repo_test.go index 85a5002cec..a424863346 100644 --- a/tests/integration/repo_test.go +++ b/tests/integration/repo_test.go @@ -1140,7 +1140,7 @@ func TestRepoIssueFilterLinks(t *testing.T) { t.Run("Fuzzy", func(t *testing.T) { defer tests.PrintCurrentTest(t)() - req := NewRequest(t, "GET", "/user2/repo1/issues?fuzzy=true") + req := NewRequest(t, "GET", "/user2/repo1/issues?fuzzy=false") resp := MakeRequest(t, req, http.StatusOK) htmlDoc := NewHTMLParser(t, resp.Body) @@ -1157,7 +1157,7 @@ func TestRepoIssueFilterLinks(t *testing.T) { assert.Contains(t, href, "&project=") assert.Contains(t, href, "&assignee=") assert.Contains(t, href, "&poster=") - assert.Contains(t, href, "&fuzzy=true") + assert.Contains(t, href, "&fuzzy=false") }) assert.True(t, called) }) @@ -1237,7 +1237,7 @@ func TestRepoIssueFilterLinks(t *testing.T) { assert.True(t, called) }) - t.Run("Miilestone", func(t *testing.T) { + t.Run("Milestone", func(t *testing.T) { defer tests.PrintCurrentTest(t)() req := NewRequest(t, "GET", "/user2/repo1/issues?milestone=1")