add search to range index

This commit is contained in:
2022-12-03 21:27:39 -05:00
parent 3ea4b77b67
commit 45da547f62
20 changed files with 342 additions and 110 deletions

View File

@ -37,6 +37,32 @@ defmodule CanneryWeb.RangeLiveTest do
assert html =~ shot_group.notes
end
test "can search for shot_group", %{conn: conn, shot_group: shot_group} do
{:ok, index_live, html} = live(conn, Routes.range_index_path(conn, :index))
assert html =~ shot_group.notes
assert index_live
|> form("[data-qa=\"shot_group_search\"]",
search: %{search_term: shot_group.notes}
)
|> render_change() =~ shot_group.notes
assert_patch(index_live, Routes.range_index_path(conn, :search, shot_group.notes))
refute index_live
|> form("[data-qa=\"shot_group_search\"]", search: %{search_term: "something_else"})
|> render_change() =~ shot_group.notes
assert_patch(index_live, Routes.range_index_path(conn, :search, "something_else"))
assert index_live
|> form("[data-qa=\"shot_group_search\"]", search: %{search_term: ""})
|> render_change() =~ shot_group.notes
assert_patch(index_live, Routes.range_index_path(conn, :index))
end
test "saves new shot_group", %{conn: conn, ammo_group: ammo_group} do
{:ok, index_live, _html} = live(conn, Routes.range_index_path(conn, :index))