Merge pull request #1112 from bookwyrm-social/search-null-state

Fixes search null state view
This commit is contained in:
Mouse Reeve 2021-05-20 16:49:46 -07:00 committed by GitHub
commit 9933b888f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View file

@ -53,6 +53,17 @@ class Views(TestCase):
self.assertEqual(data[0]["title"], "Test Book")
self.assertEqual(data[0]["key"], "https://%s/book/%d" % (DOMAIN, self.book.id))
def test_search_no_query(self):
"""just the search page"""
view = views.Search.as_view()
# we need a connector for this, sorry
request = self.factory.get("")
with patch("bookwyrm.views.search.is_api_request") as is_api:
is_api.return_value = False
response = view(request)
self.assertIsInstance(response, TemplateResponse)
response.render()
def test_search_books(self):
"""searches remote connectors"""
view = views.Search.as_view()

View file

@ -36,7 +36,7 @@ class Search(View):
)
return JsonResponse([r.json() for r in book_results], safe=False)
if not search_type:
if query and not search_type:
search_type = "user" if "@" in query else "book"
endpoints = {