mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-12-23 01:35:28 +00:00
Search: Add tests for unicode searches.
This commit is contained in:
parent
6355694309
commit
c1bae01376
|
@ -126,9 +126,25 @@ defmodule Pleroma.ActivityTest do
|
||||||
}
|
}
|
||||||
|
|
||||||
{:ok, local_activity} = Pleroma.Web.CommonAPI.post(user, %{"status" => "find me!"})
|
{:ok, local_activity} = Pleroma.Web.CommonAPI.post(user, %{"status" => "find me!"})
|
||||||
|
{:ok, japanese_activity} = Pleroma.Web.CommonAPI.post(user, %{"status" => "更新情報"})
|
||||||
{:ok, job} = Pleroma.Web.Federator.incoming_ap_doc(params)
|
{:ok, job} = Pleroma.Web.Federator.incoming_ap_doc(params)
|
||||||
{:ok, remote_activity} = ObanHelpers.perform(job)
|
{:ok, remote_activity} = ObanHelpers.perform(job)
|
||||||
%{local_activity: local_activity, remote_activity: remote_activity, user: user}
|
|
||||||
|
%{
|
||||||
|
japanese_activity: japanese_activity,
|
||||||
|
local_activity: local_activity,
|
||||||
|
remote_activity: remote_activity,
|
||||||
|
user: user
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
test "finds utf8 text in statuses", %{
|
||||||
|
japanese_activity: japanese_activity,
|
||||||
|
user: user
|
||||||
|
} do
|
||||||
|
activities = Activity.search(user, "更新情報")
|
||||||
|
|
||||||
|
assert [^japanese_activity] = activities
|
||||||
end
|
end
|
||||||
|
|
||||||
test "find local and remote statuses for authenticated users", %{
|
test "find local and remote statuses for authenticated users", %{
|
||||||
|
|
|
@ -40,7 +40,7 @@ defmodule Pleroma.Web.MastodonAPI.SearchControllerTest do
|
||||||
test "search", %{conn: conn} do
|
test "search", %{conn: conn} do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
user_two = insert(:user, %{nickname: "shp@shitposter.club"})
|
user_two = insert(:user, %{nickname: "shp@shitposter.club"})
|
||||||
user_three = insert(:user, %{nickname: "shp@heldscal.la", name: "I love 2hu"})
|
user_three = insert(:user, %{nickname: "shp@heldscal.la", name: "I love 2hu 天子"})
|
||||||
|
|
||||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "This is about 2hu private"})
|
{:ok, activity} = CommonAPI.post(user, %{"status" => "This is about 2hu private"})
|
||||||
|
|
||||||
|
@ -52,9 +52,9 @@ defmodule Pleroma.Web.MastodonAPI.SearchControllerTest do
|
||||||
|
|
||||||
{:ok, _} = CommonAPI.post(user_two, %{"status" => "This isn't"})
|
{:ok, _} = CommonAPI.post(user_two, %{"status" => "This isn't"})
|
||||||
|
|
||||||
conn = get(conn, "/api/v2/search", %{"q" => "2hu #private"})
|
results =
|
||||||
|
get(conn, "/api/v2/search", %{"q" => "2hu #private"})
|
||||||
assert results = json_response(conn, 200)
|
|> json_response(200)
|
||||||
|
|
||||||
[account | _] = results["accounts"]
|
[account | _] = results["accounts"]
|
||||||
assert account["id"] == to_string(user_three.id)
|
assert account["id"] == to_string(user_three.id)
|
||||||
|
@ -65,6 +65,13 @@ defmodule Pleroma.Web.MastodonAPI.SearchControllerTest do
|
||||||
|
|
||||||
[status] = results["statuses"]
|
[status] = results["statuses"]
|
||||||
assert status["id"] == to_string(activity.id)
|
assert status["id"] == to_string(activity.id)
|
||||||
|
|
||||||
|
results =
|
||||||
|
get(conn, "/api/v2/search", %{"q" => "天子"})
|
||||||
|
|> json_response(200)
|
||||||
|
|
||||||
|
[account] == results["accounts"]
|
||||||
|
assert account["id"] == to_string(user_three.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue