test: add tests for disabled button states in member index

Add tests to verify that copy and open-email buttons are disabled
when no members are selected and enabled after selection.
Also verify that the counter shows the correct count.
This commit is contained in:
Moritz 2025-12-16 14:53:10 +01:00
parent be6ea56860
commit 9f9d888657

View file

@ -410,7 +410,17 @@ defmodule MvWeb.MemberLive.IndexTest do
assert render(view) =~ "1"
end
test "copy button is visible when members are selected", %{
test "copy button is disabled when no members selected", %{conn: conn} do
conn = conn_with_oidc_user(conn)
{:ok, view, _html} = live(conn, "/members")
# Copy button should be disabled (button element)
assert has_element?(view, "#copy-emails-btn[disabled]")
# Open email button should be disabled (link with tabindex and aria-disabled)
assert has_element?(view, "#open-email-btn[tabindex='-1'][aria-disabled='true']")
end
test "copy button is enabled after selection", %{
conn: conn,
member1: member1
} do
@ -420,8 +430,13 @@ defmodule MvWeb.MemberLive.IndexTest do
# Select a member by sending the select_member event directly
render_click(view, "select_member", %{"id" => member1.id})
# Button should now be visible
assert has_element?(view, "#copy-emails-btn")
# Copy button should now be enabled (no disabled attribute)
refute has_element?(view, "#copy-emails-btn[disabled]")
# Open email button should now be enabled (no tabindex=-1 or aria-disabled)
refute has_element?(view, "#open-email-btn[tabindex='-1']")
refute has_element?(view, "#open-email-btn[aria-disabled='true']")
# Counter should show correct count
assert render(view) =~ "1"
end
test "copy button click triggers event and shows flash", %{