From 6f568bfe541aa89580b6855b5ce39233989a76b0 Mon Sep 17 00:00:00 2001 From: Moritz Date: Fri, 26 Dec 2025 21:41:30 +0100 Subject: [PATCH] test: fix tests after join_date validation and UI changes Update test to expect join_date validation error. Fix toggle button selector in cycle view test. Remove unnecessary cleanup from create_cycle helper. --- test/membership/member_test.exs | 7 +++++-- .../member_live/index/membership_fee_status_test.exs | 10 ++-------- test/mv_web/member_live/index_test.exs | 4 ++-- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/test/membership/member_test.exs b/test/membership/member_test.exs index 40a68ac..1c4beb1 100644 --- a/test/membership/member_test.exs +++ b/test/membership/member_test.exs @@ -49,9 +49,12 @@ defmodule Mv.Membership.MemberTest do assert {:ok, _member} = Membership.create_member(attrs2) end - test "Join date can be in the future" do + test "Join date cannot be in the future" do attrs = Map.put(@valid_attrs, :join_date, Date.utc_today() |> Date.add(1)) - assert {:ok, _member} = Membership.create_member(attrs) + + assert {:error, + %Ash.Error.Invalid{errors: [%Ash.Error.Changes.InvalidAttribute{field: :join_date}]}} = + Membership.create_member(attrs) end test "Exit date is optional but must not be before join date if both are specified" do diff --git a/test/mv_web/member_live/index/membership_fee_status_test.exs b/test/mv_web/member_live/index/membership_fee_status_test.exs index 3613276..c56e80c 100644 --- a/test/mv_web/member_live/index/membership_fee_status_test.exs +++ b/test/mv_web/member_live/index/membership_fee_status_test.exs @@ -42,15 +42,9 @@ defmodule MvWeb.MemberLive.Index.MembershipFeeStatusTest do end # Helper to create a cycle + # Note: Does not delete existing cycles - tests should manage their own test data + # If cleanup is needed, it should be done in setup or explicitly in the test defp create_cycle(member, fee_type, attrs) do - # Delete any auto-generated cycles first to avoid conflicts - existing_cycles = - MembershipFeeCycle - |> Ash.Query.filter(member_id == ^member.id) - |> Ash.read!() - - Enum.each(existing_cycles, fn cycle -> Ash.destroy!(cycle) end) - default_attrs = %{ cycle_start: ~D[2023-01-01], amount: Decimal.new("50.00"), diff --git a/test/mv_web/member_live/index_test.exs b/test/mv_web/member_live/index_test.exs index 73cd5bb..d4f5644 100644 --- a/test/mv_web/member_live/index_test.exs +++ b/test/mv_web/member_live/index_test.exs @@ -644,9 +644,9 @@ defmodule MvWeb.MemberLive.IndexTest do {:ok, view, _html} = live(conn, "/members?cycle_status_filter=paid") # Toggle to current cycle - this should update URL and preserve filter - # Use the button in the membership fee status column header + # Use the button in the toolbar view - |> element("button[phx-click='toggle_cycle_view'].btn-xs") + |> element("button[phx-click='toggle_cycle_view']") |> render_click() # Wait for patch to complete