Statistics tests: strict first_join_year nil, fee_type_id in URL

This commit is contained in:
Moritz 2026-02-12 18:44:46 +01:00 committed by moritz
parent 4b61289f33
commit 3eead112b0
2 changed files with 35 additions and 2 deletions

View file

@ -6,6 +6,8 @@ defmodule MvWeb.StatisticsLiveTest do
import Phoenix.LiveViewTest
alias Mv.MembershipFees.MembershipFeeType
describe "statistics page" do
test "renders statistics page with title and key labels for authenticated user with access",
%{
@ -28,5 +30,36 @@ defmodule MvWeb.StatisticsLiveTest do
# table header or legend
assert html =~ "Year"
end
test "fee_type_id in URL updates selected filter and contributions", %{conn: conn} do
actor = Mv.Helpers.SystemActor.get_system_actor()
fee_types =
MembershipFeeType
|> Ash.Query.sort(name: :asc)
|> Ash.read!(domain: Mv.MembershipFees, actor: actor)
fee_type =
case List.first(fee_types) do
nil ->
MembershipFeeType
|> Ash.Changeset.for_create(:create, %{
name: "Test Fee #{System.unique_integer([:positive])}",
amount: Decimal.new("50.00"),
interval: :yearly
})
|> Ash.create!(actor: actor)
ft ->
ft
end
path = ~p"/statistics" <> "?" <> URI.encode_query(%{"fee_type_id" => fee_type.id})
{:ok, view, html} = live(conn, path)
assert view |> element("select#fee-type-filter") |> has_element?()
assert html =~ fee_type.name
assert html =~ "Contributions by year"
end
end
end