fix(ct): adapt API tests to sole Default personal
CI / test (push) Successful in 8m11s
CI / deploy-ift (push) Successful in 3m30s
CI / e2e-ift (push) Successful in 6m10s
CI / deploy-stage (push) Successful in 3m3s
CI / e2e-stage (push) Successful in 1m15s

Default create_calendar to commercial; reuse existing personal on 409;
assert verify title Default; cover personal_exists / default_calendar.

Refs EventHub/EventHubBack#64
This commit is contained in:
2026-07-30 22:29:52 +03:00
parent 10464de3ec
commit 7d39c004a1
5 changed files with 68 additions and 37 deletions
+16 -10
View File
@@ -15,9 +15,8 @@ test() ->
OtherToken = api_test_runner:register_and_login(
api_test_runner:unique_email(<<"other">>), <<"pass">>),
% Создаём календарь для тестов
#{<<"id">> := CalId} = api_test_runner:client_post(<<"/v1/calendars">>, Token,
#{title => <<"TestCal">>, type => <<"personal">>}),
%% Studio calendar (sole personal Default cannot be deleted)
CalId = api_test_runner:create_calendar(Token, #{title => <<"TestCal">>}),
test_get_calendar(Token, CalId),
test_get_calendar_unauthorized(CalId),
@@ -26,6 +25,7 @@ test() ->
test_update_calendar_settings(Token, CalId),
test_update_calendar_forbidden(OtherToken, CalId),
test_delete_calendar(Token, CalId),
test_delete_default_personal_forbidden(Token),
test_delete_calendar_forbidden(OtherToken, CalId),
ct:pal("=== All user calendar by id tests passed ==="),
@@ -104,19 +104,25 @@ test_update_calendar_forbidden(OtherToken, CalId) ->
ct:pal(" OK: got 403").
test_delete_calendar(Token, CalId) ->
ct:pal(" TEST: Delete calendar (soft-delete)"),
ct:pal(" TEST: Delete studio calendar (soft-delete)"),
Path = <<"/v1/calendars/", CalId/binary>>,
Resp = api_test_runner:client_request(delete, Path, Token),
?assertMatch({ok, 200, _, _}, Resp),
ct:pal(" OK: deleted").
test_delete_calendar_forbidden(OtherToken, CalId) ->
% Первый раз мы уже удалили, но проверим на другом календаре
test_delete_default_personal_forbidden(Token) ->
ct:pal(" TEST: Delete sole personal calendar (403 default_calendar)"),
PersonalId = api_test_runner:existing_personal_calendar_id(Token),
Path = <<"/v1/calendars/", PersonalId/binary>>,
Resp = api_test_runner:client_request(delete, Path, Token),
?assertMatch({ok, 403, _, _}, Resp),
ct:pal(" OK: got 403 default_calendar").
test_delete_calendar_forbidden(OtherToken, _DeletedCalId) ->
ct:pal(" TEST: Delete calendar by non-owner (403)"),
% Создадим новый календарь владельцем Token, попробуем удалить OtherToken
#{<<"id">> := NewCalId} = api_test_runner:client_post(<<"/v1/calendars">>, api_test_runner:get_user_token(),
#{title => <<"ForbiddenDel">>, type => <<"personal">>}),
OwnerToken = api_test_runner:get_user_token(),
NewCalId = api_test_runner:create_calendar(OwnerToken, #{title => <<"ForbiddenDel">>}),
Path = <<"/v1/calendars/", NewCalId/binary>>,
Resp = api_test_runner:client_request(delete, Path, OtherToken),
?assertMatch({ok, 403, _, _}, Resp),
ct:pal(" OK: got 403").
ct:pal(" OK: got 403").