Question: Add tests on HTML tags in options

Closes: https://git.pleroma.social/pleroma/pleroma/-/issues/1362
This commit is contained in:
Haelwenn (lanodan) Monnier 2020-07-02 05:47:18 +02:00
commit 922ca23298
No known key found for this signature in database
GPG key ID: D5B7A8E43C997DEE
2 changed files with 64 additions and 0 deletions

View file

@ -55,6 +55,41 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.QuestionHandlingTest do
])
end
test "Mastodon Question activity with HTML tags in plaintext" do
options = [
%{
"type" => "Note",
"name" => "<input type=\"date\">",
"replies" => %{"totalItems" => 0, "type" => "Collection"}
},
%{
"type" => "Note",
"name" => "<input type=\"date\"/>",
"replies" => %{"totalItems" => 0, "type" => "Collection"}
},
%{
"type" => "Note",
"name" => "<input type=\"date\" />",
"replies" => %{"totalItems" => 1, "type" => "Collection"}
},
%{
"type" => "Note",
"name" => "<input type=\"date\"></input>",
"replies" => %{"totalItems" => 1, "type" => "Collection"}
}
]
data =
File.read!("test/fixtures/mastodon-question-activity.json")
|> Poison.decode!()
|> Kernel.put_in(["object", "oneOf"], options)
{:ok, %Activity{local: false} = activity} = Transmogrifier.handle_incoming(data)
object = Object.normalize(activity, false)
assert Enum.sort(object.data["oneOf"]) == Enum.sort(options)
end
test "returns an error if received a second time" do
data = File.read!("test/fixtures/mastodon-question-activity.json") |> Poison.decode!()