diff options
Diffstat (limited to 'test/web/mastodon_api')
| -rw-r--r-- | test/web/mastodon_api/mastodon_api_controller_test.exs | 86 | ||||
| -rw-r--r-- | test/web/mastodon_api/status_view_test.exs | 2 | 
2 files changed, 88 insertions, 0 deletions
| diff --git a/test/web/mastodon_api/mastodon_api_controller_test.exs b/test/web/mastodon_api/mastodon_api_controller_test.exs index c2a12d3c7..505e45010 100644 --- a/test/web/mastodon_api/mastodon_api_controller_test.exs +++ b/test/web/mastodon_api/mastodon_api_controller_test.exs @@ -300,6 +300,65 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do      assert status["url"] != direct.data["id"]    end +  test "Conversations", %{conn: conn} do +    user_one = insert(:user) +    user_two = insert(:user) + +    {:ok, user_two} = User.follow(user_two, user_one) + +    {:ok, direct} = +      CommonAPI.post(user_one, %{ +        "status" => "Hi @#{user_two.nickname}!", +        "visibility" => "direct" +      }) + +    {:ok, _follower_only} = +      CommonAPI.post(user_one, %{ +        "status" => "Hi @#{user_two.nickname}!", +        "visibility" => "private" +      }) + +    res_conn = +      conn +      |> assign(:user, user_one) +      |> get("/api/v1/conversations") + +    assert response = json_response(res_conn, 200) + +    assert [ +             %{ +               "id" => res_id, +               "accounts" => res_accounts, +               "last_status" => res_last_status, +               "unread" => unread +             } +           ] = response + +    assert length(res_accounts) == 2 +    assert is_binary(res_id) +    assert unread == true +    assert res_last_status["id"] == direct.id + +    # Apparently undocumented API endpoint +    res_conn = +      conn +      |> assign(:user, user_one) +      |> post("/api/v1/conversations/#{res_id}/read") + +    assert response = json_response(res_conn, 200) +    assert length(response["accounts"]) == 2 +    assert response["last_status"]["id"] == direct.id +    assert response["unread"] == false + +    # (vanilla) Mastodon frontend behaviour +    res_conn = +      conn +      |> assign(:user, user_one) +      |> get("/api/v1/statuses/#{res_last_status["id"]}/context") + +    assert %{"ancestors" => [], "descendants" => []} == json_response(res_conn, 200) +  end +    test "doesn't include DMs from blocked users", %{conn: conn} do      blocker = insert(:user)      blocked = insert(:user) @@ -2351,6 +2410,33 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do          end        end      end + +    test "updates profile emojos", %{conn: conn} do +      user = insert(:user) + +      note = "*sips :blank:*" +      name = "I am :firefox:" + +      conn = +        conn +        |> assign(:user, user) +        |> patch("/api/v1/accounts/update_credentials", %{ +          "note" => note, +          "display_name" => name +        }) + +      assert json_response(conn, 200) + +      conn = +        conn +        |> get("/api/v1/accounts/#{user.id}") + +      assert user = json_response(conn, 200) + +      assert user["note"] == note +      assert user["display_name"] == name +      assert [%{"shortcode" => "blank"}, %{"shortcode" => "firefox"}] = user["emojis"] +    end    end    test "get instance information", %{conn: conn} do diff --git a/test/web/mastodon_api/status_view_test.exs b/test/web/mastodon_api/status_view_test.exs index 5fddc6c58..d7c800e83 100644 --- a/test/web/mastodon_api/status_view_test.exs +++ b/test/web/mastodon_api/status_view_test.exs @@ -168,6 +168,8 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do      {:ok, _bookmark} = Bookmark.create(user.id, activity.id) +    activity = Activity.get_by_id_with_object(activity.id) +      status = StatusView.render("status.json", %{activity: activity, for: user})      assert status.bookmarked == true | 
