Implement report notes destruction
[akkoma] / test / web / admin_api / admin_api_controller_test.exs
index 453c290e4cf0b4a61f9f0b61f1e1a8562ecc8e56..fda47300cc6a257c2a6d1ca7b43e76bd85d1db8f 100644 (file)
@@ -10,6 +10,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
   alias Pleroma.HTML
   alias Pleroma.ModerationLog
   alias Pleroma.Repo
+  alias Pleroma.ReportNote
   alias Pleroma.Tests.ObanHelpers
   alias Pleroma.User
   alias Pleroma.UserInviteToken
@@ -2940,11 +2941,13 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
     end
 
     test "it creates report note", %{admin_id: admin_id, report_id: report_id} do
+      [note, _] = Repo.all(ReportNote)
+
       assert %{
                activity_id: ^report_id,
                content: "this is disgusting!",
                user_id: ^admin_id
-             } = Repo.one(Pleroma.ReportNote)
+             } = note
     end
 
     test "it returns reports with notes", %{admin: admin} do
@@ -2959,8 +2962,21 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
 
       assert note["user"]["nickname"] == admin.nickname
       assert note["content"] == "this is disgusting!"
+      assert note["created_at"]
       assert response["total"] == 1
     end
+
+    test "it deletes the note", %{admin: admin, report_id: report_id} do
+      assert ReportNote |> Repo.all() |> length() == 2
+
+      [note, _] = Repo.all(ReportNote)
+
+      build_conn()
+      |> assign(:user, admin)
+      |> delete("/api/pleroma/admin/reports/#{report_id}/notes/#{note.id}")
+
+      assert ReportNote |> Repo.all() |> length() == 1
+    end
   end
 end