defmodule MvWeb.Components.FieldVisibilityDropdownComponentTest do
  use MvWeb.ConnCase, async: true
  import Phoenix.LiveViewTest

  describe "field visibility dropdown in member view" do
    test "renders and toggles visibility", %{conn: conn} do
      conn = conn_with_oidc_user(conn)
      {:ok, view, _html} = live(conn, ~p"/members")

      # Renders Dropdown
      assert has_element?(view, "[data-testid='dropdown-menu']")

      # Opens Dropdown
      view |> element("[data-testid='dropdown-button']") |> render_click()
      assert has_element?(view, "#field-visibility-menu")
      assert has_element?(view, "button[phx-click='select_item'][phx-value-item='email']")
      assert has_element?(view, "button[phx-click='select_all']")
      assert has_element?(view, "button[phx-click='select_none']")
    end
  end
end
