added test fo Pleroma.Web.MastodonAPI.StatusController
[akkoma] / test / web / mastodon_api / controllers / status_controller_test.exs
index 2de2725e014023ae17e1f15068f2b9afc6c93931..7b52abdce1a8f1ee7129f4083c89fa26474880ea 100644 (file)
@@ -12,6 +12,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
   alias Pleroma.Object
   alias Pleroma.Repo
   alias Pleroma.ScheduledActivity
+  alias Pleroma.Tests.ObanHelpers
   alias Pleroma.User
   alias Pleroma.Web.ActivityPub.ActivityPub
   alias Pleroma.Web.CommonAPI
@@ -29,6 +30,34 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
       [conn: conn]
     end
 
+    test "posting a status and checks reblog count after perform  all backroud job", %{conn: conn} do
+      Pleroma.Config.put([:instance, :federating], true)
+      Pleroma.Config.get([:instance, :allow_relay], true)
+      user = insert(:user)
+
+      response =
+        conn
+        |> assign(:user, user)
+        |> post("api/v1/statuses", %{
+          "content_type" => "text/plain",
+          "source" => "Pleroma FE",
+          "status" => "Hello world",
+          "visibility" => "public"
+        })
+        |> json_response(200)
+
+      assert response["reblogs_count"] == 0
+      ObanHelpers.perform_all()
+
+      response =
+        conn
+        |> assign(:user, user)
+        |> get("api/v1/statuses/#{response["id"]}", %{})
+        |> json_response(200)
+
+      assert response["reblogs_count"] == 0
+    end
+
     test "posting a status", %{conn: conn} do
       idempotency_key = "Pikachu rocks!"