summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/pleroma/web/metadata/providers/open_graph_test.exs55
-rw-r--r--test/pleroma/web/metadata/providers/twitter_card_test.exs54
2 files changed, 109 insertions, 0 deletions
diff --git a/test/pleroma/web/metadata/providers/open_graph_test.exs b/test/pleroma/web/metadata/providers/open_graph_test.exs
index 6a0fc9b10..29cc036ba 100644
--- a/test/pleroma/web/metadata/providers/open_graph_test.exs
+++ b/test/pleroma/web/metadata/providers/open_graph_test.exs
@@ -9,6 +9,7 @@ defmodule Pleroma.Web.Metadata.Providers.OpenGraphTest do
alias Pleroma.UnstubbedConfigMock, as: ConfigMock
alias Pleroma.Web.Metadata.Providers.OpenGraph
+ alias Pleroma.Web.Metadata.Utils
setup do
ConfigMock
@@ -197,4 +198,58 @@ defmodule Pleroma.Web.Metadata.Providers.OpenGraphTest do
"http://localhost:4001/proxy/preview/LzAnlke-l5oZbNzWsrHfprX1rGw/aHR0cHM6Ly9wbGVyb21hLmdvdi9hYm91dC9qdWNoZS53ZWJt/juche.webm"
], []} in result
end
+
+ test "meta tag ordering matches attachment order" do
+ user = insert(:user, name: "Jimmy Hendriks", bio: "born 19 March 1994")
+
+ note =
+ insert(:note, %{
+ data: %{
+ "actor" => user.ap_id,
+ "tag" => [],
+ "id" => "https://pleroma.gov/objects/whatever",
+ "summary" => "",
+ "content" => "pleroma in a nutshell",
+ "attachment" => [
+ %{
+ "url" => [
+ %{
+ "mediaType" => "image/png",
+ "href" => "https://example.com/first.png",
+ "height" => 1024,
+ "width" => 1280
+ }
+ ]
+ },
+ %{
+ "url" => [
+ %{
+ "mediaType" => "image/png",
+ "href" => "https://example.com/second.png",
+ "height" => 1024,
+ "width" => 1280
+ }
+ ]
+ }
+ ]
+ }
+ })
+
+ result = OpenGraph.build_tags(%{object: note, url: note.data["id"], user: user})
+
+ assert [
+ {:meta, [property: "og:title", content: Utils.user_name_string(user)], []},
+ {:meta, [property: "og:url", content: "https://pleroma.gov/objects/whatever"], []},
+ {:meta, [property: "og:description", content: "pleroma in a nutshell"], []},
+ {:meta, [property: "og:type", content: "article"], []},
+ {:meta, [property: "og:image", content: "https://example.com/first.png"], []},
+ {:meta, [property: "og:image:alt", content: nil], []},
+ {:meta, [property: "og:image:width", content: "1280"], []},
+ {:meta, [property: "og:image:height", content: "1024"], []},
+ {:meta, [property: "og:image", content: "https://example.com/second.png"], []},
+ {:meta, [property: "og:image:alt", content: nil], []},
+ {:meta, [property: "og:image:width", content: "1280"], []},
+ {:meta, [property: "og:image:height", content: "1024"], []}
+ ] == result
+ end
end
diff --git a/test/pleroma/web/metadata/providers/twitter_card_test.exs b/test/pleroma/web/metadata/providers/twitter_card_test.exs
index f8d01c5c8..f9e917719 100644
--- a/test/pleroma/web/metadata/providers/twitter_card_test.exs
+++ b/test/pleroma/web/metadata/providers/twitter_card_test.exs
@@ -202,4 +202,58 @@ defmodule Pleroma.Web.Metadata.Providers.TwitterCardTest do
{:meta, [name: "twitter:player:stream:content_type", content: "video/webm"], []}
] == result
end
+
+ test "meta tag ordering matches attachment order" do
+ user = insert(:user, name: "Jimmy Hendriks", bio: "born 19 March 1994")
+
+ note =
+ insert(:note, %{
+ data: %{
+ "actor" => user.ap_id,
+ "tag" => [],
+ "id" => "https://pleroma.gov/objects/whatever",
+ "summary" => "",
+ "content" => "pleroma in a nutshell",
+ "attachment" => [
+ %{
+ "url" => [
+ %{
+ "mediaType" => "image/png",
+ "href" => "https://example.com/first.png",
+ "height" => 1024,
+ "width" => 1280
+ }
+ ]
+ },
+ %{
+ "url" => [
+ %{
+ "mediaType" => "image/png",
+ "href" => "https://example.com/second.png",
+ "height" => 1024,
+ "width" => 1280
+ }
+ ]
+ }
+ ]
+ }
+ })
+
+ result = TwitterCard.build_tags(%{object: note, activity_id: note.data["id"], user: user})
+
+ assert [
+ {:meta, [name: "twitter:title", content: Utils.user_name_string(user)], []},
+ {:meta, [name: "twitter:description", content: "pleroma in a nutshell"], []},
+ {:meta, [name: "twitter:card", content: "summary_large_image"], []},
+ {:meta, [name: "twitter:image", content: "https://example.com/first.png"], []},
+ {:meta, [name: "twitter:image:alt", content: ""], []},
+ {:meta, [name: "twitter:player:width", content: "1280"], []},
+ {:meta, [name: "twitter:player:height", content: "1024"], []},
+ {:meta, [name: "twitter:card", content: "summary_large_image"], []},
+ {:meta, [name: "twitter:image", content: "https://example.com/second.png"], []},
+ {:meta, [name: "twitter:image:alt", content: ""], []},
+ {:meta, [name: "twitter:player:width", content: "1280"], []},
+ {:meta, [name: "twitter:player:height", content: "1024"], []}
+ ] == result
+ end
end