updated tests and fix merge conflict results

This commit is contained in:
carla 2025-12-03 14:55:20 +01:00
parent f0613fe1e5
commit 064c0df701
5 changed files with 23 additions and 98 deletions

View file

@ -101,17 +101,10 @@ defmodule MvWeb.MemberLive.Index.FieldSelectionTest do
assert result == %{}
end
test "parses valid JSON from cookie" do
json = Jason.encode!(%{"first_name" => true, "email" => false})
conn = Plug.Conn.put_req_cookie(%Plug.Conn{}, "member_field_selection", json)
result = FieldSelection.get_from_cookie(conn)
assert result == %{"first_name" => true, "email" => false}
end
test "handles invalid JSON in cookie gracefully" do
conn = Plug.Conn.put_req_cookie(%Plug.Conn{}, "member_field_selection", "invalid{[")
cookie_value = URI.encode("invalid{[")
cookie_header = "member_field_selection=#{cookie_value}"
conn = %Plug.Conn{} |> Plug.Conn.put_req_header("cookie", cookie_header)
result = FieldSelection.get_from_cookie(conn)
@ -293,8 +286,9 @@ defmodule MvWeb.MemberLive.Index.FieldSelectionTest do
result = FieldSelection.to_url_param(selection)
# Only visible fields should be included
assert result == "first_name,email"
# Only visible fields should be included (order may vary)
fields = String.split(result, ",") |> Enum.sort()
assert fields == ["email", "first_name"]
end
test "handles empty selection" do