Statistic Page closes #310 #417

Merged
moritz merged 16 commits from feature/statistics into main 2026-02-12 19:40:23 +01:00
2 changed files with 35 additions and 2 deletions
Showing only changes of commit 3eead112b0 - Show all commits

View file

@ -46,9 +46,9 @@ defmodule Mv.StatisticsTest do
end end
test "returns nil when no members exist", %{actor: actor} do test "returns nil when no members exist", %{actor: actor} do
# Relies on empty member table for this test; may be nil if other tests created members # Expects empty member table (sandbox isolation). If flaky, ensure no other test creates members.
result = Statistics.first_join_year(actor: actor) result = Statistics.first_join_year(actor: actor)
assert result == nil or is_integer(result) assert result == nil
end end
end end

View file

@ -6,6 +6,8 @@ defmodule MvWeb.StatisticsLiveTest do
import Phoenix.LiveViewTest import Phoenix.LiveViewTest
alias Mv.MembershipFees.MembershipFeeType
describe "statistics page" do describe "statistics page" do
test "renders statistics page with title and key labels for authenticated user with access", 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 # table header or legend
assert html =~ "Year" assert html =~ "Year"
end 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
end end