feat(member-live): sort the composite Member column by first or last name

This commit is contained in:
Simon 2026-07-16 09:39:07 +02:00
parent ca2aaa069c
commit f7005f395f
11 changed files with 443 additions and 34 deletions

View file

@ -221,11 +221,11 @@ defmodule MvWeb.MemberLive.IndexTest do
{:ok, view, _html} =
live(
conn,
"/members?fields=first_name,email,street,house_number,postal_code,city,country,join_date"
"/members?fields=last_name,first_name,email,street,house_number,postal_code,city,country,join_date"
)
# default ascending sorting with first name
assert has_element?(view, "[data-testid='first_name'][aria-label='ascending']")
# default ascending sorting on the default sort field (last name)
assert has_element?(view, "[data-testid='last_name'][aria-label='ascending']")
sortable_fields = [
:email,
@ -295,10 +295,10 @@ defmodule MvWeb.MemberLive.IndexTest do
conn = conn |> conn_with_oidc_user() |> non_compact()
{:ok, view, _html} =
live(conn, "/members?fields=first_name&query=&sort_field=invalid_field&sort_order=asc")
live(conn, "/members?fields=last_name&query=&sort_field=invalid_field&sort_order=asc")
# Should not crash and should show default first name order
assert has_element?(view, "[data-testid='first_name'][aria-label='ascending']")
# Should not crash and should fall back to the default sort (last name)
assert has_element?(view, "[data-testid='last_name'][aria-label='ascending']")
end
test "handle_params preserves search query with sort params", %{conn: conn} do