mitgliederverwaltung/test/mv_web/member_live/index_default_columns_test.exs
Simon dfc616257d feat(member): let members tailor overview density and visible columns
The View dropdown drives row density and whether the Member and Address
fields render as composite cells or split into their underlying columns;
the column manager toggles visibility and resets to the curated default.
All choices persist per browser through the URL/session/cookie/global
chain, so a saved layout survives reloads without a per-account store.
2026-07-06 10:45:53 +02:00

63 lines
2.3 KiB
Elixir

defmodule MvWeb.MemberLive.IndexDefaultColumnsTest do
@moduledoc """
§1.2 — With no persisted column selection, exactly the curated default columns
are visible: selection checkbox, Name (composite, no in-cell email line),
E-Mail (its own column while the compact Member field keeps the email line off),
Address (composite), fee type, fee status, groups, join date.
"""
use MvWeb.ConnCase, async: false
import Phoenix.LiveViewTest
alias Mv.Helpers.SystemActor
setup %{conn: conn} do
{:ok, _} =
Mv.Membership.create_member(
%{
first_name: "Col",
last_name: "Default",
email: "col@example.com",
street: "Musterweg",
house_number: "1",
postal_code: "10115",
city: "Berlin"
},
actor: SystemActor.get_system_actor()
)
%{conn: conn_with_oidc_user(conn)}
end
test "curated columns are visible by default", %{conn: conn} do
{:ok, view, _html} = live(conn, ~p"/members")
# Composite Name + Address cells.
assert has_element?(view, "[data-testid='member-name']")
assert has_element?(view, "[data-testid='member-address']")
# E-Mail is its own column by default (compact Member field, email line off).
assert has_element?(view, "[data-testid='email']")
# Fee type, fee status, groups, join date headers.
assert has_element?(view, "[data-testid='membership_fee_type']")
assert has_element?(view, "[data-testid='join_date']")
assert has_element?(view, "th", "Membership Fee Status")
assert has_element?(view, "[data-testid='groups']")
end
test "the individual name/address sub-fields are hidden by default", %{conn: conn} do
{:ok, view, _html} = live(conn, ~p"/members")
# The composite Name/Address cells replace their constituents by default.
# E-Mail is excluded here: it is a default-visible column of its own.
for field <- ~w(first_name last_name city street house_number postal_code country) do
refute has_element?(view, "[data-testid='#{field}']")
end
end
test "an explicit field selection still overrides the curated default", %{conn: conn} do
{:ok, view, _html} = live(conn, ~p"/members?fields=email")
assert has_element?(view, "[data-testid='email']")
refute has_element?(view, "[data-testid='member-name']")
end
end