ap_id: "http://misskey.local.live/users/remote_user"
})
+ full_tag_remote_user =
+ insert(:user, %{
+ nickname: "full_tag_remote_user",
+ ap_id: "http://misskey.local.live/users/full_tag_remote_user"
+ })
+
insert(:user, %{ap_id: "https://misskey.local.live/users/92hzkskwgy"})
note =
changes: %{
content: content,
source: %{
- "content" =>
- "@akkoma_user @remote_user @oops_not_a_mention linkifylink #dancedance $[jelly mfm goes here] \n\n## aaa",
"mediaType" => "text/x.misskeymarkdown"
}
}
assert content =~
"<span class=\"h-card\"><a class=\"u-url mention\" data-user=\"#{remote_user.id}\" href=\"#{remote_user.ap_id}\" rel=\"ugc\">@<span>remote_user</span></a></span>"
+ assert content =~
+ "<span class=\"h-card\"><a class=\"u-url mention\" data-user=\"#{full_tag_remote_user.id}\" href=\"#{full_tag_remote_user.ap_id}\" rel=\"ugc\">@<span>full_tag_remote_user</span></a></span>"
+
assert content =~ "@oops_not_a_mention"
- assert content =~ "$[jelly mfm goes here] <br><br>## aaa"
+
+ assert content =~
+ "<span class=\"mfm _mfm_jelly_\" style=\"display: inline-block; animation: 1s linear 0s infinite normal both running mfm-rubberBand;\">mfm goes here</span> </p>aaa"
end
test "a misskey MFM status with a _misskey_content field should work and be linked", _ do
|> File.read!()
|> Jason.decode!()
- expected_content =
- "<span class=\"h-card\"><a class=\"u-url mention\" data-user=\"#{local_user.id}\" href=\"#{local_user.ap_id}\" rel=\"ugc\">@<span>akkoma_user</span></a></span> linkifylink <a class=\"hashtag\" data-tag=\"dancedance\" href=\"http://localhost:4001/tag/dancedance\" rel=\"tag ugc\">#dancedance</a> $[jelly mfm goes here] <br><br>## aaa"
+ changes = ArticleNotePageValidator.cast_and_validate(note)
%{
valid?: true,
changes: %{
- content: ^expected_content,
+ content: content,
source: %{
- "content" => "@akkoma_user linkifylink #dancedance $[jelly mfm goes here] \n\n## aaa",
- "mediaType" => "text/x.misskeymarkdown"
+ "mediaType" => "text/x.misskeymarkdown",
+ "content" => "@akkoma_user linkifylink #dancedance $[jelly mfm goes here] \n\n## aaa"
}
}
- } = ArticleNotePageValidator.cast_and_validate(note)
+ } = changes
+
+ assert content =~
+ "<span class=\"h-card\"><a class=\"u-url mention\" data-user=\"#{local_user.id}\" href=\"#{local_user.ap_id}\" rel=\"ugc\">@<span>akkoma_user</span></a></span>"
end
end
+
+ test "a Note without replies/first/items validates" do
+ insert(:user, ap_id: "https://mastodon.social/users/emelie")
+
+ note =
+ "test/fixtures/tesla_mock/status.emelie.json"
+ |> File.read!()
+ |> Jason.decode!()
+ |> pop_in(["replies", "first", "items"])
+ |> elem(1)
+
+ %{valid?: true} = ArticleNotePageValidator.cast_and_validate(note)
+ end
end