test(status_view): cover attachments with zero dimensions

This commit is contained in:
Lain Soykaf 2026-10-27 17:27:41 +04:00
commit 283035ad4f
No known key found for this signature in database
2 changed files with 19 additions and 0 deletions

View file

@ -0,0 +1 @@
Do not crash when rendering attachments with zero width or height

View file

@ -597,6 +597,24 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
end
describe "attachments" do
test "skips meta for zero dimensions" do
for {width, height} <- [{0, 0}, {200, 0}, {0, 100}] do
object = %{
"type" => "Image",
"url" => [
%{
"mediaType" => "image/png",
"href" => "someurl",
"width" => width,
"height" => height
}
]
}
refute Map.has_key?(StatusView.render("attachment.json", %{attachment: object}), :meta)
end
end
test "Complete Mastodon style" do
object = %{
"type" => "Image",