From 739dbfff6f21c56acd68d75fe4b5b82683fe97ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Fri, 17 Nov 2023 23:44:07 +0100 Subject: [PATCH] Update/fix test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- .../web/activity_pub/transmogrifier.ex | 4 +- .../web/mastodon_api/views/status_view.ex | 2 - test/fixtures/fep-e232.json | 53 ++++++++++--------- .../notification_backfill_test.exs | 5 ++ .../web/activity_pub/transmogrifier_test.exs | 41 -------------- test/pleroma/web/common_api_test.exs | 2 + .../mastodon_api/views/status_view_test.exs | 5 +- .../notification_controller_test.exs | 5 ++ test/pleroma/web/push/impl_test.exs | 2 + 9 files changed, 48 insertions(+), 71 deletions(-) diff --git a/lib/pleroma/web/activity_pub/transmogrifier.ex b/lib/pleroma/web/activity_pub/transmogrifier.ex index 3a18c84b43..b904a6fdcb 100644 --- a/lib/pleroma/web/activity_pub/transmogrifier.ex +++ b/lib/pleroma/web/activity_pub/transmogrifier.ex @@ -611,7 +611,9 @@ def handle_incoming( end end - def handle_incoming(_, _), do: :error + def handle_incoming(_, _) do + IO.inspect(:error) + end @spec get_obj_helper(String.t(), Keyword.t()) :: {:ok, Object.t()} | nil def get_obj_helper(id, options \\ []) do diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex index c2cf34d76e..4d8dbff449 100644 --- a/lib/pleroma/web/mastodon_api/views/status_view.ex +++ b/lib/pleroma/web/mastodon_api/views/status_view.ex @@ -702,8 +702,6 @@ def get_reply_to(%{data: %{"object" => _object}} = activity, _) do end end - def get_quote(_activity, %{show_quote: false}), do: nil - def get_quote(activity, %{quoted_activities: quoted_activities}) do object = Object.normalize(activity, fetch: false) diff --git a/test/fixtures/fep-e232.json b/test/fixtures/fep-e232.json index ef4b5a2ae0..e9d12ae357 100644 --- a/test/fixtures/fep-e232.json +++ b/test/fixtures/fep-e232.json @@ -1,28 +1,31 @@ { "@context": "https://www.w3.org/ns/activitystreams", - "id": "https://mitra.social/objects/01839574-d41f-01a7-8eef-abfe0badcd6a", - "type": "Note", - "attributedTo": "https://mitra.social/users/silverpill", - "content": "Quote test

RE: https://mitra.social/objects/01830912-1357-d4c5-e4a2-76eab347e749

", - "published": "2022-10-01T21:30:05.211215Z", - "tag": [ - { - "name": "@silverpill@mitra.social", - "type": "Mention", - "href": "https://mitra.social/users/silverpill" - }, - { - "name": "RE: https://mitra.social/objects/01830912-1357-d4c5-e4a2-76eab347e749", - "type": "Link", - "href": "https://mitra.social/objects/01830912-1357-d4c5-e4a2-76eab347e749", - "mediaType": "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"" - } - ], - "to": [ - "https://www.w3.org/ns/activitystreams#Public", - "https://mitra.social/users/silverpill" - ], - "cc": [ - "https://mitra.social/users/silverpill/followers" - ] + "type": "Create", + "actor": "https://example.org/users/alice", + "object": { + "id": "https://example.org/objects/10", + "type": "Note", + "attributedTo": "https://example.org/users/alice", + "content": "

test https://example.org/objects/9

", + "published": "2022-10-01T21:30:05.211215Z", + "tag": [ + { + "name": "@bob@example.net", + "type": "Mention", + "href": "https://example.net/users/bob" + }, + { + "name": "https://example.org/objects/9", + "type": "Link", + "href": "https://example.org/objects/9", + "mediaType": "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"" + } + ], + "to": [ + "https://www.w3.org/ns/activitystreams#Public" + ], + "cc": [ + "https://example.org/users/alice/followers" + ] + } } diff --git a/test/pleroma/migration_helper/notification_backfill_test.exs b/test/pleroma/migration_helper/notification_backfill_test.exs index 946931bba1..70d4c9b6d1 100644 --- a/test/pleroma/migration_helper/notification_backfill_test.exs +++ b/test/pleroma/migration_helper/notification_backfill_test.exs @@ -13,6 +13,11 @@ defmodule Pleroma.MigrationHelper.NotificationBackfillTest do import Pleroma.Factory + setup do + Mox.stub_with(Pleroma.UnstubbedConfigMock, Pleroma.Config) + :ok + end + describe "fill_in_notification_types" do test "it fills in missing notification types" do user = insert(:user) diff --git a/test/pleroma/web/activity_pub/transmogrifier_test.exs b/test/pleroma/web/activity_pub/transmogrifier_test.exs index e334e27bdb..63b012b2bf 100644 --- a/test/pleroma/web/activity_pub/transmogrifier_test.exs +++ b/test/pleroma/web/activity_pub/transmogrifier_test.exs @@ -155,47 +155,6 @@ test "it accepts quote posts" do # It fetched the quoted post assert Object.normalize("https://misskey.io/notes/8vs6wxufd0") end - - test "it accepts FEP-e232 quote posts" do - insert(:user, ap_id: "https://mitra.social/users/silverpill") - - object = File.read!("test/fixtures/fep-e232.json") |> Jason.decode!() - - message = %{ - "@context" => "https://www.w3.org/ns/activitystreams", - "type" => "Create", - "actor" => "https://mitra.social/users/silverpill", - "object" => object - } - - assert {:ok, activity} = Transmogrifier.handle_incoming(message) - - # Object was created in the database - object = Object.normalize(activity) - - assert object.data["quoteUrl"] == - "https://mitra.social/objects/01830912-1357-d4c5-e4a2-76eab347e749" - - # The Link tag was normalized - assert object.data["tag"] == [ - %{ - "href" => "https://mitra.social/users/silverpill", - "name" => "@silverpill@mitra.social", - "type" => "Mention" - }, - %{ - "href" => "https://mitra.social/objects/01830912-1357-d4c5-e4a2-76eab347e749", - "mediaType" => - "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"", - "name" => - "RE: https://mitra.social/objects/01830912-1357-d4c5-e4a2-76eab347e749", - "type" => "Link" - } - ] - - # It fetched the quoted post - assert Object.normalize("https://mitra.social/objects/01830912-1357-d4c5-e4a2-76eab347e749") - end end describe "prepare outgoing" do diff --git a/test/pleroma/web/common_api_test.exs b/test/pleroma/web/common_api_test.exs index 611757a307..a320802746 100644 --- a/test/pleroma/web/common_api_test.exs +++ b/test/pleroma/web/common_api_test.exs @@ -29,6 +29,8 @@ defmodule Pleroma.Web.CommonAPITest do setup_all do Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end) + Mox.stub_with(Pleroma.UnstubbedConfigMock, Pleroma.Config) + :ok end diff --git a/test/pleroma/web/mastodon_api/views/status_view_test.exs b/test/pleroma/web/mastodon_api/views/status_view_test.exs index f9b84594c6..e83328350a 100644 --- a/test/pleroma/web/mastodon_api/views/status_view_test.exs +++ b/test/pleroma/web/mastodon_api/views/status_view_test.exs @@ -444,7 +444,8 @@ test "a quote post" do assert status.pleroma.quote_url == Object.normalize(quote_post).data["id"] assert status.pleroma.quote_visible - # Quotes don't go more than one level deep + # Quotes don't go more than one level deep\ + IO.inspect(status.pleroma.quote.pleroma) refute status.pleroma.quote.pleroma.quote assert status.pleroma.quote.pleroma.quote_id == to_string(post.id) assert status.pleroma.quote.pleroma.quote_url == Object.normalize(post).data["id"] @@ -718,7 +719,7 @@ test "a Mobilizon event" do name: "Cour du Château des Ducs de Bretagne", postal_code: nil, region: "Pays de la Loire", - street: " ", + street: nil, url: nil }, join_state: nil, diff --git a/test/pleroma/web/pleroma_api/controllers/notification_controller_test.exs b/test/pleroma/web/pleroma_api/controllers/notification_controller_test.exs index 76a01bcd84..2e2935d8e6 100644 --- a/test/pleroma/web/pleroma_api/controllers/notification_controller_test.exs +++ b/test/pleroma/web/pleroma_api/controllers/notification_controller_test.exs @@ -11,6 +11,11 @@ defmodule Pleroma.Web.PleromaAPI.NotificationControllerTest do import Pleroma.Factory + setup do + Mox.stub_with(Pleroma.UnstubbedConfigMock, Pleroma.Config) + :ok + end + describe "POST /api/v1/pleroma/notifications/read" do setup do: oauth_access(["write:notifications"]) diff --git a/test/pleroma/web/push/impl_test.exs b/test/pleroma/web/push/impl_test.exs index cbd84d2302..23dbe98c3d 100644 --- a/test/pleroma/web/push/impl_test.exs +++ b/test/pleroma/web/push/impl_test.exs @@ -27,6 +27,8 @@ defmodule Pleroma.Web.Push.ImplTest do %Tesla.Env{status: 100} end) + Mox.stub_with(Pleroma.UnstubbedConfigMock, Pleroma.Config) + :ok end