Merge branch 'status-visibility-count-stats' into 'develop'
[akkoma] / test / web / admin_api / admin_api_controller_test.exs
index 908ef4d37f129b60b9c75f6217066f3e68ee85e5..0b79e4c5c116c9ba1d0a6a2df1d8a03bbeab0dde 100644 (file)
@@ -3545,6 +3545,25 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
     assert String.starts_with?(child["group"], ":")
     assert child["description"]
   end
+
+  describe "/api/pleroma/admin/stats" do
+    test "status visibility count", %{conn: conn} do
+      admin = insert(:user, is_admin: true)
+      user = insert(:user)
+      CommonAPI.post(user, %{"visibility" => "public", "status" => "hey"})
+      CommonAPI.post(user, %{"visibility" => "unlisted", "status" => "hey"})
+      CommonAPI.post(user, %{"visibility" => "unlisted", "status" => "hey"})
+
+      response =
+        conn
+        |> assign(:user, admin)
+        |> get("/api/pleroma/admin/stats")
+        |> json_response(200)
+
+      assert %{"direct" => 0, "private" => 0, "public" => 1, "unlisted" => 2} =
+               response["status_visibility"]
+    end
+  end
 end
 
 # Needed for testing