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.
This commit is contained in:
parent
af2cc2e0d4
commit
dfc616257d
21 changed files with 1643 additions and 263 deletions
76
test/mv_web/member_live/index_column_manager_test.exs
Normal file
76
test/mv_web/member_live/index_column_manager_test.exs
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
defmodule MvWeb.MemberLive.IndexColumnManagerTest do
|
||||
@moduledoc """
|
||||
§1.6 — The column manager sits in the filter toolbar, offers a per-column
|
||||
visibility toggle plus All and None controls styled as buttons (not links),
|
||||
and applies changes while preserving the existing persistence chain.
|
||||
"""
|
||||
use MvWeb.ConnCase, async: false
|
||||
|
||||
import Phoenix.LiveViewTest
|
||||
|
||||
alias Mv.Helpers.SystemActor
|
||||
|
||||
setup %{conn: conn} do
|
||||
{:ok, _} =
|
||||
Mv.Membership.create_member(
|
||||
%{first_name: "Manager", last_name: "Columns", email: "manager@example.com"},
|
||||
actor: SystemActor.get_system_actor()
|
||||
)
|
||||
|
||||
%{conn: conn_with_oidc_user(conn)}
|
||||
end
|
||||
|
||||
test "column manager trigger sits alongside the filter controls", %{conn: conn} do
|
||||
{:ok, view, _html} = live(conn, ~p"/members")
|
||||
|
||||
# Both the filter panel trigger and the column-manager trigger render in the
|
||||
# same toolbar.
|
||||
assert has_element?(view, ~s(button[aria-label="Filter members"]))
|
||||
assert has_element?(view, "button[aria-controls='field-visibility-menu']")
|
||||
end
|
||||
|
||||
test "All and None are buttons, not links, and per-column toggles are checkboxes", %{conn: conn} do
|
||||
{:ok, view, _html} = live(conn, ~p"/members")
|
||||
|
||||
view |> element("button[aria-controls='field-visibility-menu']") |> render_click()
|
||||
|
||||
# All / None render as buttons with button styling.
|
||||
assert has_element?(view, "button.btn[phx-click='select_all']", "All")
|
||||
assert has_element?(view, "button.btn[phx-click='select_none']", "None")
|
||||
refute has_element?(view, "a[phx-click='select_all']")
|
||||
refute has_element?(view, "a[phx-click='select_none']")
|
||||
|
||||
# Per-column visibility toggles are accessible checkbox menu items.
|
||||
assert has_element?(view, "button[role='menuitemcheckbox'][phx-value-item='name']")
|
||||
end
|
||||
|
||||
test "toggling a column applies and is reflected in the URL (persistence)", %{conn: conn} do
|
||||
{:ok, view, _html} = live(conn, ~p"/members")
|
||||
|
||||
view |> element("button[aria-controls='field-visibility-menu']") |> render_click()
|
||||
view |> element("button[phx-value-item='join_date']") |> render_click()
|
||||
|
||||
# The selection is pushed to the URL fields param so it survives reloads.
|
||||
path = assert_patch(view)
|
||||
assert path =~ "fields="
|
||||
refute has_element?(view, "[data-testid='join_date']")
|
||||
end
|
||||
|
||||
test "a reset button restores the curated default column set", %{conn: conn} do
|
||||
{:ok, view, _html} = live(conn, ~p"/members")
|
||||
|
||||
view |> element("button[aria-controls='field-visibility-menu']") |> render_click()
|
||||
|
||||
# Reset is a button styled like All/None, sitting next to them, with a tooltip.
|
||||
assert has_element?(view, "button.btn[phx-click='reset_fields']")
|
||||
|
||||
# Hide a curated-default column, then reset restores it.
|
||||
view |> element("button[phx-value-item='join_date']") |> render_click()
|
||||
assert_patch(view)
|
||||
refute has_element?(view, "[data-testid='join_date']")
|
||||
|
||||
view |> element("button[phx-click='reset_fields']") |> render_click()
|
||||
assert_patch(view)
|
||||
assert has_element?(view, "[data-testid='join_date']")
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue