1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.MastodonAPI.SuggestionControllerTest do
6 use Pleroma.Web.ConnCase, async: true
7 alias Pleroma.UserRelationship
10 setup do: oauth_access(["read", "write"])
12 test "returns empty result", %{conn: conn} do
15 |> get("/api/v1/suggestions")
16 |> json_response_and_validate_schema(200)
21 test "returns v2 suggestions", %{conn: conn} do
22 %{id: user_id} = insert(:user, is_suggested: true)
26 |> get("/api/v2/suggestions")
27 |> json_response_and_validate_schema(200)
29 assert [%{"source" => "staff", "account" => %{"id" => ^user_id}}] = res
32 test "dismiss suggestion", %{conn: conn, user: source} do
33 target = insert(:user, is_suggested: true)
37 |> delete("/api/v1/suggestions/#{target.id}")
38 |> json_response_and_validate_schema(200)
41 assert UserRelationship.exists?(:suggestion_dismiss, source, target)