Improve searching for group actors
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -38,16 +38,23 @@ defmodule Mobilizon.GraphQL.API.SearchTest do
|
||||
|
||||
test "search actors" do
|
||||
with_mock Actors,
|
||||
build_actors_by_username_or_name_page: fn "toto", _options, 1, 10 ->
|
||||
search_actors: fn "toto", _options, 1, 10 ->
|
||||
%Page{total: 1, elements: [%Actor{id: 42}]}
|
||||
end do
|
||||
assert {:ok, %{total: 1, elements: [%Actor{id: 42}]}} =
|
||||
Search.search_actors(%{term: "toto"}, 1, 10, :Person)
|
||||
|
||||
assert_called(
|
||||
Actors.build_actors_by_username_or_name_page(
|
||||
Actors.search_actors(
|
||||
"toto",
|
||||
[actor_type: [:Person], radius: nil, location: nil, minimum_visibility: :public],
|
||||
[
|
||||
actor_type: :Person,
|
||||
radius: nil,
|
||||
location: nil,
|
||||
minimum_visibility: :public,
|
||||
current_actor_id: nil,
|
||||
exclude_my_groups: false
|
||||
],
|
||||
1,
|
||||
10
|
||||
)
|
||||
|
||||
@@ -70,7 +70,9 @@ defmodule Mobilizon.Web.Resolvers.FollowerTest do
|
||||
variables: %{name: preferred_username}
|
||||
)
|
||||
|
||||
assert hd(res["errors"])["message"] == "unauthenticated"
|
||||
assert res["errors"] == nil
|
||||
assert res["data"]["group"]["followers"]["total"] == 1
|
||||
assert res["data"]["group"]["followers"]["elements"] == []
|
||||
end
|
||||
|
||||
test "without being a member", %{
|
||||
@@ -88,7 +90,9 @@ defmodule Mobilizon.Web.Resolvers.FollowerTest do
|
||||
variables: %{name: preferred_username}
|
||||
)
|
||||
|
||||
assert hd(res["errors"])["message"] == "unauthorized"
|
||||
assert res["errors"] == nil
|
||||
assert res["data"]["group"]["followers"]["total"] == 1
|
||||
assert res["data"]["group"]["followers"]["elements"] == []
|
||||
end
|
||||
|
||||
test "without being a moderator", %{
|
||||
@@ -107,7 +111,9 @@ defmodule Mobilizon.Web.Resolvers.FollowerTest do
|
||||
variables: %{name: preferred_username}
|
||||
)
|
||||
|
||||
assert hd(res["errors"])["message"] == "unauthorized"
|
||||
assert res["errors"] == nil
|
||||
assert res["data"]["group"]["followers"]["total"] == 1
|
||||
assert res["data"]["group"]["followers"]["elements"] == []
|
||||
end
|
||||
|
||||
test "while being a moderator", %{
|
||||
|
||||
@@ -183,14 +183,14 @@ defmodule Mobilizon.ActorsTest do
|
||||
assert MapSet.new([actor_found_id, actor2_found_id]) == MapSet.new([actor.id, actor2.id])
|
||||
end
|
||||
|
||||
test "test build_actors_by_username_or_name_page/4 returns actors with similar usernames",
|
||||
test "test search_actors/4 returns actors with similar usernames",
|
||||
%{actor: %Actor{id: actor_id}} do
|
||||
use_cassette "actors/remote_actor_mastodon_tcit" do
|
||||
with {:ok, %Actor{id: actor2_id}} <-
|
||||
ActivityPubActor.get_or_fetch_actor_by_url(@remote_account_url) do
|
||||
%Page{total: 2, elements: actors} =
|
||||
Actors.build_actors_by_username_or_name_page("tcit",
|
||||
actor_type: [:Person],
|
||||
Actors.search_actors("tcit",
|
||||
actor_type: :Person,
|
||||
minimum_visibility: :private
|
||||
)
|
||||
|
||||
@@ -201,9 +201,8 @@ defmodule Mobilizon.ActorsTest do
|
||||
end
|
||||
end
|
||||
|
||||
test "test build_actors_by_username_or_name_page/4 returns actors with similar names" do
|
||||
%{total: 0, elements: actors} =
|
||||
Actors.build_actors_by_username_or_name_page("ohno", actor_type: [:Person])
|
||||
test "test search_actors/4 returns actors with similar names" do
|
||||
%{total: 0, elements: actors} = Actors.search_actors("ohno", actor_type: :Person)
|
||||
|
||||
assert actors == []
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user