summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorShiny Nematoda <snematoda.751k2@aleeas.com>2024-08-06 07:57:25 +0200
committerEarl Warren <earl-warren@noreply.codeberg.org>2024-08-06 07:57:25 +0200
commit06d2e90fa4000e5965b4f7a1dc52b53f8d7cf639 (patch)
treec914cde5520f4936f348c878b9bb04549b08767b /tests
parentMerge pull request '[gitea] week 2024-32 cherry pick (gitea/main -> forgejo)'... (diff)
downloadforgejo-06d2e90fa4000e5965b4f7a1dc52b53f8d7cf639.tar.xz
forgejo-06d2e90fa4000e5965b4f7a1dc52b53f8d7cf639.zip
feat: highlighted code search results (#4749)
closes #4534 <details> <summary>Screenshots</summary> ![](https://codeberg.org/attachments/0ab8a7b0-6485-46dc-a730-c016abb1f287) </details> Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4749 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/explore_code_test.go14
-rw-r--r--tests/integration/repo_search_test.go3
2 files changed, 12 insertions, 5 deletions
diff --git a/tests/integration/explore_code_test.go b/tests/integration/explore_code_test.go
index 1634f70d39..d84b47cf05 100644
--- a/tests/integration/explore_code_test.go
+++ b/tests/integration/explore_code_test.go
@@ -8,6 +8,7 @@ import (
"code.gitea.io/gitea/modules/test"
"code.gitea.io/gitea/tests"
+ "github.com/PuerkitoBio/goquery"
"github.com/stretchr/testify/assert"
)
@@ -15,11 +16,16 @@ func TestExploreCodeSearchIndexer(t *testing.T) {
defer tests.PrepareTestEnv(t)()
defer test.MockVariableValue(&setting.Indexer.RepoIndexerEnabled, true)()
- req := NewRequest(t, "GET", "/explore/code")
+ req := NewRequest(t, "GET", "/explore/code?q=file&fuzzy=true")
resp := MakeRequest(t, req, http.StatusOK)
+ doc := NewHTMLParser(t, resp.Body).Find(".explore")
- doc := NewHTMLParser(t, resp.Body)
- msg := doc.Find(".explore").Find(".ui.container").Find(".ui.message[data-test-tag=grep]")
+ msg := doc.
+ Find(".ui.container").
+ Find(".ui.message[data-test-tag=grep]")
+ assert.EqualValues(t, 0, msg.Length())
- assert.Empty(t, msg.Nodes)
+ doc.Find(".file-body").Each(func(i int, sel *goquery.Selection) {
+ assert.Positive(t, sel.Find(".code-inner").Find(".search-highlight").Length(), 0)
+ })
}
diff --git a/tests/integration/repo_search_test.go b/tests/integration/repo_search_test.go
index a2b4588890..c7a31f473b 100644
--- a/tests/integration/repo_search_test.go
+++ b/tests/integration/repo_search_test.go
@@ -27,7 +27,8 @@ func resultFilenames(t testing.TB, doc *HTMLDoc) []string {
result := make([]string, resultSelections.Length())
resultSelections.Each(func(i int, selection *goquery.Selection) {
- assert.Positive(t, resultSelections.Find("div ol li").Length(), 0)
+ assert.Positive(t, selection.Find("div ol li").Length(), 0)
+ assert.Positive(t, selection.Find(".code-inner").Find(".search-highlight").Length(), 0)
result[i] = selection.
Find(".header").
Find("span.file a.file-link").