From b31a934a804aed3f35442ceafe2080b0955e7317 Mon Sep 17 00:00:00 2001 From: dcc Date: Wed, 15 May 2024 00:57:23 -0700 Subject: total rebase --- .../pleroma/web/common_api/activity_draft_test.exs | 33 ++++++++++++++++++++++ test/pleroma/web/common_api/utils_test.exs | 17 +++++++---- 2 files changed, 44 insertions(+), 6 deletions(-) create mode 100644 test/pleroma/web/common_api/activity_draft_test.exs mode change 100755 => 100644 test/pleroma/web/common_api/utils_test.exs (limited to 'test/pleroma/web/common_api') diff --git a/test/pleroma/web/common_api/activity_draft_test.exs b/test/pleroma/web/common_api/activity_draft_test.exs new file mode 100644 index 0000000..02bc6cf --- /dev/null +++ b/test/pleroma/web/common_api/activity_draft_test.exs @@ -0,0 +1,33 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2021 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + +defmodule Pleroma.Web.CommonAPI.ActivityDraftTest do + use Pleroma.DataCase + + alias Pleroma.Web.CommonAPI + alias Pleroma.Web.CommonAPI.ActivityDraft + + import Pleroma.Factory + + test "create/2 with a quote post" do + user = insert(:user) + another_user = insert(:user) + + {:ok, direct} = CommonAPI.post(user, %{status: ".", visibility: "direct"}) + {:ok, private} = CommonAPI.post(user, %{status: ".", visibility: "private"}) + {:ok, unlisted} = CommonAPI.post(user, %{status: ".", visibility: "unlisted"}) + {:ok, local} = CommonAPI.post(user, %{status: ".", visibility: "local"}) + {:ok, public} = CommonAPI.post(user, %{status: ".", visibility: "public"}) + + {:error, _} = ActivityDraft.create(user, %{status: "nice", quote_id: direct.id}) + {:ok, _} = ActivityDraft.create(user, %{status: "nice", quote_id: private.id}) + {:error, _} = ActivityDraft.create(another_user, %{status: "nice", quote_id: private.id}) + {:ok, _} = ActivityDraft.create(user, %{status: "nice", quote_id: unlisted.id}) + {:ok, _} = ActivityDraft.create(another_user, %{status: "nice", quote_id: unlisted.id}) + {:ok, _} = ActivityDraft.create(user, %{status: "nice", quote_id: local.id}) + {:ok, _} = ActivityDraft.create(another_user, %{status: "nice", quote_id: local.id}) + {:ok, _} = ActivityDraft.create(user, %{status: "nice", quote_id: public.id}) + {:ok, _} = ActivityDraft.create(another_user, %{status: "nice", quote_id: public.id}) + end +end diff --git a/test/pleroma/web/common_api/utils_test.exs b/test/pleroma/web/common_api/utils_test.exs old mode 100755 new mode 100644 index c52d3e9..27b1da1 --- a/test/pleroma/web/common_api/utils_test.exs +++ b/test/pleroma/web/common_api/utils_test.exs @@ -200,7 +200,7 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do {result, _, []} = Utils.format_input(code, "text/markdown") assert result == - ~s[

@mario @luigi yo what’s up?

] + ~s[

@mario @luigi yo what's up?

] end test "remote mentions" do @@ -211,7 +211,7 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do {result, _, []} = Utils.format_input(code, "text/markdown") assert result == - ~s[

@mario @luigi yo what’s up?

] + ~s[

@mario @luigi yo what's up?

] end test "raw HTML" do @@ -229,7 +229,7 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do test "blockquote" do code = ~s[> whoms't are you quoting?] {result, [], []} = Utils.format_input(code, "text/markdown") - assert result == "

whoms’t are you quoting?

" + assert result == "

whoms't are you quoting?

" end test "code" do @@ -593,7 +593,7 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do test "returns list attachments with desc" do user = insert(:user) - object = insert(:note, %{user: user}) + object = insert(:attachment, %{user: user}) desc = Jason.encode!(%{object.id => "test-desc"}) assert Utils.attachments_from_ids_descs(["#{object.id}", "34"], desc, user) == [ @@ -605,7 +605,7 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do describe "attachments_from_ids/2" do test "returns attachments with descs" do user = insert(:user) - object = insert(:note, %{user: user}) + object = insert(:attachment, %{user: user}) desc = Jason.encode!(%{object.id => "test-desc"}) assert Utils.attachments_from_ids( @@ -621,7 +621,7 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do test "returns attachments without descs" do user = insert(:user) - object = insert(:note, %{user: user}) + object = insert(:attachment, %{user: user}) assert Utils.attachments_from_ids(%{media_ids: ["#{object.id}"]}, user) == [object.data] end @@ -637,6 +637,11 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do assert Utils.attachments_from_ids(%{media_ids: ["#{object.id}"]}, user2) == [] end + + test "checks that the object is of upload type" do + object = insert(:note) + assert Utils.attachments_from_ids(%{media_ids: ["#{object.id}"]}, nil) == [] + end end describe "maybe_add_list_data/3" do -- cgit v1.2.3