Update to allow search book by an empty bid.
continuous-integration/drone/push Build is passing Details

dev
KKlochko 4 weeks ago
parent 5c31715211
commit 3bc4616c5d

@ -204,7 +204,7 @@ defmodule DecentralisedBookIndex.Metadata.Book do
description "Return a list of Books, optionally filtering by BookId."
argument :type, :string, allow_nil?: false
argument :bid, :string, allow_nil?: false
argument :bid, :string, allow_nil?: true
filter expr(exists(bids, type == ^arg(:type) and contains(bid, ^arg(:bid))))

@ -0,0 +1,45 @@
defmodule DecentralisedBookIndexWeb.Live.BookLive.IndexTest do
use DecentralisedBookIndexWeb.LiveCase, async: true
describe "Search by bid" do
setup do
%{
modes: [
"isbn",
"isbn13",
"asin"
],
books:
for _ <- 1..5 do
generate(book())
end
}
end
test "can search by an empty bid", %{conn: conn, modes: modes} do
for mode <- modes do
{:ok, _view, html} =
conn
|> live("/books?search_mode=#{mode}")
assert html =~ "Listing Books"
assert html =~ "No Books"
end
end
test "can search by a bid", %{conn: conn, modes: modes, books: books} do
[book | others] = books
for %{type: type, bid: bid} <- book.bids do
{:ok, view, html} =
conn
|> live("/books?query=#{bid}&search_mode=#{type}")
html = render(view)
assert html =~ book.title
refute html =~ "No Books"
end
end
end
end
Loading…
Cancel
Save