# Pleroma: A lightweight social networking server
-# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.CommonAPI.UtilsTest do
assert output == expected
- text = "<p>hello world!</p>\n\n<p>second paragraph</p>"
- expected = "<p>hello world!</p>\n\n<p>second paragraph</p>"
+ text = "<p>hello world!</p><br/>\n<p>second paragraph</p>"
+ expected = "<p>hello world!</p><br/>\n<p>second paragraph</p>"
{output, [], []} = Utils.format_input(text, "text/html")
test "works for bare text/markdown" do
text = "**hello world**"
- expected = "<p><strong>hello world</strong></p>\n"
+ expected = "<p><strong>hello world</strong></p>"
{output, [], []} = Utils.format_input(text, "text/markdown")
assert output == expected
text = "**hello world**\n\n*another paragraph*"
- expected = "<p><strong>hello world</strong></p>\n<p><em>another paragraph</em></p>\n"
+ expected = "<p><strong>hello world</strong></p><p><em>another paragraph</em></p>"
{output, [], []} = Utils.format_input(text, "text/markdown")
by someone
"""
- expected = "<blockquote><p>cool quote</p>\n</blockquote>\n<p>by someone</p>\n"
+ expected = "<blockquote><p>cool quote</p></blockquote><p>by someone</p>"
{output, [], []} = Utils.format_input(text, "text/markdown")
assert output == expected
text = "[b]hello world![/b]\n\nsecond paragraph!"
- expected = "<strong>hello world!</strong><br>\n<br>\nsecond paragraph!"
+ expected = "<strong>hello world!</strong><br><br>second paragraph!"
{output, [], []} = Utils.format_input(text, "text/bbcode")
text = "[b]hello world![/b]\n\n<strong>second paragraph!</strong>"
expected =
- "<strong>hello world!</strong><br>\n<br>\n<strong>second paragraph!</strong>"
+ "<strong>hello world!</strong><br><br><strong>second paragraph!</strong>"
{output, [], []} = Utils.format_input(text, "text/bbcode")
text = "**hello world**\n\n*another @user__test and @user__test google.com paragraph*"
- expected =
- ~s(<p><strong>hello world</strong></p>\n<p><em>another <span class="h-card"><a data-user="#{
- user.id
- }" class="u-url mention" href="http://foo.com/user__test" rel="ugc">@<span>user__test</span></a></span> and <span class="h-card"><a data-user="#{
- user.id
- }" class="u-url mention" href="http://foo.com/user__test" rel="ugc">@<span>user__test</span></a></span> <a href="http://google.com" rel="ugc">google.com</a> paragraph</em></p>\n)
-
{output, _, _} = Utils.format_input(text, "text/markdown")
- assert output == expected
+ assert output ==
+ ~s(<p><strong>hello world</strong></p><p><em>another <span class="h-card"><a class="u-url mention" data-user="#{
+ user.id
+ }" href="http://foo.com/user__test" rel="ugc">@<span>user__test</span></a></span> and <span class="h-card"><a class="u-url mention" data-user="#{
+ user.id
+ }" href="http://foo.com/user__test" rel="ugc">@<span>user__test</span></a></span> <a href="http://google.com" rel="ugc">google.com</a> paragraph</em></p>)
end
end
{to, cc} = Utils.get_to_and_cc(user, mentions, nil, "private", nil)
assert length(to) == 2
- assert length(cc) == 0
+ assert Enum.empty?(cc)
assert mentioned_user.ap_id in to
assert user.follower_address in to
{to, cc} = Utils.get_to_and_cc(user, mentions, activity, "private", nil)
assert length(to) == 3
- assert length(cc) == 0
+ assert Enum.empty?(cc)
assert mentioned_user.ap_id in to
assert third_user.ap_id in to
{to, cc} = Utils.get_to_and_cc(user, mentions, nil, "direct", nil)
assert length(to) == 1
- assert length(cc) == 0
+ assert Enum.empty?(cc)
assert mentioned_user.ap_id in to
end
{to, cc} = Utils.get_to_and_cc(user, mentions, activity, "direct", nil)
assert length(to) == 2
- assert length(cc) == 0
+ assert Enum.empty?(cc)
assert mentioned_user.ap_id in to
assert third_user.ap_id in to
activity = insert(:note_activity, user: user, note: object)
Pleroma.Repo.delete(object)
+ obj_url = activity.data["object"]
+
+ Tesla.Mock.mock(fn
+ %{method: :get, url: ^obj_url} ->
+ %Tesla.Env{status: 404, body: ""}
+ end)
+
assert Utils.maybe_notify_mentioned_recipients(["test-test"], activity) == [
"test-test"
]
end
describe "maybe_add_attachments/3" do
- test "returns parsed results when no_links is true" do
+ test "returns parsed results when attachment_links is false" do
assert Utils.maybe_add_attachments(
{"test", [], ["tags"]},
[],
- true
+ false
) == {"test", [], ["tags"]}
end
assert Utils.maybe_add_attachments(
{"test", [], ["tags"]},
[attachment],
- false
+ true
) == {
"test<br><a href=\"SakuraPM.png\" class='attachment'>SakuraPM.png</a>",
[],