Implement commercial calendars: booking_open, specialists, expire without type downgrade.
CI / test (push) Successful in 6m44s
CI / deploy-ift (push) Successful in 4m2s
CI / e2e-ift (push) Successful in 1m25s
CI / deploy-stage (push) Successful in 2m25s
CI / e2e-stage (push) Successful in 1m12s

Refs EventHub/EventHubBack#54
This commit is contained in:
2026-07-22 16:12:52 +03:00
parent fdb08eb453
commit af5f506866
35 changed files with 978 additions and 207 deletions
+13 -14
View File
@@ -2,7 +2,7 @@
-include_lib("eunit/include/eunit.hrl").
-include("records.hrl").
-define(TABLES, [user, calendar, event, booking, admin]).
-define(TABLES, [user, calendar, event, booking, admin, subscription]).
setup() ->
eh_test_support:start_mnesia(),
@@ -19,7 +19,7 @@ booking_integration_test_() ->
fun setup/0,
fun cleanup/1,
[
{"Booking create stays pending", fun test_pending_booking_flow/0},
{"Booking auto confirms", fun test_auto_booking_flow/0},
{"Full booking flow with manual confirmation", fun test_manual_booking_flow/0},
{"Capacity management test", fun test_capacity_management/0},
{"Multiple bookings test", fun test_multiple_bookings/0}
@@ -39,24 +39,25 @@ create_user() ->
mnesia:dirty_write(User),
UserId.
create_commercial(OwnerId, Confirmation) ->
{ok, _} = core_subscription:create(OwnerId, monthly, true),
{ok, Calendar} = core_calendar:create(OwnerId, <<"Cal">>, <<"">>, Confirmation, commercial),
Calendar.
add_days(DateTime, Days) ->
Sec = calendar:datetime_to_gregorian_seconds(DateTime) + Days * 86400,
calendar:gregorian_seconds_to_datetime(Sec).
test_pending_booking_flow() ->
test_auto_booking_flow() ->
OwnerId = create_user(),
ParticipantId = create_user(),
{ok, Calendar} = core_calendar:create(OwnerId, <<"Auto">>, <<"">>, auto),
Calendar = create_commercial(OwnerId, auto),
StartTime = eh_test_support:future_start(),
{ok, Event} = core_event:create(Calendar#calendar.id, <<"Event">>, StartTime, 60),
{ok, Booking} = logic_booking:create_booking(ParticipantId, Event#event.id),
?assertEqual(pending, Booking#booking.status),
{ok, Stored} = core_booking:get_by_id(Booking#booking.id),
?assertEqual(pending, Stored#booking.status),
?assertEqual(confirmed, Booking#booking.status),
{ok, EventBookings} = logic_booking:list_event_bookings(Event#event.id),
?assertEqual(1, length(EventBookings)),
@@ -67,8 +68,7 @@ test_pending_booking_flow() ->
test_manual_booking_flow() ->
OwnerId = create_user(),
ParticipantId = create_user(),
{ok, Calendar} = core_calendar:create(OwnerId, <<"Manual">>, <<"">>, manual),
Calendar = create_commercial(OwnerId, manual),
StartTime = eh_test_support:future_start(),
{ok, Event} = core_event:create(Calendar#calendar.id, <<"Event">>, StartTime, 60),
@@ -88,7 +88,7 @@ test_capacity_management() ->
Participant2Id = create_user(),
Participant3Id = create_user(),
{ok, Calendar} = core_calendar:create(OwnerId, <<"Test">>, <<"">>, manual),
Calendar = create_commercial(OwnerId, manual),
StartTime = eh_test_support:future_start(),
{ok, Event} = core_event:create(Calendar#calendar.id, <<"Event">>, StartTime, 60),
@@ -108,8 +108,7 @@ test_capacity_management() ->
test_multiple_bookings() ->
OwnerId = create_user(),
ParticipantId = create_user(),
{ok, Calendar} = core_calendar:create(OwnerId, <<"Test">>, <<"">>, manual),
Calendar = create_commercial(OwnerId, manual),
Base = eh_test_support:future_start(),
StartTime1 = Base,