1
0
Fork 1
mirror of https://akkoma.dev/AkkomaGang/akkoma.git synced 2024-12-25 04:53:06 +00:00

fix all tests

This commit is contained in:
FloatingGhost 2022-06-11 16:14:22 +01:00
parent c3ed86cd1e
commit 32fbd2e4e3
12 changed files with 43 additions and 23 deletions

View file

@ -152,12 +152,12 @@
config :logger, truncate: 65536
config :logger, :console,
level: :debug,
level: :info,
format: "\n$time $metadata[$level] $message\n",
metadata: [:request_id]
config :logger, :ex_syslogger,
level: :debug,
level: :info,
ident: "pleroma",
format: "$metadata[$level] $message",
metadata: [:request_id]

View file

@ -14,6 +14,7 @@ defmodule Pleroma.Search.Builtin do
def search(_conn, %{q: query} = params, options) do
version = Keyword.get(options, :version)
timeout = Keyword.get(Repo.config(), :timeout, 15_000)
query = String.trim(query)
default_values = %{"statuses" => [], "accounts" => [], "hashtags" => []}
default_values

View file

@ -1321,7 +1321,7 @@ def fetch_activities_query(recipients, opts \\ %{}) do
fetch_activities_query_ap_ids_ops(opts)
config = %{
skip_thread_containment: true
skip_thread_containment: Config.get([:instance, :skip_thread_containment])
}
query =

View file

@ -543,7 +543,6 @@ def fetch_latest_undo(%User{ap_id: ap_id}) do
end
def get_latest_reaction(internal_activity_id, %{ap_id: ap_id}, emoji) do
IO.inspect(emoji)
%{data: %{"object" => object_ap_id}} = Activity.get_by_id(internal_activity_id)
emoji = Pleroma.Emoji.maybe_quote(emoji)

View file

@ -61,6 +61,7 @@ def filter_allowed_users(reactions, user, with_muted) do
|> Stream.map(fn
[emoji, users, url] when is_list(users) -> filter_emoji.(emoji, users, url)
{emoji, users, url} when is_list(users) -> filter_emoji.(emoji, users, url)
{emoji, users} when is_list(users) -> filter_emoji.(emoji, users, nil)
_ -> nil
end)
|> Stream.reject(&is_nil/1)

View file

@ -130,7 +130,7 @@ test "max_body_length returns error if streaming body more than that option", %{
assert capture_log(fn ->
ReverseProxy.call(conn, "/stream-bytes/50", max_body_length: 30)
end) =~
"[warn] Elixir.Pleroma.ReverseProxy request to /stream-bytes/50 failed while reading/chunking: :body_too_large"
"Elixir.Pleroma.ReverseProxy request to /stream-bytes/50 failed while reading/chunking: :body_too_large"
end
end

View file

@ -158,7 +158,7 @@ test "adds the reaction to the object", %{emoji_react: emoji_react, user: user}
object = Object.get_by_ap_id(emoji_react.data["object"])
assert object.data["reaction_count"] == 1
assert ["👌", [user.ap_id]] in object.data["reactions"]
assert ["👌", [user.ap_id], nil] in object.data["reactions"]
end
test "creates a notification", %{emoji_react: emoji_react, poster: poster} do

View file

@ -360,7 +360,13 @@ test "it returns reports with notes", %{conn: conn, admin: admin} do
response = json_response_and_validate_schema(conn, 200)
notes = hd(response["reports"])["notes"]
[note, _] = notes
assert 2 == Enum.count(notes)
note =
notes
|> Enum.find(fn note -> note["content"] == "this is disgusting!" end)
refute is_nil(note)
assert note["user"]["nickname"] == admin.nickname
assert note["content"] == "this is disgusting!"

View file

@ -309,7 +309,7 @@ test "when date is a binary in wrong format" do
assert capture_log(fn ->
assert Utils.date_to_asctime(date) == expected
end) =~ "[warn] Date #{date} in wrong format, must be ISO 8601"
end) =~ "[warning] Date #{date} in wrong format, must be ISO 8601"
end
test "when date is a Unix timestamp" do
@ -319,7 +319,7 @@ test "when date is a Unix timestamp" do
assert capture_log(fn ->
assert Utils.date_to_asctime(date) == expected
end) =~ "[warn] Date #{date} in wrong format, must be ISO 8601"
end) =~ "[warning] Date #{date} in wrong format, must be ISO 8601"
end
test "when date is nil" do
@ -327,13 +327,13 @@ test "when date is nil" do
assert capture_log(fn ->
assert Utils.date_to_asctime(nil) == expected
end) =~ "[warn] Date in wrong format, must be ISO 8601"
end) =~ "[warning] Date in wrong format, must be ISO 8601"
end
test "when date is a random string" do
assert capture_log(fn ->
assert Utils.date_to_asctime("foo") == ""
end) =~ "[warn] Date foo in wrong format, must be ISO 8601"
end) =~ "[warning] Date foo in wrong format, must be ISO 8601"
end
end

