fix(test): use commercial fixtures in logic_search_tests.
CI / test (push) Successful in 7m27s
CI / deploy-ift (push) Successful in 3m30s
CI / e2e-ift (push) Successful in 1m30s
CI / deploy-stage (push) Successful in 2m5s
CI / e2e-stage (push) Failing after 3m22s

Personal is never discoverable; assert exclusion explicitly. Refs EventHub/EventHubBack#73
This commit is contained in:
2026-08-16 00:04:26 +03:00
parent fcb737eb47
commit c1b4897a8b
+24 -11
View File
@@ -32,7 +32,8 @@ logic_search_test_() ->
{"Access control in search", fun test_access_control/0}, {"Access control in search", fun test_access_control/0},
{"Empty search results", fun test_empty_search/0}, {"Empty search results", fun test_empty_search/0},
{"Discovery tops without filters", fun test_discovery_returns_tops/0}, {"Discovery tops without filters", fun test_discovery_returns_tops/0},
{"Query switches to filtered search", fun test_discovery_with_q_uses_filter/0} {"Query switches to filtered search", fun test_discovery_with_q_uses_filter/0},
{"Personal excluded from search", fun test_personal_excluded_from_search/0}
]}. ]}.
%% Вспомогательные функции %% Вспомогательные функции
@@ -86,7 +87,7 @@ calendars_from({ok, Total, #{<<"calendars">> := Calendars}}) ->
%% Тесты %% Тесты
test_search_events_by_text() -> test_search_events_by_text() ->
OwnerId = create_test_user(user), OwnerId = create_test_user(user),
CalendarId = create_test_calendar(OwnerId, personal, []), CalendarId = create_test_calendar(OwnerId, commercial, []),
StartTime = eh_test_support:future_start(), StartTime = eh_test_support:future_start(),
create_test_event(CalendarId, <<"Python Workshop">>, <<"Learn Python">>, StartTime, [], undefined), create_test_event(CalendarId, <<"Python Workshop">>, <<"Learn Python">>, StartTime, [], undefined),
@@ -103,7 +104,7 @@ test_search_events_by_text() ->
test_search_events_by_tags() -> test_search_events_by_tags() ->
OwnerId = create_test_user(user), OwnerId = create_test_user(user),
CalendarId = create_test_calendar(OwnerId, personal, []), CalendarId = create_test_calendar(OwnerId, commercial, []),
StartTime = eh_test_support:future_start(), StartTime = eh_test_support:future_start(),
create_test_event(CalendarId, <<"Event 1">>, <<"">>, StartTime, [<<"python">>, <<"workshop">>], undefined), create_test_event(CalendarId, <<"Event 1">>, <<"">>, StartTime, [<<"python">>, <<"workshop">>], undefined),
@@ -121,7 +122,7 @@ test_search_events_by_tags() ->
test_search_events_by_date() -> test_search_events_by_date() ->
OwnerId = create_test_user(user), OwnerId = create_test_user(user),
CalendarId = create_test_calendar(OwnerId, personal, []), CalendarId = create_test_calendar(OwnerId, commercial, []),
Base = eh_test_support:future_start(), Base = eh_test_support:future_start(),
create_test_event(CalendarId, <<"Near Event">>, <<"">>, Base, [], undefined), create_test_event(CalendarId, <<"Near Event">>, <<"">>, Base, [], undefined),
@@ -134,7 +135,7 @@ test_search_events_by_date() ->
test_search_events_by_location() -> test_search_events_by_location() ->
OwnerId = create_test_user(user), OwnerId = create_test_user(user),
CalendarId = create_test_calendar(OwnerId, personal, []), CalendarId = create_test_calendar(OwnerId, commercial, []),
StartTime = eh_test_support:future_start(), StartTime = eh_test_support:future_start(),
MoscowLoc = #location{address = <<"Moscow">>, lat = 55.7558, lon = 37.6173}, MoscowLoc = #location{address = <<"Moscow">>, lat = 55.7558, lon = 37.6173},
@@ -153,7 +154,7 @@ test_search_events_by_location() ->
test_combined_search() -> test_combined_search() ->
OwnerId = create_test_user(user), OwnerId = create_test_user(user),
CalendarId = create_test_calendar(OwnerId, personal, []), CalendarId = create_test_calendar(OwnerId, commercial, []),
Base = eh_test_support:future_start(), Base = eh_test_support:future_start(),
create_test_event(CalendarId, <<"Python Workshop">>, <<"Learn Python">>, Base, create_test_event(CalendarId, <<"Python Workshop">>, <<"Learn Python">>, Base,
@@ -167,8 +168,10 @@ test_combined_search() ->
test_search_calendars() -> test_search_calendars() ->
OwnerId = create_test_user(user), OwnerId = create_test_user(user),
create_test_calendar(OwnerId, personal, [<<"tech">>, <<"programming">>]), create_test_calendar(OwnerId, commercial, [<<"tech">>, <<"programming">>]),
create_test_calendar(OwnerId, commercial, [<<"yoga">>, <<"wellness">>]), create_test_calendar(OwnerId, commercial, [<<"yoga">>, <<"wellness">>]),
%% personal never discoverable
create_test_calendar(OwnerId, personal, [<<"tech">>, <<"private">>]),
{Total, _} = calendars_from(logic_search:search(<<"calendar">>, undefined, OwnerId, #{tags => <<"tech">>})), {Total, _} = calendars_from(logic_search:search(<<"calendar">>, undefined, OwnerId, #{tags => <<"tech">>})),
?assertEqual(1, Total), ?assertEqual(1, Total),
@@ -186,7 +189,7 @@ test_search_calendars_image_url() ->
test_search_all() -> test_search_all() ->
OwnerId = create_test_user(user), OwnerId = create_test_user(user),
CalendarId = create_test_calendar(OwnerId, personal, []), CalendarId = create_test_calendar(OwnerId, commercial, []),
StartTime = eh_test_support:future_start(), StartTime = eh_test_support:future_start(),
create_test_event(CalendarId, <<"Test Event">>, <<"">>, StartTime, [], undefined), create_test_event(CalendarId, <<"Test Event">>, <<"">>, StartTime, [], undefined),
@@ -197,7 +200,7 @@ test_search_all() ->
test_pagination() -> test_pagination() ->
OwnerId = create_test_user(user), OwnerId = create_test_user(user),
CalendarId = create_test_calendar(OwnerId, personal, []), CalendarId = create_test_calendar(OwnerId, commercial, []),
StartTime = eh_test_support:future_start(), StartTime = eh_test_support:future_start(),
lists:foreach(fun(I) -> lists:foreach(fun(I) ->
@@ -217,7 +220,7 @@ test_pagination() ->
test_sorting() -> test_sorting() ->
OwnerId = create_test_user(user), OwnerId = create_test_user(user),
CalendarId = create_test_calendar(OwnerId, personal, []), CalendarId = create_test_calendar(OwnerId, commercial, []),
Base = eh_test_support:future_start(), Base = eh_test_support:future_start(),
create_test_event(CalendarId, <<"Early">>, <<"">>, Base, [], undefined), create_test_event(CalendarId, <<"Early">>, <<"">>, Base, [], undefined),
@@ -275,7 +278,7 @@ test_discovery_returns_tops() ->
test_discovery_with_q_uses_filter() -> test_discovery_with_q_uses_filter() ->
OwnerId = create_test_user(user), OwnerId = create_test_user(user),
CalendarId = create_test_calendar(OwnerId, personal, []), CalendarId = create_test_calendar(OwnerId, commercial, []),
StartTime = eh_test_support:future_start(), StartTime = eh_test_support:future_start(),
LowId = create_test_event(CalendarId, <<"Alpha">>, <<"">>, StartTime, [], undefined), LowId = create_test_event(CalendarId, <<"Alpha">>, <<"">>, StartTime, [], undefined),
HighId = create_test_event(CalendarId, <<"Beta">>, <<"">>, StartTime, [], undefined), HighId = create_test_event(CalendarId, <<"Beta">>, <<"">>, StartTime, [], undefined),
@@ -287,3 +290,13 @@ test_discovery_with_q_uses_filter() ->
{Total, Results} = events_from(logic_search:search(<<"event">>, <<"Alpha">>, OwnerId, #{})), {Total, Results} = events_from(logic_search:search(<<"event">>, <<"Alpha">>, OwnerId, #{})),
?assertEqual(1, Total), ?assertEqual(1, Total),
?assertMatch([#{title := <<"Alpha">>}], Results). ?assertMatch([#{title := <<"Alpha">>}], Results).
test_personal_excluded_from_search() ->
OwnerId = create_test_user(user),
PersonalId = create_test_calendar(OwnerId, personal, [<<"mine">>]),
StartTime = eh_test_support:future_start(),
create_test_event(PersonalId, <<"Secret Personal">>, <<"">>, StartTime, [], undefined),
{TotalE, _} = events_from(logic_search:search(<<"event">>, <<"Secret">>, OwnerId, #{})),
?assertEqual(0, TotalE),
{TotalC, _} = calendars_from(logic_search:search(<<"calendar">>, undefined, OwnerId, #{tags => <<"mine">>})),
?assertEqual(0, TotalC).