test: restore deleted tests with dynamic field visibility support

Adapts icon distribution test for dynamic fields, restores empty cell test
This commit is contained in:
Moritz 2025-12-03 18:13:30 +01:00
parent b9bd5882e7
commit ecc6522571
2 changed files with 45 additions and 0 deletions

View file

@ -149,6 +149,29 @@ defmodule MvWeb.Components.SortHeaderComponentTest do
assert html_neutral =~ "hero-chevron-up-down"
assert has_element?(view, "[data-testid='email'] .opacity-40")
end
test "icon distribution shows exactly one active sort icon", %{conn: conn} do
conn = conn_with_oidc_user(conn)
# Test neutral state - only one field should have active sort icon
{:ok, _view, html_neutral} = live(conn, "/members")
# Count active icons (should be exactly 1 - ascending for default sort field)
up_count = html_neutral |> String.split("hero-chevron-up ") |> length() |> Kernel.-(1)
down_count = html_neutral |> String.split("hero-chevron-down ") |> length() |> Kernel.-(1)
assert up_count == 1, "Expected exactly 1 ascending icon, got #{up_count}"
assert down_count == 0, "Expected 0 descending icons, got #{down_count}"
# Test descending state
{:ok, _view, html_desc} = live(conn, "/members?sort_field=first_name&sort_order=desc")
up_count = html_desc |> String.split("hero-chevron-up ") |> length() |> Kernel.-(1)
down_count = html_desc |> String.split("hero-chevron-down ") |> length() |> Kernel.-(1)
assert up_count == 0, "Expected 0 ascending icons, got #{up_count}"
assert down_count == 1, "Expected exactly 1 descending icon, got #{down_count}"
end
end
describe "accessibility" do

View file

@ -241,4 +241,26 @@ defmodule MvWeb.MemberLive.IndexCustomFieldsDisplayTest do
assert html =~ "alice.private@example.com"
end
test "shows empty cell for members without custom field values", %{
conn: conn,
member2: _member2,
field_show_string: field
} do
conn = conn_with_oidc_user(conn)
{:ok, _view, html} = live(conn, "/members")
# The custom field column should exist
assert html =~ field.name
# Member2 should exist in the table (first_name and last_name are in separate columns)
assert html =~ "Bob"
assert html =~ "Brown"
# The value from member1 should appear (phone number)
assert html =~ "+49123456789"
# Note: Member2 doesn't have this custom field value, so the cell is empty
# The implementation shows "" for missing values, which is the expected behavior
end
end