View file

@ -323,7 +323,6 @@ test "search fetches remote accounts", %{conn: conn} do
|> assign(:token, insert(:oauth_token, user: user, scopes: ["read"]))
|> get("/api/v1/search?#{query}")
|> json_response_and_validate_schema(200)
[account] = results["accounts"]
assert account["acct"] == "mike@osada.macgirvin.com"
end

View file

@ -34,16 +34,25 @@ test "has an emoji reaction list" do
{:ok, activity} = CommonAPI.post(user, %{status: "dae cofe??"})
{:ok, _} = CommonAPI.react_with_emoji(activity.id, user, "")
{:ok, _} = CommonAPI.react_with_emoji(activity.id, user, ":dinosaur:")
{:ok, _} = CommonAPI.react_with_emoji(activity.id, third_user, "🍵")
{:ok, _} = CommonAPI.react_with_emoji(activity.id, other_user, "")
{:ok, _} = CommonAPI.react_with_emoji(activity.id, other_user, ":dinosaur:")
activity = Repo.get(Activity, activity.id)
status = StatusView.render("show.json", activity: activity)
assert_schema(status, "Status", Pleroma.Web.ApiSpec.spec())
assert status[:pleroma][:emoji_reactions] == [
%{name: "", count: 2, me: false},
%{name: "🍵", count: 1, me: false}
%{name: "", count: 2, me: false, url: nil},
%{
count: 2,
me: false,
name: "dinosaur",
url: "http://localhost:4001/emoji/dino walking.gif"
},
%{name: "🍵", count: 1, me: false, url: nil}
]
status = StatusView.render("show.json", activity: activity, for: user)
@ -51,8 +60,14 @@ test "has an emoji reaction list" do
assert_schema(status, "Status", Pleroma.Web.ApiSpec.spec())
assert status[:pleroma][:emoji_reactions] == [
%{name: "", count: 2, me: true},
%{name: "🍵", count: 1, me: false}
%{name: "", count: 2, me: true, url: nil},
%{
count: 2,
me: true,
name: "dinosaur",
url: "http://localhost:4001/emoji/dino walking.gif"
},
%{name: "🍵", count: 1, me: false, url: nil}
]
end
@ -65,11 +80,10 @@ test "works correctly with badly formatted emojis" do
|> Object.update_data(%{"reactions" => %{"" => [user.ap_id], "x" => 1}})
activity = Activity.get_by_id(activity.id)
status = StatusView.render("show.json", activity: activity, for: user)
assert status[:pleroma][:emoji_reactions] == [
%{name: "", count: 1, me: true}
%{name: "", count: 1, me: true, url: nil}
]
end
@ -89,7 +103,7 @@ test "doesn't show reactions from muted and blocked users" do
status = StatusView.render("show.json", activity: activity)
assert status[:pleroma][:emoji_reactions] == [
%{name: "", count: 1, me: false}
%{name: "", count: 1, me: false, url: nil}
]
status = StatusView.render("show.json", activity: activity, for: user)
@ -101,19 +115,19 @@ test "doesn't show reactions from muted and blocked users" do
status = StatusView.render("show.json", activity: activity)
assert status[:pleroma][:emoji_reactions] == [
%{name: "", count: 2, me: false}
%{name: "", count: 2, me: false, url: nil}
]
status = StatusView.render("show.json", activity: activity, for: user)
assert status[:pleroma][:emoji_reactions] == [
%{name: "", count: 1, me: false}
%{name: "", count: 1, me: false, url: nil}
]
status = StatusView.render("show.json", activity: activity, for: other_user)
assert status[:pleroma][:emoji_reactions] == [
%{name: "", count: 1, me: true}
%{name: "", count: 1, me: true, url: nil}
]
end

View file

@ -144,7 +144,7 @@ test "video attachments have image thumbnail with WxH metadata with Preview Prox
[
property: "og:image",
content:
"http://localhost:4001/proxy/preview/LzAnlke-l5oZbNzWsrHfprX1rGw/aHR0cHM6Ly9wbGVyb21hLmdvdi9hYm91dC9qdWNoZS53ZWJt/juche.webm"
"http://localhost:4001/proxy/preview/FElXD3PfapZSKq-u62Dc3BiaIM8/aHR0cHM6Ly9wbGVyb21hLmdvdi9hYm91dC9qdWNoZS53ZWJt/juche.webm"
], []} in result
end