test(member-live): update component tests for the new defaults and composite sort
This commit is contained in:
parent
95c25142f0
commit
f847ae10af
2 changed files with 13 additions and 6 deletions
|
|
@ -4,7 +4,13 @@ defmodule MvWeb.Components.FieldVisibilityDropdownComponentTest do
|
||||||
|
|
||||||
describe "field visibility dropdown in member view" do
|
describe "field visibility dropdown in member view" do
|
||||||
test "renders and toggles visibility", %{conn: conn} do
|
test "renders and toggles visibility", %{conn: conn} do
|
||||||
conn = conn_with_oidc_user(conn)
|
# Email is folded into the Member cell by default; unfold it so it appears
|
||||||
|
# as its own togglable column in the dropdown.
|
||||||
|
conn =
|
||||||
|
conn
|
||||||
|
|> conn_with_oidc_user()
|
||||||
|
|> Plug.Conn.put_session("member_view_settings", ~s({"member_include_email":false}))
|
||||||
|
|
||||||
{:ok, view, _html} = live(conn, ~p"/members")
|
{:ok, view, _html} = live(conn, ~p"/members")
|
||||||
|
|
||||||
# Renders Dropdown
|
# Renders Dropdown
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ defmodule MvWeb.Components.SortHeaderComponentTest do
|
||||||
# The individual name/address constituents are only *offered* when the compact
|
# The individual name/address constituents are only *offered* when the compact
|
||||||
# Member / Address view settings are off, so the session opts them out of the
|
# Member / Address view settings are off, so the session opts them out of the
|
||||||
# composite columns before selecting the fields via ?fields=.
|
# composite columns before selecting the fields via ?fields=.
|
||||||
@cols "first_name,email,street,house_number,postal_code,city,country,join_date"
|
@cols "first_name,last_name,email,street,house_number,postal_code,city,country,join_date"
|
||||||
|
|
||||||
# Disables the compact Member/Address composites so first_name/last_name/email
|
# Disables the compact Member/Address composites so first_name/last_name/email
|
||||||
# and street/house_number/postal_code/city are offered as individual sortable
|
# and street/house_number/postal_code/city are offered as individual sortable
|
||||||
|
|
@ -135,9 +135,10 @@ defmodule MvWeb.Components.SortHeaderComponentTest do
|
||||||
conn = conn |> conn_with_oidc_user() |> non_compact()
|
conn = conn |> conn_with_oidc_user() |> non_compact()
|
||||||
{:ok, view, _html} = live(conn, "/members?fields=#{@cols}")
|
{:ok, view, _html} = live(conn, "/members?fields=#{@cols}")
|
||||||
|
|
||||||
# Start: all fields neutral except first name as default
|
# Start: all fields neutral except the default sort field (last name)
|
||||||
assert has_element?(view, "[data-testid='city'] .opacity-40")
|
assert has_element?(view, "[data-testid='city'] .opacity-40")
|
||||||
refute has_element?(view, "[data-testid='first_name'] .opacity-40")
|
refute has_element?(view, "[data-testid='last_name'] .opacity-40")
|
||||||
|
assert has_element?(view, "[data-testid='first_name'] .opacity-40")
|
||||||
assert has_element?(view, "[data-testid='email'] .opacity-40")
|
assert has_element?(view, "[data-testid='email'] .opacity-40")
|
||||||
|
|
||||||
# Click city - should become active
|
# Click city - should become active
|
||||||
|
|
@ -304,9 +305,9 @@ defmodule MvWeb.Components.SortHeaderComponentTest do
|
||||||
{:ok, view, html} =
|
{:ok, view, html} =
|
||||||
live(conn, "/members?fields=#{@cols}&sort_field=invalid_field&sort_order=asc")
|
live(conn, "/members?fields=#{@cols}&sort_field=invalid_field&sort_order=asc")
|
||||||
|
|
||||||
# Should not crash and should default sorting for first name
|
# Should not crash and should fall back to the default sort (last name)
|
||||||
assert html =~ "hero-chevron-up-down"
|
assert html =~ "hero-chevron-up-down"
|
||||||
refute has_element?(view, "[data-testid='first_name'] .opacity-40")
|
refute has_element?(view, "[data-testid='last_name'] .opacity-40")
|
||||||
end
|
end
|
||||||
|
|
||||||
test "handles invalid sort order gracefully", %{conn: conn} do
|
test "handles invalid sort order gracefully", %{conn: conn} do
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue