summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorfeld <feld@feld.me>2024-07-21 04:33:34 +0000
committerfeld <feld@feld.me>2024-07-21 04:33:34 +0000
commit058f8acb586b832864b9c3912970f4072aaea255 (patch)
tree4a5540ec563fcb6d28c892d994b172b605d9b449 /test
parente4a6973e0b9ffdb827b71012f0b44ed4d870d56a (diff)
parentfb654acfadfeec00a1a52e2af96e922dc4b88b01 (diff)
downloadpleroma-058f8acb586b832864b9c3912970f4072aaea255.tar.gz
pleroma-058f8acb586b832864b9c3912970f4072aaea255.zip
Merge branch 'metadata/parsing-empty' into 'develop'
Fix Metadata providers when parsing objects with no content or summary See merge request pleroma/pleroma!4188
Diffstat (limited to 'test')
-rw-r--r--test/pleroma/web/metadata/utils_test.exs28
1 files changed, 22 insertions, 6 deletions
diff --git a/test/pleroma/web/metadata/utils_test.exs b/test/pleroma/web/metadata/utils_test.exs
index 3daf852fb..9bc02dadf 100644
--- a/test/pleroma/web/metadata/utils_test.exs
+++ b/test/pleroma/web/metadata/utils_test.exs
@@ -8,7 +8,7 @@ defmodule Pleroma.Web.Metadata.UtilsTest do
alias Pleroma.Web.Metadata.Utils
describe "scrub_html_and_truncate/1" do
- test "it returns content text without encode HTML if summary is nil" do
+ test "it returns content text without HTML if summary is nil" do
user = insert(:user)
note =
@@ -17,14 +17,14 @@ defmodule Pleroma.Web.Metadata.UtilsTest do
"actor" => user.ap_id,
"id" => "https://pleroma.gov/objects/whatever",
"summary" => nil,
- "content" => "Pleroma's really cool!"
+ "content" => "Pleroma's really cool!<br>"
}
})
assert Utils.scrub_html_and_truncate(note) == "Pleroma's really cool!"
end
- test "it returns context text without encode HTML if summary is empty" do
+ test "it returns content text without HTML if summary is empty" do
user = insert(:user)
note =
@@ -33,14 +33,14 @@ defmodule Pleroma.Web.Metadata.UtilsTest do
"actor" => user.ap_id,
"id" => "https://pleroma.gov/objects/whatever",
"summary" => "",
- "content" => "Pleroma's really cool!"
+ "content" => "Pleroma's really cool!<br>"
}
})
assert Utils.scrub_html_and_truncate(note) == "Pleroma's really cool!"
end
- test "it returns summary text without encode HTML if summary is filled" do
+ test "it returns summary text without HTML if summary is filled" do
user = insert(:user)
note =
@@ -48,7 +48,7 @@ defmodule Pleroma.Web.Metadata.UtilsTest do
data: %{
"actor" => user.ap_id,
"id" => "https://pleroma.gov/objects/whatever",
- "summary" => "Public service announcement on caffeine consumption",
+ "summary" => "Public service announcement on caffeine consumption<br>",
"content" => "cofe"
}
})
@@ -57,6 +57,22 @@ defmodule Pleroma.Web.Metadata.UtilsTest do
"Public service announcement on caffeine consumption"
end
+ test "it returns empty string if summary and content are absent" do
+ user = insert(:user)
+
+ note =
+ insert(:note, %{
+ data: %{
+ "actor" => user.ap_id,
+ "id" => "https://pleroma.gov/objects/whatever",
+ "content" => nil,
+ "summary" => nil
+ }
+ })
+
+ assert Utils.scrub_html_and_truncate(note) == ""
+ end
+
test "it does not return old content after editing" do
user = insert(:user)