feat: load boolean custom fields
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
fbf3b64192
commit
1011b94acf
2 changed files with 55 additions and 0 deletions
|
|
@ -696,6 +696,54 @@ defmodule MvWeb.MemberLive.IndexTest do
|
|||
assert state.socket.assigns.boolean_custom_field_filters == %{}
|
||||
end
|
||||
|
||||
test "mount initializes boolean_custom_fields as empty list when no boolean fields exist", %{
|
||||
conn: conn
|
||||
} do
|
||||
conn = conn_with_oidc_user(conn)
|
||||
{:ok, view, _html} = live(conn, "/members")
|
||||
|
||||
state = :sys.get_state(view.pid)
|
||||
assert state.socket.assigns.boolean_custom_fields == []
|
||||
end
|
||||
|
||||
test "mount loads and filters boolean custom fields correctly", %{conn: conn} do
|
||||
conn = conn_with_oidc_user(conn)
|
||||
|
||||
# Create boolean and non-boolean custom fields
|
||||
boolean_field1 = create_boolean_custom_field(%{name: "Active Member"})
|
||||
boolean_field2 = create_boolean_custom_field(%{name: "Newsletter Subscription"})
|
||||
_string_field = create_string_custom_field(%{name: "Phone Number"})
|
||||
|
||||
{:ok, view, _html} = live(conn, "/members")
|
||||
|
||||
state = :sys.get_state(view.pid)
|
||||
boolean_custom_fields = state.socket.assigns.boolean_custom_fields
|
||||
|
||||
# Should only contain boolean fields
|
||||
assert length(boolean_custom_fields) == 2
|
||||
assert Enum.all?(boolean_custom_fields, &(&1.value_type == :boolean))
|
||||
assert Enum.any?(boolean_custom_fields, &(&1.id == boolean_field1.id))
|
||||
assert Enum.any?(boolean_custom_fields, &(&1.id == boolean_field2.id))
|
||||
end
|
||||
|
||||
test "mount sorts boolean custom fields by name ascending", %{conn: conn} do
|
||||
conn = conn_with_oidc_user(conn)
|
||||
|
||||
# Create boolean fields with specific names to test sorting
|
||||
_boolean_field_z = create_boolean_custom_field(%{name: "Zebra Field"})
|
||||
_boolean_field_a = create_boolean_custom_field(%{name: "Alpha Field"})
|
||||
_boolean_field_m = create_boolean_custom_field(%{name: "Middle Field"})
|
||||
|
||||
{:ok, view, _html} = live(conn, "/members")
|
||||
|
||||
state = :sys.get_state(view.pid)
|
||||
boolean_custom_fields = state.socket.assigns.boolean_custom_fields
|
||||
|
||||
# Should be sorted by name ascending
|
||||
names = Enum.map(boolean_custom_fields, & &1.name)
|
||||
assert names == ["Alpha Field", "Middle Field", "Zebra Field"]
|
||||
end
|
||||
|
||||
test "handle_params parses bf_<id> values correctly", %{conn: conn} do
|
||||
conn = conn_with_oidc_user(conn)
|
||||
boolean_field = create_boolean_custom_field()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue