diff options
| author | eugenijm <eugenijm@protonmail.com> | 2019-11-07 03:00:21 +0300 | 
|---|---|---|
| committer | eugenijm <eugenijm@protonmail.com> | 2019-11-07 08:26:24 +0300 | 
| commit | 7888803ffed428438ed107d35a856647a46b347d (patch) | |
| tree | 31a82ba5fcdbde2e3f045b295764916e7c90ae5d /test | |
| parent | 9f9c3c4fbe4a2f95227bc4b32ea8961c4f699ecf (diff) | |
| download | pleroma-7888803ffed428438ed107d35a856647a46b347d.tar.gz pleroma-7888803ffed428438ed107d35a856647a46b347d.zip | |
Mastodon API: Add the `recipients` parameter to `GET /api/v1/conversations`
Diffstat (limited to 'test')
| -rw-r--r-- | test/web/mastodon_api/controllers/conversation_controller_test.exs | 53 | 
1 files changed, 53 insertions, 0 deletions
| diff --git a/test/web/mastodon_api/controllers/conversation_controller_test.exs b/test/web/mastodon_api/controllers/conversation_controller_test.exs index 542af4944..2a1223b18 100644 --- a/test/web/mastodon_api/controllers/conversation_controller_test.exs +++ b/test/web/mastodon_api/controllers/conversation_controller_test.exs @@ -59,6 +59,59 @@ defmodule Pleroma.Web.MastodonAPI.ConversationControllerTest do      assert User.get_cached_by_id(user_one.id).unread_conversation_count == 0    end +  test "filters conversations by recipients", %{conn: conn} do +    user_one = insert(:user) +    user_two = insert(:user) +    user_three = insert(:user) + +    {:ok, direct1} = +      CommonAPI.post(user_one, %{ +        "status" => "Hi @#{user_two.nickname}!", +        "visibility" => "direct" +      }) + +    {:ok, _direct2} = +      CommonAPI.post(user_one, %{ +        "status" => "Hi @#{user_three.nickname}!", +        "visibility" => "direct" +      }) + +    {:ok, direct3} = +      CommonAPI.post(user_one, %{ +        "status" => "Hi @#{user_two.nickname}, @#{user_three.nickname}!", +        "visibility" => "direct" +      }) + +    {:ok, _direct4} = +      CommonAPI.post(user_two, %{ +        "status" => "Hi @#{user_three.nickname}!", +        "visibility" => "direct" +      }) + +    {:ok, direct5} = +      CommonAPI.post(user_two, %{ +        "status" => "Hi @#{user_one.nickname}!", +        "visibility" => "direct" +      }) + +    [conversation1, conversation2] = +      conn +      |> assign(:user, user_one) +      |> get("/api/v1/conversations", %{"recipients" => [user_two.id]}) +      |> json_response(200) + +    assert conversation1["last_status"]["id"] == direct5.id +    assert conversation2["last_status"]["id"] == direct1.id + +    [conversation1] = +      conn +      |> assign(:user, user_one) +      |> get("/api/v1/conversations", %{"recipients" => [user_two.id, user_three.id]}) +      |> json_response(200) + +    assert conversation1["last_status"]["id"] == direct3.id +  end +    test "updates the last_status on reply", %{conn: conn} do      user_one = insert(:user)      user_two = insert(:user) | 
