diff --git a/test/membership/member_type_change_integration_test.exs b/test/membership/member_type_change_integration_test.exs index 8ea151c..8aa1725 100644 --- a/test/membership/member_type_change_integration_test.exs +++ b/test/membership/member_type_change_integration_test.exs @@ -76,8 +76,8 @@ defmodule Mv.Membership.MemberTypeChangeIntegrationTest do }) |> Ash.update!() - # Wait for cycle generation - Process.sleep(100) + # Cycle generation runs synchronously in the same transaction + # No need to wait for async completion # Create cycles: one in the past (paid), one current (unpaid) # Note: Future cycles are not automatically generated by CycleGenerator, @@ -131,8 +131,8 @@ defmodule Mv.Membership.MemberTypeChangeIntegrationTest do }) |> Ash.update() - # Wait for async cycle regeneration (in test it runs synchronously) - Process.sleep(100) + # Cycle regeneration runs synchronously in the same transaction + # No need to wait for async completion # Verify past cycle is unchanged past_cycle_after = @@ -184,8 +184,8 @@ defmodule Mv.Membership.MemberTypeChangeIntegrationTest do }) |> Ash.update!() - # Wait for cycle generation - Process.sleep(100) + # Cycle generation runs synchronously in the same transaction + # No need to wait for async completion # Get the current cycle and mark it as paid current_cycle_start = CalendarCycles.calculate_cycle_start(today, :yearly) @@ -206,8 +206,8 @@ defmodule Mv.Membership.MemberTypeChangeIntegrationTest do }) |> Ash.update() - # Wait for async cycle regeneration - Process.sleep(100) + # Cycle regeneration runs synchronously in the same transaction + # No need to wait for async completion # Verify paid cycle is unchanged (not deleted and regenerated) {:ok, cycle_after} = Ash.get(MembershipFeeCycle, paid_cycle.id) @@ -232,8 +232,8 @@ defmodule Mv.Membership.MemberTypeChangeIntegrationTest do }) |> Ash.update!() - # Wait for cycle generation - Process.sleep(100) + # Cycle generation runs synchronously in the same transaction + # No need to wait for async completion # Get the current cycle and mark it as suspended current_cycle_start = CalendarCycles.calculate_cycle_start(today, :yearly) @@ -254,8 +254,8 @@ defmodule Mv.Membership.MemberTypeChangeIntegrationTest do }) |> Ash.update() - # Wait for async cycle regeneration - Process.sleep(100) + # Cycle regeneration runs synchronously in the same transaction + # No need to wait for async completion # Verify suspended cycle is unchanged (not deleted and regenerated) {:ok, cycle_after} = Ash.get(MembershipFeeCycle, suspended_cycle.id) @@ -280,8 +280,8 @@ defmodule Mv.Membership.MemberTypeChangeIntegrationTest do }) |> Ash.update!() - # Wait for cycle generation - Process.sleep(100) + # Cycle generation runs synchronously in the same transaction + # No need to wait for async completion # Create cycles: one in the past (unpaid, ended), one current (unpaid, not ended) past_cycle_start = @@ -338,8 +338,8 @@ defmodule Mv.Membership.MemberTypeChangeIntegrationTest do }) |> Ash.update() - # Wait for async cycle regeneration - Process.sleep(100) + # Cycle regeneration runs synchronously in the same transaction + # No need to wait for async completion # Verify past cycle is unchanged {:ok, past_cycle_after} = Ash.get(MembershipFeeCycle, past_cycle.id) @@ -386,8 +386,8 @@ defmodule Mv.Membership.MemberTypeChangeIntegrationTest do }) |> Ash.update!() - # Wait for cycle generation - Process.sleep(100) + # Cycle generation runs synchronously in the same transaction + # No need to wait for async completion # Get current cycle start current_cycle_start = CalendarCycles.calculate_cycle_start(today, :yearly) @@ -439,8 +439,8 @@ defmodule Mv.Membership.MemberTypeChangeIntegrationTest do }) |> Ash.update() - # Wait for async cycle regeneration - Process.sleep(100) + # Cycle regeneration runs synchronously in the same transaction + # No need to wait for async completion # Reload member with calculations updated_member = Ash.load!(updated_member, [:current_cycle_status, :overdue_count])