Statistics tests: strict first_join_year nil, fee_type_id in URL
This commit is contained in:
parent
8abad9040f
commit
aa692ac224
2 changed files with 35 additions and 2 deletions
|
|
@ -46,9 +46,9 @@ defmodule Mv.StatisticsTest do
|
|||
end
|
||||
|
||||
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)
|
||||
assert result == nil or is_integer(result)
|
||||
assert result == nil
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue