logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git

builder_test.exs (1994B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Web.ActivityPub.BuilderTest do
  5. alias Pleroma.Web.ActivityPub.Builder
  6. alias Pleroma.Web.CommonAPI.ActivityDraft
  7. use Pleroma.DataCase
  8. import Pleroma.Factory
  9. describe "note/1" do
  10. test "returns note data" do
  11. user = insert(:user)
  12. note = insert(:note)
  13. user2 = insert(:user)
  14. user3 = insert(:user)
  15. draft = %ActivityDraft{
  16. user: user,
  17. to: [user2.ap_id],
  18. context: "2hu",
  19. content_html: "<h1>This is :moominmamma: note</h1>",
  20. in_reply_to: note.id,
  21. tags: [name: "jimm"],
  22. summary: "test summary",
  23. cc: [user3.ap_id],
  24. extra: %{"custom_tag" => "test"}
  25. }
  26. expected = %{
  27. "actor" => user.ap_id,
  28. "attachment" => [],
  29. "cc" => [user3.ap_id],
  30. "content" => "<h1>This is :moominmamma: note</h1>",
  31. "context" => "2hu",
  32. "sensitive" => false,
  33. "summary" => "test summary",
  34. "tag" => ["jimm"],
  35. "to" => [user2.ap_id],
  36. "type" => "Note",
  37. "custom_tag" => "test"
  38. }
  39. assert {:ok, ^expected, []} = Builder.note(draft)
  40. end
  41. test "quote post" do
  42. user = insert(:user)
  43. note = insert(:note)
  44. draft = %ActivityDraft{
  45. user: user,
  46. context: "2hu",
  47. content_html: "<h1>This is :moominmamma: note</h1>",
  48. quote_post: note,
  49. extra: %{}
  50. }
  51. expected = %{
  52. "actor" => user.ap_id,
  53. "attachment" => [],
  54. "content" => "<h1>This is :moominmamma: note</h1>",
  55. "context" => "2hu",
  56. "sensitive" => false,
  57. "type" => "Note",
  58. "quoteUrl" => note.data["id"],
  59. "cc" => [],
  60. "summary" => nil,
  61. "tag" => [],
  62. "to" => []
  63. }
  64. assert {:ok, ^expected, []} = Builder.note(draft)
  65. end
  66. end
  67. end