Commit cf204d6198
Verified · cmc
Layout: unified · split
e2e/searchweb_test.go +11
| @@ -56,6 +56,17 @@ func TestGlobalSearchAndNotificationsWeb(t *testing.T) { | ||
| 56 | 56 | t.Fatal("short query not refused") |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | // A query that matches nothing says what to do next instead of | |
| 60 | // repeating the count line's "no matches" under it (#248). | |
| 61 | _, body = inst.get(t, "/search?q=zzznothing&kind=issue") | |
| 62 | if !strings.Contains(body, "0 results") || !strings.Contains(body, "Try fewer words") || | |
| 63 | !strings.Contains(body, "search everything") { | |
| 64 | t.Fatalf("empty search lacks its recovery line:\n%s", body) | |
| 65 | } | |
| 66 | if strings.Contains(body, "no matches") { | |
| 67 | t.Fatalf("empty search repeats the count line:\n%s", body) | |
| 68 | } | |
| 69 | ||
| 59 | 70 | // Alice sees her private repository and its issue in the same page. |
| 60 | 71 | browser := inst.login(t, aliceKey) |
| 61 | 72 | status, body = browserGet(t, browser, inst.base()+"/search?q=widget") |
internal/web/templates/globalsearch.html +3 −1
| @@ -40,7 +40,9 @@ | ||
| 40 | 40 | </li> |
| 41 | 41 | {{end}} |
| 42 | 42 | </ul> |
| 43 | {{else}}<p class="empty-note">no matches for “{{.Query}}”</p>{{end}} | |
| 43 | {{/* The count line above already says nothing matched, so this one | |
| 44 | carries the way out instead of repeating it. */}} | |
| 45 | {{else}}<p class="empty-note">Try fewer words{{if .Kind}}, <a href="?q={{.Query}}">search everything</a>,{{end}} or <a href="/explore">browse the repositories</a>.</p>{{end}} | |
| 44 | 46 | {{else}} |
| 45 | 47 | <p class="empty-note">Repository names, descriptions and topics, and the title and body of every issue and merge request you can read. File contents are searched per repository, from a repository's Code tab.</p> |
| 46 | 48 | {{end}} |