Merge branch 'outbox_pagination' into 'develop'
[akkoma] / test / web / mastodon_api / mastodon_api_controller_test.exs
index c9bce14392f5f3059d0819dc15e5d2dd9ee94e5e..35a0d3fe157f86b96ae6ce1ae182b8d697f07a94 100644 (file)
@@ -13,6 +13,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest 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
@@ -295,7 +296,9 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
         conn
         |> post("api/v1/statuses", %{"status" => content, "visibility" => "direct"})
 
-      assert %{"id" => id, "visibility" => "direct"} = json_response(conn, 200)
+      assert %{"id" => id} = response = json_response(conn, 200)
+      assert response["visibility"] == "direct"
+      assert response["pleroma"]["direct_conversation_id"]
       assert activity = Activity.get_by_id(id)
       assert activity.recipients == [user2.ap_id, conn.assigns[:user].ap_id]
       assert activity.data["to"] == [user2.ap_id]
@@ -751,7 +754,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
     query_string = "ids[]=#{id1}&ids[]=#{id2}"
     conn = get(conn, "/api/v1/statuses/?#{query_string}")
 
-    assert [%{"id" => ^id1}, %{"id" => ^id2}] = json_response(conn, :ok)
+    assert [%{"id" => ^id1}, %{"id" => ^id2}] = Enum.sort_by(json_response(conn, :ok), & &1["id"])
   end
 
   describe "deleting a status" do
@@ -3759,7 +3762,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
       assert id == other_user.id
     end
 
-    test "requires authentifucation for private posts", %{conn: conn, user: user} do
+    test "requires authentification for private posts", %{conn: conn, user: user} do
       other_user = insert(:user)
 
       {:ok, activity} =
@@ -3856,7 +3859,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
       assert id == other_user.id
     end
 
-    test "requires authentifucation for private posts", %{conn: conn, user: user} do
+    test "requires authentification for private posts", %{conn: conn, user: user} do
       other_user = insert(:user)
 
       {:ok, activity} =
@@ -3897,6 +3900,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
     end
 
     test "it sends an email to user", %{user: user} do
+      ObanHelpers.perform_all()
       token_record = Repo.get_by(Pleroma.PasswordResetToken, user_id: user.id)
 
       email = Pleroma.Emails.UserEmail.password_reset_email(user, token_record.token)
@@ -3957,6 +3961,8 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
       |> post("/api/v1/pleroma/accounts/confirmation_resend?email=#{user.email}")
       |> json_response(:no_content)
 
+      ObanHelpers.perform_all()
+
       email = Pleroma.Emails.UserEmail.account_confirmation_email(user)
       notify_email = Config.get([:instance, :notify_email])
       instance_name = Config.get([:instance, :name])