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

This commit is contained in:
2025-06-01 20:47:34 +03:00
parent 5c31715211
commit 3bc4616c5d
2 changed files with 46 additions and 1 deletions
@@ -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