test: export and PDF regression for Fee Type without start_date
All checks were successful
continuous-integration/drone/push Build is passing

Add test for CSV export with only first_name and membership_fee_type.
Add test for PDF export with same field set (status and content-type).
This commit is contained in:
Moritz 2026-02-24 09:15:41 +01:00
parent 1c8c5ae83b
commit d5df2338a7
Signed by: moritz
GPG key ID: 1020A035E5DD0824
3 changed files with 71 additions and 2 deletions

View file

@ -177,6 +177,39 @@ defmodule MvWeb.MemberExportControllerTest do
assert body =~ "Alice"
end
# Regression: when membership_fee_start_date is not in member_fields, Fee Type must still be exported (append fallback)
test "export includes Fee Type when only first_name and membership_fee_type are requested (no start_date)",
%{
conn: conn,
member1: m1
} do
payload = %{
"selected_ids" => [m1.id],
"member_fields" => ["first_name", "membership_fee_type"],
"custom_field_ids" => [],
"query" => nil,
"sort_field" => nil,
"sort_order" => nil
}
conn = get(conn, "/members")
csrf_token = csrf_token_from_conn(conn)
conn =
post(conn, "/members/export.csv", %{
"payload" => Jason.encode!(payload),
"_csrf_token" => csrf_token
})
assert conn.status == 200
body = response(conn, 200)
header = body |> export_lines() |> hd()
assert header =~ "Fee Type"
assert header =~ "First Name"
assert body =~ "Alice"
end
test "export includes membership_fee_status computed field when requested", %{
conn: conn,
member1: m1
@ -532,4 +565,40 @@ defmodule MvWeb.MemberExportControllerTest do
assert membership_idx < active_idx
end
end
describe "POST /members/export.pdf" do
test "PDF export includes Fee Type column when requested without membership_fee_start_date",
%{
conn: conn
} do
m =
Fixtures.member_fixture(%{first_name: "PDF", last_name: "Test", email: "pdf@example.com"})
payload = %{
"selected_ids" => [m.id],
"member_fields" => ["first_name", "membership_fee_type"],
"custom_field_ids" => [],
"query" => nil,
"sort_field" => nil,
"sort_order" => nil
}
conn = get(conn, "/members")
csrf_token = csrf_token_from_conn(conn)
conn =
post(conn, "/members/export.pdf", %{
"payload" => Jason.encode!(payload),
"_csrf_token" => csrf_token
})
assert conn.status == 200
assert get_resp_header(conn, "content-type") |> List.first() =~ "application/pdf"
body = response(conn, 200)
# PDF is generated successfully with Fee Type in columns (regression: fee type without start_date)
assert is_binary(body) and byte_size(body) > 0
end
end
end