diff options
author | Shiny Nematoda <snematoda.751k2@aleeas.com> | 2024-12-22 13:24:29 +0100 |
---|---|---|
committer | 0ko <0ko@noreply.codeberg.org> | 2024-12-22 13:24:29 +0100 |
commit | ee214cb886b81acb7c9cb277809d19aae42f3c7f (patch) | |
tree | c2d5edb0481030712db3332f6f93535d5ef8deb2 /tests | |
parent | Merge pull request 'Don't notify when a user self-request as reviewer' (#6287... (diff) | |
download | forgejo-ee214cb886b81acb7c9cb277809d19aae42f3c7f.tar.xz forgejo-ee214cb886b81acb7c9cb277809d19aae42f3c7f.zip |
feat: filepath filter for code search (#6143)
Added support for searching content in a specific directory or file.
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6143
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Reviewed-by: 0ko <0ko@noreply.codeberg.org>
Co-authored-by: Shiny Nematoda <snematoda.751k2@aleeas.com>
Co-committed-by: Shiny Nematoda <snematoda.751k2@aleeas.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/integration/repo_test.go | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/tests/integration/repo_test.go b/tests/integration/repo_test.go index f165cae539..90fc19c193 100644 --- a/tests/integration/repo_test.go +++ b/tests/integration/repo_test.go @@ -1009,16 +1009,29 @@ func TestRepoCodeSearchForm(t *testing.T) { resp := MakeRequest(t, req, http.StatusOK) htmlDoc := NewHTMLParser(t, resp.Body) - action, exists := htmlDoc.doc.Find("form[data-test-tag=codesearch]").Attr("action") - assert.True(t, exists) + formEl := htmlDoc.doc.Find("form[data-test-tag=codesearch]") + action, exists := formEl.Attr("action") + assert.True(t, exists) branchSubURL := "/branch/master" - if indexer { assert.NotContains(t, action, branchSubURL) } else { assert.Contains(t, action, branchSubURL) } + + filepath, exists := formEl.Find("input[name=path]").Attr("value") + assert.True(t, exists) + assert.Empty(t, filepath) + + req = NewRequest(t, "GET", "/user2/glob/src/branch/master/x/y") + resp = MakeRequest(t, req, http.StatusOK) + + filepath, exists = NewHTMLParser(t, resp.Body).doc. + Find("form[data-test-tag=codesearch] input[name=path]"). + Attr("value") + assert.True(t, exists) + assert.Equal(t, "x/y", filepath) } t.Run("indexer disabled", func(t *testing.T) { |