test: remove Process.sleep from type change integration tests

This commit is contained in:
Moritz 2025-12-15 12:22:06 +01:00
parent 28b2be1125
commit f08b520e66
Signed by: moritz
GPG key ID: 1020A035E5DD0824

View file

@ -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])