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 other members are not listed html = view |> element("form[role=search]") |> render_submit(%{"query" => "Friedrich"}) refute html =~ "Greta" html = view |> element("form[role=search]") |> render_submit(%{"query" => "Greta"}) refute html =~ "Friedrich" end end end