test: updated tests for member and search bar

This commit is contained in:
carla 2025-09-17 14:36:50 +02:00
parent 78588cbad9
commit 53f6b62289
2 changed files with 47 additions and 0 deletions

View file

@ -0,0 +1,34 @@
defmodule MvWeb.Components.SearchBarComponentTest do
use MvWeb.ConnCase, async: true
import Phoenix.LiveViewTest
describe "SearchBarComponent" do
test "renders with placeholder", %{conn: conn} do
conn = conn_with_oidc_user(conn)
{:ok, view, _html} = live(conn, "/members")
assert has_element?(view, "input[placeholder='Search...']")
end
test "updates query when user types", %{conn: conn} do
conn = conn_with_oidc_user(conn)
{:ok, view, _html} = live(conn, "/members")
# simulate search input and check that correct user is listed
html =
view
|> element("form[role=search]")
|> render_change(%{"query" => "Friedrich"})
assert html =~ "Friedrich"
# simulate search input and check that not matching user is not shown
html =
view
|> element("form[role=search]")
|> render_change(%{"query" => "Greta"})
refute html =~ "Friedrich"
end
end
end