diff options
| author | kaniini <ariadne@dereferenced.org> | 2019-11-07 15:13:20 +0000 | 
|---|---|---|
| committer | kaniini <ariadne@dereferenced.org> | 2019-11-07 15:13:20 +0000 | 
| commit | 5bf59f8e66f0c341ee0e667c2d5d78f709f46af8 (patch) | |
| tree | 31a82ba5fcdbde2e3f045b295764916e7c90ae5d /test/web/mastodon_api/controllers | |
| parent | 9f9c3c4fbe4a2f95227bc4b32ea8961c4f699ecf (diff) | |
| parent | 7888803ffed428438ed107d35a856647a46b347d (diff) | |
| download | pleroma-5bf59f8e66f0c341ee0e667c2d5d78f709f46af8.tar.gz pleroma-5bf59f8e66f0c341ee0e667c2d5d78f709f46af8.zip | |
Merge branch 'recipients-filter' into 'develop'
Mastodon API: Add the `recipients` parameter to `GET /api/v1/conversations`
See merge request pleroma/pleroma!1948
Diffstat (limited to 'test/web/mastodon_api/controllers')
| -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) | 
