Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into remake-remodel-dms
This commit is contained in:
commit
814c3e5171
570 changed files with 3509 additions and 2461 deletions
|
|
@ -555,6 +555,7 @@ defmodule Pleroma.UserTest do
|
|||
assert user == fetched_user
|
||||
end
|
||||
|
||||
@tag capture_log: true
|
||||
test "returns nil if no user could be fetched" do
|
||||
{:error, fetched_user} = User.get_or_fetch_by_nickname("nonexistant@social.heldscal.la")
|
||||
assert fetched_user == "not found nonexistant@social.heldscal.la"
|
||||
|
|
@ -1171,6 +1172,33 @@ defmodule Pleroma.UserTest do
|
|||
end
|
||||
end
|
||||
|
||||
describe "delete/1 when confirmation is pending" do
|
||||
setup do
|
||||
user = insert(:user, confirmation_pending: true)
|
||||
{:ok, user: user}
|
||||
end
|
||||
|
||||
test "deletes user from database when activation required", %{user: user} do
|
||||
clear_config([:instance, :account_activation_required], true)
|
||||
|
||||
{:ok, job} = User.delete(user)
|
||||
{:ok, _} = ObanHelpers.perform(job)
|
||||
|
||||
refute User.get_cached_by_id(user.id)
|
||||
refute User.get_by_id(user.id)
|
||||
end
|
||||
|
||||
test "deactivates user when activation is not required", %{user: user} do
|
||||
clear_config([:instance, :account_activation_required], false)
|
||||
|
||||
{:ok, job} = User.delete(user)
|
||||
{:ok, _} = ObanHelpers.perform(job)
|
||||
|
||||
assert %{deactivated: true} = User.get_cached_by_id(user.id)
|
||||
assert %{deactivated: true} = User.get_by_id(user.id)
|
||||
end
|
||||
end
|
||||
|
||||
test "get_public_key_for_ap_id fetches a user that's not in the db" do
|
||||
assert {:ok, _key} = User.get_public_key_for_ap_id("http://mastodon.example.org/users/admin")
|
||||
end
|
||||
|
|
|
|||
|
|
@ -141,6 +141,31 @@ defmodule Pleroma.Web.ActivityPub.SideEffectsTest do
|
|||
end
|
||||
end
|
||||
|
||||
describe "delete users with confirmation pending" do
|
||||
setup do
|
||||
user = insert(:user, confirmation_pending: true)
|
||||
{:ok, delete_user_data, _meta} = Builder.delete(user, user.ap_id)
|
||||
{:ok, delete_user, _meta} = ActivityPub.persist(delete_user_data, local: true)
|
||||
{:ok, delete: delete_user, user: user}
|
||||
end
|
||||
|
||||
test "when activation is not required", %{delete: delete, user: user} do
|
||||
clear_config([:instance, :account_activation_required], false)
|
||||
{:ok, _, _} = SideEffects.handle(delete)
|
||||
ObanHelpers.perform_all()
|
||||
|
||||
assert User.get_cached_by_id(user.id).deactivated
|
||||
end
|
||||
|
||||
test "when activation is required", %{delete: delete, user: user} do
|
||||
clear_config([:instance, :account_activation_required], true)
|
||||
{:ok, _, _} = SideEffects.handle(delete)
|
||||
ObanHelpers.perform_all()
|
||||
|
||||
refute User.get_cached_by_id(user.id)
|
||||
end
|
||||
end
|
||||
|
||||
describe "Undo objects" do
|
||||
setup do
|
||||
poster = insert(:user)
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ defmodule Pleroma.Web.ApiSpec.SchemaExamplesTest do
|
|||
end
|
||||
end
|
||||
|
||||
for {status, response} <- operation.responses do
|
||||
for {status, response} <- operation.responses, is_map(response.content[@content_type]) do
|
||||
describe "#{operation.operationId} - #{status} Response" do
|
||||
@schema resolve_schema(response.content[@content_type].schema)
|
||||
|
||||
|
|
|
|||
|
|
@ -916,10 +916,10 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.listen(user, %{
|
||||
"title" => "lain radio episode 1",
|
||||
"album" => "lain radio",
|
||||
"artist" => "lain",
|
||||
"length" => 180_000
|
||||
title: "lain radio episode 1",
|
||||
album: "lain radio",
|
||||
artist: "lain",
|
||||
length: 180_000
|
||||
})
|
||||
|
||||
object = Object.normalize(activity)
|
||||
|
|
@ -934,11 +934,11 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.listen(user, %{
|
||||
"title" => "lain radio episode 1",
|
||||
"album" => "lain radio",
|
||||
"artist" => "lain",
|
||||
"length" => 180_000,
|
||||
"visibility" => "private"
|
||||
title: "lain radio episode 1",
|
||||
album: "lain radio",
|
||||
artist: "lain",
|
||||
length: 180_000,
|
||||
visibility: "private"
|
||||
})
|
||||
|
||||
object = Object.normalize(activity)
|
||||
|
|
|
|||
|
|
@ -112,6 +112,13 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController.UpdateCredentialsTest do
|
|||
assert user_data["source"]["privacy"] == "unlisted"
|
||||
end
|
||||
|
||||
test "updates the user's privacy", %{conn: conn} do
|
||||
conn = patch(conn, "/api/v1/accounts/update_credentials", %{source: %{privacy: "unlisted"}})
|
||||
|
||||
assert user_data = json_response_and_validate_schema(conn, 200)
|
||||
assert user_data["source"]["privacy"] == "unlisted"
|
||||
end
|
||||
|
||||
test "updates the user's hide_followers status", %{conn: conn} do
|
||||
conn = patch(conn, "/api/v1/accounts/update_credentials", %{hide_followers: "true"})
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,8 @@ defmodule Pleroma.Web.MastodonAPI.InstanceControllerTest do
|
|||
"upload_limit" => _,
|
||||
"avatar_upload_limit" => _,
|
||||
"background_upload_limit" => _,
|
||||
"banner_upload_limit" => _
|
||||
"banner_upload_limit" => _,
|
||||
"background_image" => _
|
||||
} = result
|
||||
|
||||
assert result["pleroma"]["metadata"]["features"]
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
|> post("/api/v1/statuses", %{
|
||||
"status" => "cofe",
|
||||
"spoiler_text" => "2hu",
|
||||
"sensitive" => "false"
|
||||
"sensitive" => "0"
|
||||
})
|
||||
|
||||
{:ok, ttl} = Cachex.ttl(:idempotency_cache, idempotency_key)
|
||||
|
|
@ -81,7 +81,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
|> post("/api/v1/statuses", %{
|
||||
"status" => "cofe",
|
||||
"spoiler_text" => "2hu",
|
||||
"sensitive" => "false"
|
||||
"sensitive" => 0
|
||||
})
|
||||
|
||||
assert %{"id" => second_id} = json_response(conn_two, 200)
|
||||
|
|
@ -93,7 +93,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
|> post("/api/v1/statuses", %{
|
||||
"status" => "cofe",
|
||||
"spoiler_text" => "2hu",
|
||||
"sensitive" => "false"
|
||||
"sensitive" => "False"
|
||||
})
|
||||
|
||||
assert %{"id" => third_id} = json_response_and_validate_schema(conn_three, 200)
|
||||
|
|
|
|||
|
|
@ -620,14 +620,4 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||
|
||||
assert status.visibility == "list"
|
||||
end
|
||||
|
||||
test "successfully renders a Listen activity (pleroma extension)" do
|
||||
listen_activity = insert(:listen)
|
||||
|
||||
status = StatusView.render("listen.json", activity: listen_activity)
|
||||
|
||||
assert status.length == listen_activity.data["object"]["length"]
|
||||
assert status.title == listen_activity.data["object"]["title"]
|
||||
assert_schema(status, "Status", Pleroma.Web.ApiSpec.spec())
|
||||
end
|
||||
end
|
||||
|
|
|
|||
35
test/web/media_proxy/invalidations/http_test.exs
Normal file
35
test/web/media_proxy/invalidations/http_test.exs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
defmodule Pleroma.Web.MediaProxy.Invalidation.HttpTest do
|
||||
use ExUnit.Case
|
||||
alias Pleroma.Web.MediaProxy.Invalidation
|
||||
|
||||
import ExUnit.CaptureLog
|
||||
import Tesla.Mock
|
||||
|
||||
test "logs hasn't error message when request is valid" do
|
||||
mock(fn
|
||||
%{method: :purge, url: "http://example.com/media/example.jpg"} ->
|
||||
%Tesla.Env{status: 200}
|
||||
end)
|
||||
|
||||
refute capture_log(fn ->
|
||||
assert Invalidation.Http.purge(
|
||||
["http://example.com/media/example.jpg"],
|
||||
%{}
|
||||
) == {:ok, "success"}
|
||||
end) =~ "Error while cache purge"
|
||||
end
|
||||
|
||||
test "it write error message in logs when request invalid" do
|
||||
mock(fn
|
||||
%{method: :purge, url: "http://example.com/media/example1.jpg"} ->
|
||||
%Tesla.Env{status: 404}
|
||||
end)
|
||||
|
||||
assert capture_log(fn ->
|
||||
assert Invalidation.Http.purge(
|
||||
["http://example.com/media/example1.jpg"],
|
||||
%{}
|
||||
) == {:ok, "success"}
|
||||
end) =~ "Error while cache purge: url - http://example.com/media/example1.jpg"
|
||||
end
|
||||
end
|
||||
20
test/web/media_proxy/invalidations/script_test.exs
Normal file
20
test/web/media_proxy/invalidations/script_test.exs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
defmodule Pleroma.Web.MediaProxy.Invalidation.ScriptTest do
|
||||
use ExUnit.Case
|
||||
alias Pleroma.Web.MediaProxy.Invalidation
|
||||
|
||||
import ExUnit.CaptureLog
|
||||
|
||||
test "it logger error when script not found" do
|
||||
assert capture_log(fn ->
|
||||
assert Invalidation.Script.purge(
|
||||
["http://example.com/media/example.jpg"],
|
||||
%{script_path: "./example"}
|
||||
) == {:error, "\"%ErlangError{original: :enoent}\""}
|
||||
end) =~ "Error while cache purge: \"%ErlangError{original: :enoent}\""
|
||||
|
||||
assert Invalidation.Script.purge(
|
||||
["http://example.com/media/example.jpg"],
|
||||
%{}
|
||||
) == {:error, "not found script path"}
|
||||
end
|
||||
end
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do
|
||||
defmodule Pleroma.Web.PleromaAPI.EmojiPackControllerTest do
|
||||
use Pleroma.Web.ConnCase
|
||||
|
||||
import Tesla.Mock
|
||||
|
|
@ -28,7 +28,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do
|
|||
end
|
||||
|
||||
test "GET /api/pleroma/emoji/packs", %{conn: conn} do
|
||||
resp = conn |> get("/api/pleroma/emoji/packs") |> json_response(200)
|
||||
resp = conn |> get("/api/pleroma/emoji/packs") |> json_response_and_validate_schema(200)
|
||||
|
||||
shared = resp["test_pack"]
|
||||
assert shared["files"] == %{"blank" => "blank.png"}
|
||||
|
|
@ -46,7 +46,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do
|
|||
resp =
|
||||
conn
|
||||
|> get("/api/pleroma/emoji/packs")
|
||||
|> json_response(200)
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
mock(fn
|
||||
%{method: :get, url: "https://example.com/.well-known/nodeinfo"} ->
|
||||
|
|
@ -60,10 +60,8 @@ defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do
|
|||
end)
|
||||
|
||||
assert admin_conn
|
||||
|> get("/api/pleroma/emoji/packs/remote", %{
|
||||
url: "https://example.com"
|
||||
})
|
||||
|> json_response(200) == resp
|
||||
|> get("/api/pleroma/emoji/packs/remote?url=https://example.com")
|
||||
|> json_response_and_validate_schema(200) == resp
|
||||
end
|
||||
|
||||
test "non shareable instance", %{admin_conn: admin_conn} do
|
||||
|
|
@ -76,8 +74,8 @@ defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do
|
|||
end)
|
||||
|
||||
assert admin_conn
|
||||
|> get("/api/pleroma/emoji/packs/remote", %{url: "https://example.com"})
|
||||
|> json_response(500) == %{
|
||||
|> get("/api/pleroma/emoji/packs/remote?url=https://example.com")
|
||||
|> json_response_and_validate_schema(500) == %{
|
||||
"error" => "The requested instance does not support sharing emoji packs"
|
||||
}
|
||||
end
|
||||
|
|
@ -99,7 +97,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do
|
|||
test "non existing pack", %{conn: conn} do
|
||||
assert conn
|
||||
|> get("/api/pleroma/emoji/packs/test_pack_for_import/archive")
|
||||
|> json_response(:not_found) == %{
|
||||
|> json_response_and_validate_schema(:not_found) == %{
|
||||
"error" => "Pack test_pack_for_import does not exist"
|
||||
}
|
||||
end
|
||||
|
|
@ -107,7 +105,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do
|
|||
test "non downloadable pack", %{conn: conn} do
|
||||
assert conn
|
||||
|> get("/api/pleroma/emoji/packs/test_pack_nonshared/archive")
|
||||
|> json_response(:forbidden) == %{
|
||||
|> json_response_and_validate_schema(:forbidden) == %{
|
||||
"error" =>
|
||||
"Pack test_pack_nonshared cannot be downloaded from this instance, either pack sharing was disabled for this pack or some files are missing"
|
||||
}
|
||||
|
|
@ -132,7 +130,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do
|
|||
} ->
|
||||
conn
|
||||
|> get("/api/pleroma/emoji/packs/test_pack")
|
||||
|> json_response(200)
|
||||
|> json_response_and_validate_schema(200)
|
||||
|> json()
|
||||
|
||||
%{
|
||||
|
|
@ -150,7 +148,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do
|
|||
} ->
|
||||
conn
|
||||
|> get("/api/pleroma/emoji/packs/test_pack_nonshared")
|
||||
|> json_response(200)
|
||||
|> json_response_and_validate_schema(200)
|
||||
|> json()
|
||||
|
||||
%{
|
||||
|
|
@ -161,23 +159,25 @@ defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do
|
|||
end)
|
||||
|
||||
assert admin_conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> post("/api/pleroma/emoji/packs/download", %{
|
||||
url: "https://example.com",
|
||||
name: "test_pack",
|
||||
as: "test_pack2"
|
||||
})
|
||||
|> json_response(200) == "ok"
|
||||
|> json_response_and_validate_schema(200) == "ok"
|
||||
|
||||
assert File.exists?("#{@emoji_path}/test_pack2/pack.json")
|
||||
assert File.exists?("#{@emoji_path}/test_pack2/blank.png")
|
||||
|
||||
assert admin_conn
|
||||
|> delete("/api/pleroma/emoji/packs/test_pack2")
|
||||
|> json_response(200) == "ok"
|
||||
|> json_response_and_validate_schema(200) == "ok"
|
||||
|
||||
refute File.exists?("#{@emoji_path}/test_pack2")
|
||||
|
||||
assert admin_conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> post(
|
||||
"/api/pleroma/emoji/packs/download",
|
||||
%{
|
||||
|
|
@ -186,14 +186,14 @@ defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do
|
|||
as: "test_pack_nonshared2"
|
||||
}
|
||||
)
|
||||
|> json_response(200) == "ok"
|
||||
|> json_response_and_validate_schema(200) == "ok"
|
||||
|
||||
assert File.exists?("#{@emoji_path}/test_pack_nonshared2/pack.json")
|
||||
assert File.exists?("#{@emoji_path}/test_pack_nonshared2/blank.png")
|
||||
|
||||
assert admin_conn
|
||||
|> delete("/api/pleroma/emoji/packs/test_pack_nonshared2")
|
||||
|> json_response(200) == "ok"
|
||||
|> json_response_and_validate_schema(200) == "ok"
|
||||
|
||||
refute File.exists?("#{@emoji_path}/test_pack_nonshared2")
|
||||
end
|
||||
|
|
@ -208,6 +208,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do
|
|||
end)
|
||||
|
||||
assert admin_conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> post(
|
||||
"/api/pleroma/emoji/packs/download",
|
||||
%{
|
||||
|
|
@ -216,7 +217,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do
|
|||
as: "test_pack2"
|
||||
}
|
||||
)
|
||||
|> json_response(500) == %{
|
||||
|> json_response_and_validate_schema(500) == %{
|
||||
"error" => "The requested instance does not support sharing emoji packs"
|
||||
}
|
||||
end
|
||||
|
|
@ -233,10 +234,8 @@ defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do
|
|||
method: :get,
|
||||
url: "https://example.com/api/pleroma/emoji/packs/pack_bad_sha"
|
||||
} ->
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
body: Pleroma.Emoji.Pack.load_pack("pack_bad_sha") |> Jason.encode!()
|
||||
}
|
||||
{:ok, pack} = Pleroma.Emoji.Pack.load_pack("pack_bad_sha")
|
||||
%Tesla.Env{status: 200, body: Jason.encode!(pack)}
|
||||
|
||||
%{
|
||||
method: :get,
|
||||
|
|
@ -249,12 +248,13 @@ defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do
|
|||
end)
|
||||
|
||||
assert admin_conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> post("/api/pleroma/emoji/packs/download", %{
|
||||
url: "https://example.com",
|
||||
name: "pack_bad_sha",
|
||||
as: "pack_bad_sha2"
|
||||
})
|
||||
|> json_response(:internal_server_error) == %{
|
||||
|> json_response_and_validate_schema(:internal_server_error) == %{
|
||||
"error" => "SHA256 for the pack doesn't match the one sent by the server"
|
||||
}
|
||||
end
|
||||
|
|
@ -271,19 +271,18 @@ defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do
|
|||
method: :get,
|
||||
url: "https://example.com/api/pleroma/emoji/packs/test_pack"
|
||||
} ->
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
body: Pleroma.Emoji.Pack.load_pack("test_pack") |> Jason.encode!()
|
||||
}
|
||||
{:ok, pack} = Pleroma.Emoji.Pack.load_pack("test_pack")
|
||||
%Tesla.Env{status: 200, body: Jason.encode!(pack)}
|
||||
end)
|
||||
|
||||
assert admin_conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> post("/api/pleroma/emoji/packs/download", %{
|
||||
url: "https://example.com",
|
||||
name: "test_pack",
|
||||
as: "test_pack2"
|
||||
})
|
||||
|> json_response(:internal_server_error) == %{
|
||||
|> json_response_and_validate_schema(:internal_server_error) == %{
|
||||
"error" =>
|
||||
"The pack was not set as shared and there is no fallback src to download from"
|
||||
}
|
||||
|
|
@ -311,8 +310,9 @@ defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do
|
|||
|
||||
test "for a pack without a fallback source", ctx do
|
||||
assert ctx[:admin_conn]
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> patch("/api/pleroma/emoji/packs/test_pack", %{"metadata" => ctx[:new_data]})
|
||||
|> json_response(200) == ctx[:new_data]
|
||||
|> json_response_and_validate_schema(200) == ctx[:new_data]
|
||||
|
||||
assert Jason.decode!(File.read!(ctx[:pack_file]))["pack"] == ctx[:new_data]
|
||||
end
|
||||
|
|
@ -336,8 +336,9 @@ defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do
|
|||
)
|
||||
|
||||
assert ctx[:admin_conn]
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> patch("/api/pleroma/emoji/packs/test_pack", %{metadata: new_data})
|
||||
|> json_response(200) == new_data_with_sha
|
||||
|> json_response_and_validate_schema(200) == new_data_with_sha
|
||||
|
||||
assert Jason.decode!(File.read!(ctx[:pack_file]))["pack"] == new_data_with_sha
|
||||
end
|
||||
|
|
@ -355,8 +356,9 @@ defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do
|
|||
new_data = Map.put(ctx[:new_data], "fallback-src", "https://nonshared-pack")
|
||||
|
||||
assert ctx[:admin_conn]
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> patch("/api/pleroma/emoji/packs/test_pack", %{metadata: new_data})
|
||||
|> json_response(:bad_request) == %{
|
||||
|> json_response_and_validate_schema(:bad_request) == %{
|
||||
"error" => "The fallback archive does not have all files specified in pack.json"
|
||||
}
|
||||
end
|
||||
|
|
@ -376,6 +378,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do
|
|||
|
||||
test "create shortcode exists", %{admin_conn: admin_conn} do
|
||||
assert admin_conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> post("/api/pleroma/emoji/packs/test_pack/files", %{
|
||||
shortcode: "blank",
|
||||
filename: "dir/blank.png",
|
||||
|
|
@ -384,7 +387,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do
|
|||
path: "#{@emoji_path}/test_pack/blank.png"
|
||||
}
|
||||
})
|
||||
|> json_response(:conflict) == %{
|
||||
|> json_response_and_validate_schema(:conflict) == %{
|
||||
"error" => "An emoji with the \"blank\" shortcode already exists"
|
||||
}
|
||||
end
|
||||
|
|
@ -393,6 +396,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do
|
|||
on_exit(fn -> File.rm_rf!("#{@emoji_path}/test_pack/dir/") end)
|
||||
|
||||
assert admin_conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> post("/api/pleroma/emoji/packs/test_pack/files", %{
|
||||
shortcode: "blank2",
|
||||
filename: "dir/blank.png",
|
||||
|
|
@ -401,17 +405,21 @@ defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do
|
|||
path: "#{@emoji_path}/test_pack/blank.png"
|
||||
}
|
||||
})
|
||||
|> json_response(200) == %{"blank" => "blank.png", "blank2" => "dir/blank.png"}
|
||||
|> json_response_and_validate_schema(200) == %{
|
||||
"blank" => "blank.png",
|
||||
"blank2" => "dir/blank.png"
|
||||
}
|
||||
|
||||
assert File.exists?("#{@emoji_path}/test_pack/dir/blank.png")
|
||||
|
||||
assert admin_conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> patch("/api/pleroma/emoji/packs/test_pack/files", %{
|
||||
shortcode: "blank",
|
||||
new_shortcode: "blank2",
|
||||
new_filename: "dir_2/blank_3.png"
|
||||
})
|
||||
|> json_response(:conflict) == %{
|
||||
|> json_response_and_validate_schema(:conflict) == %{
|
||||
"error" =>
|
||||
"New shortcode \"blank2\" is already used. If you want to override emoji use 'force' option"
|
||||
}
|
||||
|
|
@ -421,6 +429,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do
|
|||
on_exit(fn -> File.rm_rf!("#{@emoji_path}/test_pack/dir_2/") end)
|
||||
|
||||
assert admin_conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> post("/api/pleroma/emoji/packs/test_pack/files", %{
|
||||
shortcode: "blank2",
|
||||
filename: "dir/blank.png",
|
||||
|
|
@ -429,18 +438,22 @@ defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do
|
|||
path: "#{@emoji_path}/test_pack/blank.png"
|
||||
}
|
||||
})
|
||||
|> json_response(200) == %{"blank" => "blank.png", "blank2" => "dir/blank.png"}
|
||||
|> json_response_and_validate_schema(200) == %{
|
||||
"blank" => "blank.png",
|
||||
"blank2" => "dir/blank.png"
|
||||
}
|
||||
|
||||
assert File.exists?("#{@emoji_path}/test_pack/dir/blank.png")
|
||||
|
||||
assert admin_conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> patch("/api/pleroma/emoji/packs/test_pack/files", %{
|
||||
shortcode: "blank2",
|
||||
new_shortcode: "blank3",
|
||||
new_filename: "dir_2/blank_3.png",
|
||||
force: true
|
||||
})
|
||||
|> json_response(200) == %{
|
||||
|> json_response_and_validate_schema(200) == %{
|
||||
"blank" => "blank.png",
|
||||
"blank3" => "dir_2/blank_3.png"
|
||||
}
|
||||
|
|
@ -450,6 +463,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do
|
|||
|
||||
test "with empty filename", %{admin_conn: admin_conn} do
|
||||
assert admin_conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> post("/api/pleroma/emoji/packs/test_pack/files", %{
|
||||
shortcode: "blank2",
|
||||
filename: "",
|
||||
|
|
@ -458,13 +472,14 @@ defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do
|
|||
path: "#{@emoji_path}/test_pack/blank.png"
|
||||
}
|
||||
})
|
||||
|> json_response(:bad_request) == %{
|
||||
|> json_response_and_validate_schema(:bad_request) == %{
|
||||
"error" => "pack name, shortcode or filename cannot be empty"
|
||||
}
|
||||
end
|
||||
|
||||
test "add file with not loaded pack", %{admin_conn: admin_conn} do
|
||||
assert admin_conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> post("/api/pleroma/emoji/packs/not_loaded/files", %{
|
||||
shortcode: "blank2",
|
||||
filename: "dir/blank.png",
|
||||
|
|
@ -473,37 +488,43 @@ defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do
|
|||
path: "#{@emoji_path}/test_pack/blank.png"
|
||||
}
|
||||
})
|
||||
|> json_response(:bad_request) == %{
|
||||
|> json_response_and_validate_schema(:bad_request) == %{
|
||||
"error" => "pack \"not_loaded\" is not found"
|
||||
}
|
||||
end
|
||||
|
||||
test "remove file with not loaded pack", %{admin_conn: admin_conn} do
|
||||
assert admin_conn
|
||||
|> delete("/api/pleroma/emoji/packs/not_loaded/files", %{shortcode: "blank3"})
|
||||
|> json_response(:bad_request) == %{"error" => "pack \"not_loaded\" is not found"}
|
||||
|> delete("/api/pleroma/emoji/packs/not_loaded/files?shortcode=blank3")
|
||||
|> json_response_and_validate_schema(:bad_request) == %{
|
||||
"error" => "pack \"not_loaded\" is not found"
|
||||
}
|
||||
end
|
||||
|
||||
test "remove file with empty shortcode", %{admin_conn: admin_conn} do
|
||||
assert admin_conn
|
||||
|> delete("/api/pleroma/emoji/packs/not_loaded/files", %{shortcode: ""})
|
||||
|> json_response(:bad_request) == %{
|
||||
|> delete("/api/pleroma/emoji/packs/not_loaded/files?shortcode=")
|
||||
|> json_response_and_validate_schema(:bad_request) == %{
|
||||
"error" => "pack name or shortcode cannot be empty"
|
||||
}
|
||||
end
|
||||
|
||||
test "update file with not loaded pack", %{admin_conn: admin_conn} do
|
||||
assert admin_conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> patch("/api/pleroma/emoji/packs/not_loaded/files", %{
|
||||
shortcode: "blank4",
|
||||
new_shortcode: "blank3",
|
||||
new_filename: "dir_2/blank_3.png"
|
||||
})
|
||||
|> json_response(:bad_request) == %{"error" => "pack \"not_loaded\" is not found"}
|
||||
|> json_response_and_validate_schema(:bad_request) == %{
|
||||
"error" => "pack \"not_loaded\" is not found"
|
||||
}
|
||||
end
|
||||
|
||||
test "new with shortcode as file with update", %{admin_conn: admin_conn} do
|
||||
assert admin_conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> post("/api/pleroma/emoji/packs/test_pack/files", %{
|
||||
shortcode: "blank4",
|
||||
filename: "dir/blank.png",
|
||||
|
|
@ -512,24 +533,31 @@ defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do
|
|||
path: "#{@emoji_path}/test_pack/blank.png"
|
||||
}
|
||||
})
|
||||
|> json_response(200) == %{"blank" => "blank.png", "blank4" => "dir/blank.png"}
|
||||
|> json_response_and_validate_schema(200) == %{
|
||||
"blank" => "blank.png",
|
||||
"blank4" => "dir/blank.png"
|
||||
}
|
||||
|
||||
assert File.exists?("#{@emoji_path}/test_pack/dir/blank.png")
|
||||
|
||||
assert admin_conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> patch("/api/pleroma/emoji/packs/test_pack/files", %{
|
||||
shortcode: "blank4",
|
||||
new_shortcode: "blank3",
|
||||
new_filename: "dir_2/blank_3.png"
|
||||
})
|
||||
|> json_response(200) == %{"blank3" => "dir_2/blank_3.png", "blank" => "blank.png"}
|
||||
|> json_response_and_validate_schema(200) == %{
|
||||
"blank3" => "dir_2/blank_3.png",
|
||||
"blank" => "blank.png"
|
||||
}
|
||||
|
||||
refute File.exists?("#{@emoji_path}/test_pack/dir/")
|
||||
assert File.exists?("#{@emoji_path}/test_pack/dir_2/blank_3.png")
|
||||
|
||||
assert admin_conn
|
||||
|> delete("/api/pleroma/emoji/packs/test_pack/files", %{shortcode: "blank3"})
|
||||
|> json_response(200) == %{"blank" => "blank.png"}
|
||||
|> delete("/api/pleroma/emoji/packs/test_pack/files?shortcode=blank3")
|
||||
|> json_response_and_validate_schema(200) == %{"blank" => "blank.png"}
|
||||
|
||||
refute File.exists?("#{@emoji_path}/test_pack/dir_2/")
|
||||
|
||||
|
|
@ -546,11 +574,12 @@ defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do
|
|||
end)
|
||||
|
||||
assert admin_conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> post("/api/pleroma/emoji/packs/test_pack/files", %{
|
||||
shortcode: "blank_url",
|
||||
file: "https://test-blank/blank_url.png"
|
||||
})
|
||||
|> json_response(200) == %{
|
||||
|> json_response_and_validate_schema(200) == %{
|
||||
"blank_url" => "blank_url.png",
|
||||
"blank" => "blank.png"
|
||||
}
|
||||
|
|
@ -564,40 +593,51 @@ defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do
|
|||
on_exit(fn -> File.rm_rf!("#{@emoji_path}/test_pack/shortcode.png") end)
|
||||
|
||||
assert admin_conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> post("/api/pleroma/emoji/packs/test_pack/files", %{
|
||||
file: %Plug.Upload{
|
||||
filename: "shortcode.png",
|
||||
path: "#{Pleroma.Config.get([:instance, :static_dir])}/add/shortcode.png"
|
||||
}
|
||||
})
|
||||
|> json_response(200) == %{"shortcode" => "shortcode.png", "blank" => "blank.png"}
|
||||
|> json_response_and_validate_schema(200) == %{
|
||||
"shortcode" => "shortcode.png",
|
||||
"blank" => "blank.png"
|
||||
}
|
||||
end
|
||||
|
||||
test "remove non existing shortcode in pack.json", %{admin_conn: admin_conn} do
|
||||
assert admin_conn
|
||||
|> delete("/api/pleroma/emoji/packs/test_pack/files", %{shortcode: "blank2"})
|
||||
|> json_response(:bad_request) == %{"error" => "Emoji \"blank2\" does not exist"}
|
||||
|> delete("/api/pleroma/emoji/packs/test_pack/files?shortcode=blank2")
|
||||
|> json_response_and_validate_schema(:bad_request) == %{
|
||||
"error" => "Emoji \"blank2\" does not exist"
|
||||
}
|
||||
end
|
||||
|
||||
test "update non existing emoji", %{admin_conn: admin_conn} do
|
||||
assert admin_conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> patch("/api/pleroma/emoji/packs/test_pack/files", %{
|
||||
shortcode: "blank2",
|
||||
new_shortcode: "blank3",
|
||||
new_filename: "dir_2/blank_3.png"
|
||||
})
|
||||
|> json_response(:bad_request) == %{"error" => "Emoji \"blank2\" does not exist"}
|
||||
|> json_response_and_validate_schema(:bad_request) == %{
|
||||
"error" => "Emoji \"blank2\" does not exist"
|
||||
}
|
||||
end
|
||||
|
||||
test "update with empty shortcode", %{admin_conn: admin_conn} do
|
||||
assert admin_conn
|
||||
|> patch("/api/pleroma/emoji/packs/test_pack/files", %{
|
||||
shortcode: "blank",
|
||||
new_filename: "dir_2/blank_3.png"
|
||||
})
|
||||
|> json_response(:bad_request) == %{
|
||||
"error" => "new_shortcode or new_filename cannot be empty"
|
||||
}
|
||||
assert %{
|
||||
"error" => "Missing field: new_shortcode."
|
||||
} =
|
||||
admin_conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> patch("/api/pleroma/emoji/packs/test_pack/files", %{
|
||||
shortcode: "blank",
|
||||
new_filename: "dir_2/blank_3.png"
|
||||
})
|
||||
|> json_response_and_validate_schema(:bad_request)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -605,7 +645,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do
|
|||
test "creating and deleting a pack", %{admin_conn: admin_conn} do
|
||||
assert admin_conn
|
||||
|> post("/api/pleroma/emoji/packs/test_created")
|
||||
|> json_response(200) == "ok"
|
||||
|> json_response_and_validate_schema(200) == "ok"
|
||||
|
||||
assert File.exists?("#{@emoji_path}/test_created/pack.json")
|
||||
|
||||
|
|
@ -616,7 +656,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do
|
|||
|
||||
assert admin_conn
|
||||
|> delete("/api/pleroma/emoji/packs/test_created")
|
||||
|> json_response(200) == "ok"
|
||||
|> json_response_and_validate_schema(200) == "ok"
|
||||
|
||||
refute File.exists?("#{@emoji_path}/test_created/pack.json")
|
||||
end
|
||||
|
|
@ -629,7 +669,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do
|
|||
|
||||
assert admin_conn
|
||||
|> post("/api/pleroma/emoji/packs/test_created")
|
||||
|> json_response(:conflict) == %{
|
||||
|> json_response_and_validate_schema(:conflict) == %{
|
||||
"error" => "A pack named \"test_created\" already exists"
|
||||
}
|
||||
|
||||
|
|
@ -639,20 +679,26 @@ defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do
|
|||
test "with empty name", %{admin_conn: admin_conn} do
|
||||
assert admin_conn
|
||||
|> post("/api/pleroma/emoji/packs/ ")
|
||||
|> json_response(:bad_request) == %{"error" => "pack name cannot be empty"}
|
||||
|> json_response_and_validate_schema(:bad_request) == %{
|
||||
"error" => "pack name cannot be empty"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
test "deleting nonexisting pack", %{admin_conn: admin_conn} do
|
||||
assert admin_conn
|
||||
|> delete("/api/pleroma/emoji/packs/non_existing")
|
||||
|> json_response(:not_found) == %{"error" => "Pack non_existing does not exist"}
|
||||
|> json_response_and_validate_schema(:not_found) == %{
|
||||
"error" => "Pack non_existing does not exist"
|
||||
}
|
||||
end
|
||||
|
||||
test "deleting with empty name", %{admin_conn: admin_conn} do
|
||||
assert admin_conn
|
||||
|> delete("/api/pleroma/emoji/packs/ ")
|
||||
|> json_response(:bad_request) == %{"error" => "pack name cannot be empty"}
|
||||
|> json_response_and_validate_schema(:bad_request) == %{
|
||||
"error" => "pack name cannot be empty"
|
||||
}
|
||||
end
|
||||
|
||||
test "filesystem import", %{admin_conn: admin_conn, conn: conn} do
|
||||
|
|
@ -661,15 +707,15 @@ defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do
|
|||
File.rm!("#{@emoji_path}/test_pack_for_import/pack.json")
|
||||
end)
|
||||
|
||||
resp = conn |> get("/api/pleroma/emoji/packs") |> json_response(200)
|
||||
resp = conn |> get("/api/pleroma/emoji/packs") |> json_response_and_validate_schema(200)
|
||||
|
||||
refute Map.has_key?(resp, "test_pack_for_import")
|
||||
|
||||
assert admin_conn
|
||||
|> get("/api/pleroma/emoji/packs/import")
|
||||
|> json_response(200) == ["test_pack_for_import"]
|
||||
|> json_response_and_validate_schema(200) == ["test_pack_for_import"]
|
||||
|
||||
resp = conn |> get("/api/pleroma/emoji/packs") |> json_response(200)
|
||||
resp = conn |> get("/api/pleroma/emoji/packs") |> json_response_and_validate_schema(200)
|
||||
assert resp["test_pack_for_import"]["files"] == %{"blank" => "blank.png"}
|
||||
|
||||
File.rm!("#{@emoji_path}/test_pack_for_import/pack.json")
|
||||
|
|
@ -686,9 +732,9 @@ defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do
|
|||
|
||||
assert admin_conn
|
||||
|> get("/api/pleroma/emoji/packs/import")
|
||||
|> json_response(200) == ["test_pack_for_import"]
|
||||
|> json_response_and_validate_schema(200) == ["test_pack_for_import"]
|
||||
|
||||
resp = conn |> get("/api/pleroma/emoji/packs") |> json_response(200)
|
||||
resp = conn |> get("/api/pleroma/emoji/packs") |> json_response_and_validate_schema(200)
|
||||
|
||||
assert resp["test_pack_for_import"]["files"] == %{
|
||||
"blank" => "blank.png",
|
||||
|
|
@ -712,19 +758,23 @@ defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do
|
|||
} =
|
||||
conn
|
||||
|> get("/api/pleroma/emoji/packs/test_pack")
|
||||
|> json_response(200)
|
||||
|> json_response_and_validate_schema(200)
|
||||
end
|
||||
|
||||
test "non existing pack", %{conn: conn} do
|
||||
assert conn
|
||||
|> get("/api/pleroma/emoji/packs/non_existing")
|
||||
|> json_response(:not_found) == %{"error" => "Pack non_existing does not exist"}
|
||||
|> json_response_and_validate_schema(:not_found) == %{
|
||||
"error" => "Pack non_existing does not exist"
|
||||
}
|
||||
end
|
||||
|
||||
test "error name", %{conn: conn} do
|
||||
assert conn
|
||||
|> get("/api/pleroma/emoji/packs/ ")
|
||||
|> json_response(:bad_request) == %{"error" => "pack name cannot be empty"}
|
||||
|> json_response_and_validate_schema(:bad_request) == %{
|
||||
"error" => "pack name cannot be empty"
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -16,9 +16,12 @@ defmodule Pleroma.Web.PleromaAPI.MascotControllerTest do
|
|||
filename: "sound.mp3"
|
||||
}
|
||||
|
||||
ret_conn = put(conn, "/api/v1/pleroma/mascot", %{"file" => non_image_file})
|
||||
ret_conn =
|
||||
conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> put("/api/v1/pleroma/mascot", %{"file" => non_image_file})
|
||||
|
||||
assert json_response(ret_conn, 415)
|
||||
assert json_response_and_validate_schema(ret_conn, 415)
|
||||
|
||||
file = %Plug.Upload{
|
||||
content_type: "image/jpg",
|
||||
|
|
@ -26,9 +29,12 @@ defmodule Pleroma.Web.PleromaAPI.MascotControllerTest do
|
|||
filename: "an_image.jpg"
|
||||
}
|
||||
|
||||
conn = put(conn, "/api/v1/pleroma/mascot", %{"file" => file})
|
||||
conn =
|
||||
conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> put("/api/v1/pleroma/mascot", %{"file" => file})
|
||||
|
||||
assert %{"id" => _, "type" => image} = json_response(conn, 200)
|
||||
assert %{"id" => _, "type" => image} = json_response_and_validate_schema(conn, 200)
|
||||
end
|
||||
|
||||
test "mascot retrieving" do
|
||||
|
|
@ -37,7 +43,7 @@ defmodule Pleroma.Web.PleromaAPI.MascotControllerTest do
|
|||
# When user hasn't set a mascot, we should just get pleroma tan back
|
||||
ret_conn = get(conn, "/api/v1/pleroma/mascot")
|
||||
|
||||
assert %{"url" => url} = json_response(ret_conn, 200)
|
||||
assert %{"url" => url} = json_response_and_validate_schema(ret_conn, 200)
|
||||
assert url =~ "pleroma-fox-tan-smol"
|
||||
|
||||
# When a user sets their mascot, we should get that back
|
||||
|
|
@ -47,9 +53,12 @@ defmodule Pleroma.Web.PleromaAPI.MascotControllerTest do
|
|||
filename: "an_image.jpg"
|
||||
}
|
||||
|
||||
ret_conn = put(conn, "/api/v1/pleroma/mascot", %{"file" => file})
|
||||
ret_conn =
|
||||
conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> put("/api/v1/pleroma/mascot", %{"file" => file})
|
||||
|
||||
assert json_response(ret_conn, 200)
|
||||
assert json_response_and_validate_schema(ret_conn, 200)
|
||||
|
||||
user = User.get_cached_by_id(user.id)
|
||||
|
||||
|
|
@ -58,7 +67,7 @@ defmodule Pleroma.Web.PleromaAPI.MascotControllerTest do
|
|||
|> assign(:user, user)
|
||||
|> get("/api/v1/pleroma/mascot")
|
||||
|
||||
assert %{"url" => url, "type" => "image"} = json_response(conn, 200)
|
||||
assert %{"url" => url, "type" => "image"} = json_response_and_validate_schema(conn, 200)
|
||||
assert url =~ "an_image"
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -12,14 +12,16 @@ defmodule Pleroma.Web.PleromaAPI.ScrobbleControllerTest do
|
|||
%{conn: conn} = oauth_access(["write"])
|
||||
|
||||
conn =
|
||||
post(conn, "/api/v1/pleroma/scrobble", %{
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/v1/pleroma/scrobble", %{
|
||||
"title" => "lain radio episode 1",
|
||||
"artist" => "lain",
|
||||
"album" => "lain radio",
|
||||
"length" => "180000"
|
||||
})
|
||||
|
||||
assert %{"title" => "lain radio episode 1"} = json_response(conn, 200)
|
||||
assert %{"title" => "lain radio episode 1"} = json_response_and_validate_schema(conn, 200)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -29,28 +31,28 @@ defmodule Pleroma.Web.PleromaAPI.ScrobbleControllerTest do
|
|||
|
||||
{:ok, _activity} =
|
||||
CommonAPI.listen(user, %{
|
||||
"title" => "lain radio episode 1",
|
||||
"artist" => "lain",
|
||||
"album" => "lain radio"
|
||||
title: "lain radio episode 1",
|
||||
artist: "lain",
|
||||
album: "lain radio"
|
||||
})
|
||||
|
||||
{:ok, _activity} =
|
||||
CommonAPI.listen(user, %{
|
||||
"title" => "lain radio episode 2",
|
||||
"artist" => "lain",
|
||||
"album" => "lain radio"
|
||||
title: "lain radio episode 2",
|
||||
artist: "lain",
|
||||
album: "lain radio"
|
||||
})
|
||||
|
||||
{:ok, _activity} =
|
||||
CommonAPI.listen(user, %{
|
||||
"title" => "lain radio episode 3",
|
||||
"artist" => "lain",
|
||||
"album" => "lain radio"
|
||||
title: "lain radio episode 3",
|
||||
artist: "lain",
|
||||
album: "lain radio"
|
||||
})
|
||||
|
||||
conn = get(conn, "/api/v1/pleroma/accounts/#{user.id}/scrobbles")
|
||||
|
||||
result = json_response(conn, 200)
|
||||
result = json_response_and_validate_schema(conn, 200)
|
||||
|
||||
assert length(result) == 3
|
||||
end
|
||||
|
|
|
|||
20
test/web/pleroma_api/views/scrobble_view_test.exs
Normal file
20
test/web/pleroma_api/views/scrobble_view_test.exs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.PleromaAPI.StatusViewTest do
|
||||
use Pleroma.DataCase
|
||||
|
||||
alias Pleroma.Web.PleromaAPI.ScrobbleView
|
||||
|
||||
import Pleroma.Factory
|
||||
|
||||
test "successfully renders a Listen activity (pleroma extension)" do
|
||||
listen_activity = insert(:listen)
|
||||
|
||||
status = ScrobbleView.render("show.json", activity: listen_activity)
|
||||
|
||||
assert status.length == listen_activity.data["object"]["length"]
|
||||
assert status.title == listen_activity.data["object"]["title"]
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue