summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authortusooa <tusooa@kazv.moe>2022-11-12 17:55:50 +0000
committertusooa <tusooa@kazv.moe>2022-11-12 17:55:50 +0000
commit1b0e47b79b38468f2b9a52d24dfc42830cc46c0f (patch)
tree07cb5a39eb46ce474da955fe91afb9536f99640d /test
parent7c8618dc9ad589d1e7b335dde85f7e722ce5ff6f (diff)
parente3e68b93774ffb3b45e395e7ea5cea2467b4395f (diff)
Merge branch 'from/upstream-develop/tusooa/no-strip-report' into 'develop'
Give admin the choice to not strip reported statuses Closes #2887 See merge request pleroma/pleroma!3773
Diffstat (limited to 'test')
-rw-r--r--test/pleroma/web/admin_api/controllers/report_controller_test.exs26
-rw-r--r--test/pleroma/web/common_api_test.exs26
2 files changed, 52 insertions, 0 deletions
diff --git a/test/pleroma/web/admin_api/controllers/report_controller_test.exs b/test/pleroma/web/admin_api/controllers/report_controller_test.exs
index 30dcb87e2..164cbb95b 100644
--- a/test/pleroma/web/admin_api/controllers/report_controller_test.exs
+++ b/test/pleroma/web/admin_api/controllers/report_controller_test.exs
@@ -54,6 +54,32 @@ defmodule Pleroma.Web.AdminAPI.ReportControllerTest do
assert notes["content"] == "this is an admin note"
end
+ test "renders reported content even if the status is deleted", %{conn: conn} do
+ [reporter, target_user] = insert_pair(:user)
+ activity = insert(:note_activity, user: target_user)
+ activity = Activity.normalize(activity)
+
+ {:ok, %{id: report_id}} =
+ CommonAPI.report(reporter, %{
+ account_id: target_user.id,
+ comment: "I feel offended",
+ status_ids: [activity.id]
+ })
+
+ CommonAPI.delete(activity.id, target_user)
+
+ response =
+ conn
+ |> get("/api/pleroma/admin/reports/#{report_id}")
+ |> json_response_and_validate_schema(:ok)
+
+ assert response["id"] == report_id
+
+ assert [status] = response["statuses"]
+ assert activity.data["id"] == status["uri"]
+ assert activity.object.data["content"] == status["content"]
+ end
+
test "returns 404 when report id is invalid", %{conn: conn} do
conn = get(conn, "/api/pleroma/admin/reports/test")
diff --git a/test/pleroma/web/common_api_test.exs b/test/pleroma/web/common_api_test.exs
index ee01548f9..4dc0d9cbe 100644
--- a/test/pleroma/web/common_api_test.exs
+++ b/test/pleroma/web/common_api_test.exs
@@ -1154,6 +1154,32 @@ defmodule Pleroma.Web.CommonAPITest do
assert activity_id == activity.data["id"]
end
+ test "updates report state, don't strip when report_strip_status is false" do
+ clear_config([:instance, :report_strip_status], false)
+
+ [reporter, target_user] = insert_pair(:user)
+ activity = insert(:note_activity, user: target_user)
+
+ {:ok, %Activity{id: report_id, data: report_data}} =
+ CommonAPI.report(reporter, %{
+ account_id: target_user.id,
+ comment: "I feel offended",
+ status_ids: [activity.id]
+ })
+
+ {:ok, report} = CommonAPI.update_report_state(report_id, "resolved")
+
+ assert report.data["state"] == "resolved"
+
+ [reported_user, reported_activity] = report.data["object"]
+
+ assert reported_user == target_user.ap_id
+ assert is_map(reported_activity)
+
+ assert reported_activity["content"] ==
+ report_data["object"] |> Enum.at(1) |> Map.get("content")
+ end
+
test "does not update report state when state is unsupported" do
[reporter, target_user] = insert_pair(:user)
activity = insert(:note_activity, user: target_user)