1 defmodule Pleroma.Web.MastodonAPI.DirectoryControllerTest do
2 use Pleroma.Web.ConnCase, async: true
3 alias Pleroma.Web.CommonAPI
6 test "GET /api/v1/directory with :profile_directory disabled returns empty array", %{conn: conn} do
7 clear_config([:instance, :profile_directory], false)
9 insert(:user, is_discoverable: true)
10 insert(:user, is_discoverable: true)
14 |> get("/api/v1/directory")
15 |> json_response_and_validate_schema(200)
20 test "GET /api/v1/directory returns discoverable users only", %{conn: conn} do
21 %{id: user_id} = insert(:user, is_discoverable: true)
22 insert(:user, is_discoverable: false)
26 |> get("/api/v1/directory")
27 |> json_response_and_validate_schema(200)
29 assert [%{"id" => ^user_id}] = result
32 test "GET /api/v1/directory returns users sorted by most recent statuses", %{conn: conn} do
33 insert(:user, is_discoverable: true)
34 %{id: user_id} = user = insert(:user, is_discoverable: true)
35 insert(:user, is_discoverable: true)
37 {:ok, _activity} = CommonAPI.post(user, %{status: "yay i'm discoverable"})
41 |> get("/api/v1/directory?order=active")
42 |> json_response_and_validate_schema(200)
44 assert [%{"id" => ^user_id} | _tail] = result