v2 Suggestions: rudimentary API response
[akkoma] / test / pleroma / web / mastodon_api / controllers / suggestion_controller_test.exs
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.MastodonAPI.SuggestionControllerTest do
6 use Pleroma.Web.ConnCase, async: true
7 import Pleroma.Factory
8
9 setup do: oauth_access(["read"])
10
11 test "returns empty result", %{conn: conn} do
12 res =
13 conn
14 |> get("/api/v1/suggestions")
15 |> json_response_and_validate_schema(200)
16
17 assert res == []
18 end
19
20 test "returns v2 suggestions", %{conn: conn} do
21 %{id: user_id} = insert(:user, is_suggested: true)
22
23 res =
24 conn
25 |> get("/api/v2/suggestions")
26 |> json_response_and_validate_schema(200)
27
28 assert [%{"source" => "staff", "account" => %{"id" => ^user_id}}] = res
29 end
30 end