diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/pleroma/web/mastodon_api/controllers/account_controller_test.exs | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/test/pleroma/web/mastodon_api/controllers/account_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/account_controller_test.exs index 374e2048a..828ebddd6 100644 --- a/test/pleroma/web/mastodon_api/controllers/account_controller_test.exs +++ b/test/pleroma/web/mastodon_api/controllers/account_controller_test.exs @@ -1838,4 +1838,57 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do |> get("/api/v1/accounts/relationships?id=#{other_user.id}") |> json_response_and_validate_schema(200) end + + describe "account endorsements" do + setup do: oauth_access(["read:accounts", "write:accounts", "write:follows"]) + + setup do: clear_config([:instance, :max_endorsed_users], 1) + + test "pin account", %{user: user, conn: conn} do + %{id: id1} = insert(:user) + + conn + |> put_req_header("content-type", "application/json") + |> post("/api/v1/accounts/#{id1}/follow") + |> json_response_and_validate_schema(200) + + assert %{"id" => ^id1, "endorsed" => true} = + conn + |> put_req_header("content-type", "application/json") + |> post("/api/v1/accounts/#{id1}/pin") + |> json_response_and_validate_schema(200) + + assert [%{"id" => ^id1}] = + conn + |> put_req_header("content-type", "application/json") + |> get("/api/v1/endorsements") + |> json_response_and_validate_schema(200) + end + + test "max pinned accounts", %{user: user, conn: conn} do + %{id: id1} = insert(:user) + %{id: id2} = insert(:user) + + conn + |> put_req_header("content-type", "application/json") + |> post("/api/v1/accounts/#{id1}/follow") + |> json_response_and_validate_schema(200) + + conn + |> put_req_header("content-type", "application/json") + |> post("/api/v1/accounts/#{id2}/follow") + |> json_response_and_validate_schema(200) + + conn + |> put_req_header("content-type", "application/json") + |> post("/api/v1/accounts/#{id1}/pin") + |> json_response_and_validate_schema(200) + + assert %{"error" => "You have already pinned the maximum number of users"} = + conn + |> assign(:user, user) + |> post("/api/v1/accounts/#{id2}/pin") + |> json_response_and_validate_schema(400) + end + end end |