Update/fix test

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak 2023-11-17 23:44:07 +01:00
parent c78495900e
commit 739dbfff6f
9 changed files with 48 additions and 71 deletions

View file

@ -611,7 +611,9 @@ def handle_incoming(
end end
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 @spec get_obj_helper(String.t(), Keyword.t()) :: {:ok, Object.t()} | nil
def get_obj_helper(id, options \\ []) do def get_obj_helper(id, options \\ []) do

View file

@ -702,8 +702,6 @@ def get_reply_to(%{data: %{"object" => _object}} = activity, _) do
end end
end end
def get_quote(_activity, %{show_quote: false}), do: nil
def get_quote(activity, %{quoted_activities: quoted_activities}) do def get_quote(activity, %{quoted_activities: quoted_activities}) do
object = Object.normalize(activity, fetch: false) object = Object.normalize(activity, fetch: false)

View file

@ -1,28 +1,31 @@
{ {
"@context": "https://www.w3.org/ns/activitystreams", "@context": "https://www.w3.org/ns/activitystreams",
"id": "https://mitra.social/objects/01839574-d41f-01a7-8eef-abfe0badcd6a", "type": "Create",
"type": "Note", "actor": "https://example.org/users/alice",
"attributedTo": "https://mitra.social/users/silverpill", "object": {
"content": "Quote test<p class=\"inline-quote\">RE: <a href=\"https://mitra.social/objects/01830912-1357-d4c5-e4a2-76eab347e749\">https://mitra.social/objects/01830912-1357-d4c5-e4a2-76eab347e749</a></p>", "id": "https://example.org/objects/10",
"published": "2022-10-01T21:30:05.211215Z", "type": "Note",
"tag": [ "attributedTo": "https://example.org/users/alice",
{ "content": "<p>test <a href=\"https://example.org/objects/9\">https://example.org/objects/9</a></p>",
"name": "@silverpill@mitra.social", "published": "2022-10-01T21:30:05.211215Z",
"type": "Mention", "tag": [
"href": "https://mitra.social/users/silverpill" {
}, "name": "@bob@example.net",
{ "type": "Mention",
"name": "RE: https://mitra.social/objects/01830912-1357-d4c5-e4a2-76eab347e749", "href": "https://example.net/users/bob"
"type": "Link", },
"href": "https://mitra.social/objects/01830912-1357-d4c5-e4a2-76eab347e749", {
"mediaType": "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"" "name": "https://example.org/objects/9",
} "type": "Link",
], "href": "https://example.org/objects/9",
"to": [ "mediaType": "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\""
"https://www.w3.org/ns/activitystreams#Public", }
"https://mitra.social/users/silverpill" ],
], "to": [
"cc": [ "https://www.w3.org/ns/activitystreams#Public"
"https://mitra.social/users/silverpill/followers" ],
] "cc": [
"https://example.org/users/alice/followers"
]
}
} }

View file

@ -13,6 +13,11 @@ defmodule Pleroma.MigrationHelper.NotificationBackfillTest do
import Pleroma.Factory import Pleroma.Factory
setup do
Mox.stub_with(Pleroma.UnstubbedConfigMock, Pleroma.Config)
:ok
end
describe "fill_in_notification_types" do describe "fill_in_notification_types" do
test "it fills in missing notification types" do test "it fills in missing notification types" do
user = insert(:user) user = insert(:user)

View file

@ -155,47 +155,6 @@ test "it accepts quote posts" do
# It fetched the quoted post # It fetched the quoted post
assert Object.normalize("https://misskey.io/notes/8vs6wxufd0") assert Object.normalize("https://misskey.io/notes/8vs6wxufd0")
end 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 end
describe "prepare outgoing" do describe "prepare outgoing" do

View file

@ -29,6 +29,8 @@ defmodule Pleroma.Web.CommonAPITest do
setup_all do setup_all do
Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end) Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
Mox.stub_with(Pleroma.UnstubbedConfigMock, Pleroma.Config)
:ok :ok
end end

View file

@ -444,7 +444,8 @@ test "a quote post" do
assert status.pleroma.quote_url == Object.normalize(quote_post).data["id"] assert status.pleroma.quote_url == Object.normalize(quote_post).data["id"]
assert status.pleroma.quote_visible 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 refute status.pleroma.quote.pleroma.quote
assert status.pleroma.quote.pleroma.quote_id == to_string(post.id) assert status.pleroma.quote.pleroma.quote_id == to_string(post.id)
assert status.pleroma.quote.pleroma.quote_url == Object.normalize(post).data["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", name: "Cour du Château des Ducs de Bretagne",
postal_code: nil, postal_code: nil,
region: "Pays de la Loire", region: "Pays de la Loire",
street: " ", street: nil,
url: nil url: nil
}, },
join_state: nil, join_state: nil,

View file

@ -11,6 +11,11 @@ defmodule Pleroma.Web.PleromaAPI.NotificationControllerTest do
import Pleroma.Factory import Pleroma.Factory
setup do
Mox.stub_with(Pleroma.UnstubbedConfigMock, Pleroma.Config)
:ok
end
describe "POST /api/v1/pleroma/notifications/read" do describe "POST /api/v1/pleroma/notifications/read" do
setup do: oauth_access(["write:notifications"]) setup do: oauth_access(["write:notifications"])

View file

@ -27,6 +27,8 @@ defmodule Pleroma.Web.Push.ImplTest do
%Tesla.Env{status: 100} %Tesla.Env{status: 100}
end) end)
Mox.stub_with(Pleroma.UnstubbedConfigMock, Pleroma.Config)
:ok :ok
end end