pleroma/test/pleroma/web/pleroma_api/controllers/report_controller_test.exs
FloatingGhost 98cb255d12 Support elixir1.15
OTP builds to 1.15

Changelog entry

Ensure policies are fully loaded

Fix :warn

use main branch for linkify

Fix warn in tests

Migrations for phoenix 1.17

Revert "Migrations for phoenix 1.17"

This reverts commit 6a3b2f15b74ea5e33150529385215b7a531f3999.

Oban upgrade

Add default empty whitelist

mix format

limit test to amd64

OTP 26 tests for 1.15

use OTP_VERSION tag

baka

just 1.15

Massive deps update

Update locale, deps

Mix format

shell????

multiline???

?

max cases 1

use assert_recieve

don't put_env in async tests

don't async conn/fs tests

mix format

FIx some uploader issues

Fix tests
2023-08-03 17:44:09 +01:00

81 lines
2.6 KiB
Elixir

# Pleroma: A lightweight social networking server
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.PleromaAPI.ReportControllerTest do
use Pleroma.Web.ConnCase, async: false
import Pleroma.Factory
alias Pleroma.Web.CommonAPI
describe "GET /api/v0/pleroma/reports" do
test "returns list of own reports" do
%{conn: reporter_conn, user: reporter} = oauth_access(["read:reports"])
%{conn: reported_conn, user: reported} = oauth_access(["read:reports"])
activity = insert(:note_activity, user: reported)
{:ok, %{id: report_id}} =
CommonAPI.report(reporter, %{
account_id: reported.id,
comment: "You stole my sandwich!",
status_ids: [activity.id]
})
assert reported_response =
reported_conn
|> get("/api/v0/pleroma/reports")
|> json_response_and_validate_schema(:ok)
assert reported_response == %{"reports" => [], "total" => 0}
assert reporter_response =
reporter_conn
|> get("/api/v0/pleroma/reports")
|> json_response_and_validate_schema(:ok)
assert %{"reports" => [report], "total" => 1} = reporter_response
assert report["id"] == report_id
refute report["notes"]
end
end
describe "GET /api/v0/pleroma/reports/:id" do
test "returns report by its id" do
%{conn: reporter_conn, user: reporter} = oauth_access(["read:reports"])
%{conn: reported_conn, user: reported} = oauth_access(["read:reports"])
activity = insert(:note_activity, user: reported)
{:ok, %{id: report_id}} =
CommonAPI.report(reporter, %{
account_id: reported.id,
comment: "You stole my sandwich!",
status_ids: [activity.id]
})
assert reported_conn
|> get("/api/v0/pleroma/reports/#{report_id}")
|> json_response_and_validate_schema(:not_found)
assert response =
reporter_conn
|> get("/api/v0/pleroma/reports/#{report_id}")
|> json_response_and_validate_schema(:ok)
assert response["id"] == report_id
refute response["notes"]
end
test "returns 404 when report id is invalid" do
%{conn: conn, user: _user} = oauth_access(["read:reports"])
assert response =
conn
|> get("/api/v0/pleroma/reports/0")
|> json_response_and_validate_schema(:not_found)
assert response == %{"error" => "Record not found"}
end
end
end