diff options
| author | Maksim Pechnikov <parallel588@gmail.com> | 2020-01-27 15:20:47 +0300 | 
|---|---|---|
| committer | Maksim Pechnikov <parallel588@gmail.com> | 2020-01-27 15:20:47 +0300 | 
| commit | e442ea5722404ca551135b6f4767c016952bbda3 (patch) | |
| tree | 91bb371d96fbc8b46d59c378f6dd690ba30f3da3 /test/web/mastodon_api/views | |
| parent | 6fbafb1cdcba3dc2a7e8b9718e295c9811a726d9 (diff) | |
| parent | 0b582d415ba5215495047ddae1cb4e4fc1e016e6 (diff) | |
| download | pleroma-e442ea5722404ca551135b6f4767c016952bbda3.tar.gz pleroma-e442ea5722404ca551135b6f4767c016952bbda3.zip  | |
Merge branch 'develop' into issue/1276
Diffstat (limited to 'test/web/mastodon_api/views')
| -rw-r--r-- | test/web/mastodon_api/views/account_view_test.exs | 17 | ||||
| -rw-r--r-- | test/web/mastodon_api/views/notification_view_test.exs | 27 | ||||
| -rw-r--r-- | test/web/mastodon_api/views/status_view_test.exs | 36 | 
3 files changed, 70 insertions, 10 deletions
diff --git a/test/web/mastodon_api/views/account_view_test.exs b/test/web/mastodon_api/views/account_view_test.exs index ed6f2ecbd..2107bb85c 100644 --- a/test/web/mastodon_api/views/account_view_test.exs +++ b/test/web/mastodon_api/views/account_view_test.exs @@ -66,6 +66,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do          note: "valid html",          sensitive: false,          pleroma: %{ +          actor_type: "Person",            discoverable: false          },          fields: [] @@ -92,13 +93,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do    test "Represent the user account for the account owner" do      user = insert(:user) -    notification_settings = %{ -      "followers" => true, -      "follows" => true, -      "non_follows" => true, -      "non_followers" => true -    } - +    notification_settings = %Pleroma.User.NotificationSetting{}      privacy = user.default_scope      assert %{ @@ -112,7 +107,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do        insert(:user, %{          follower_count: 3,          note_count: 5, -        source_data: %{"type" => "Service"}, +        source_data: %{}, +        actor_type: "Service",          nickname: "shp@shitposter.club",          inserted_at: ~N[2017-08-15 15:47:06.597036]        }) @@ -140,6 +136,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do          note: user.bio,          sensitive: false,          pleroma: %{ +          actor_type: "Service",            discoverable: false          },          fields: [] @@ -284,7 +281,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do        insert(:user, %{          follower_count: 0,          note_count: 5, -        source_data: %{"type" => "Service"}, +        source_data: %{}, +        actor_type: "Service",          nickname: "shp@shitposter.club",          inserted_at: ~N[2017-08-15 15:47:06.597036]        }) @@ -317,6 +315,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do          note: user.bio,          sensitive: false,          pleroma: %{ +          actor_type: "Service",            discoverable: false          },          fields: [] diff --git a/test/web/mastodon_api/views/notification_view_test.exs b/test/web/mastodon_api/views/notification_view_test.exs index ba1721e06..1fe83cb2c 100644 --- a/test/web/mastodon_api/views/notification_view_test.exs +++ b/test/web/mastodon_api/views/notification_view_test.exs @@ -134,4 +134,31 @@ defmodule Pleroma.Web.MastodonAPI.NotificationViewTest do      assert [expected] ==               NotificationView.render("index.json", %{notifications: [notification], for: follower})    end + +  test "EmojiReaction notification" do +    user = insert(:user) +    other_user = insert(:user) + +    {:ok, activity} = CommonAPI.post(user, %{"status" => "#cofe"}) +    {:ok, _activity, _} = CommonAPI.react_with_emoji(activity.id, other_user, "☕") + +    activity = Repo.get(Activity, activity.id) + +    [notification] = Notification.for_user(user) + +    assert notification + +    expected = %{ +      id: to_string(notification.id), +      pleroma: %{is_seen: false}, +      type: "pleroma:emoji_reaction", +      emoji: "☕", +      account: AccountView.render("show.json", %{user: other_user, for: user}), +      status: StatusView.render("show.json", %{activity: activity, for: user}), +      created_at: Utils.to_masto_date(notification.inserted_at) +    } + +    assert expected == +             NotificationView.render("show.json", %{notification: notification, for: user}) +  end  end diff --git a/test/web/mastodon_api/views/status_view_test.exs b/test/web/mastodon_api/views/status_view_test.exs index bdd87a79e..25777b011 100644 --- a/test/web/mastodon_api/views/status_view_test.exs +++ b/test/web/mastodon_api/views/status_view_test.exs @@ -24,6 +24,24 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do      :ok    end +  test "has an emoji reaction list" do +    user = insert(:user) +    other_user = insert(:user) +    third_user = insert(:user) +    {:ok, activity} = CommonAPI.post(user, %{"status" => "dae cofe??"}) + +    {:ok, _, _} = CommonAPI.react_with_emoji(activity.id, user, "☕") +    {:ok, _, _} = CommonAPI.react_with_emoji(activity.id, third_user, "🍵") +    {:ok, _, _} = CommonAPI.react_with_emoji(activity.id, other_user, "☕") +    activity = Repo.get(Activity, activity.id) +    status = StatusView.render("show.json", activity: activity) + +    assert status[:pleroma][:emoji_reactions] == [ +             %{emoji: "☕", count: 2}, +             %{emoji: "🍵", count: 1} +           ] +  end +    test "loads and returns the direct conversation id when given the `with_direct_conversation_id` option" do      user = insert(:user) @@ -172,7 +190,8 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do          spoiler_text: %{"text/plain" => HTML.strip_tags(object_data["summary"])},          expires_at: nil,          direct_conversation_id: nil, -        thread_muted: false +        thread_muted: false, +        emoji_reactions: []        }      } @@ -394,6 +413,21 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do      assert length(represented[:media_attachments]) == 1    end +  test "a Mobilizon event" do +    user = insert(:user) + +    {:ok, object} = +      Pleroma.Object.Fetcher.fetch_object_from_id( +        "https://mobilizon.org/events/252d5816-00a3-4a89-a66f-15bf65c33e39" +      ) + +    %Activity{} = activity = Activity.get_create_by_object_ap_id(object.data["id"]) + +    represented = StatusView.render("show.json", %{for: user, activity: activity}) + +    assert represented[:id] == to_string(activity.id) +  end +    describe "build_tags/1" do      test "it returns a a dictionary tags" do        object_tags = [  | 
