Conversations: Make tests run.
[akkoma] / test / web / mastodon_api / mastodon_api_controller_test.exs
index 9e19fb48e2186aa7152f78fdeda3930ed71fce6c..d1d22edde5e47f3a9f5a24acf841d958e5ed42f6 100644 (file)
@@ -320,35 +320,39 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
 
     res_conn =
       conn
-      |> assign(:user, user)
+      |> 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
-           } = reponse
+    assert [
+             %{
+               "id" => res_id,
+               "accounts" => res_accounts,
+               "last_status" => res_last_status,
+               "unread" => unread
+             }
+           ] = response
 
-    assert unread == false
+    assert unread == true
+    assert res_last_status == direct.id
 
     # Apparently undocumented API endpoint
     res_conn =
       conn
-      |> assign(:user, user)
-      |> get("/api/v1/conversations/#{res_id}/read")
+      |> assign(:user, user_one)
+      |> post("/api/v1/conversations/#{res_id}/read")
 
-    assert response == json_response(res_conn, 200)
+    assert response = json_response(res_conn, 200)
+    assert response["unread"] == false
 
     # (vanilla) Mastodon frontend behaviour
     res_conn =
       conn
-      |> assign(:user, user)
-      |> get("/api/v1/statuses/#{res_last_status.id}/context")
+      |> assign(:user, user_one)
+      |> get("/api/v1/statuses/#{res_last_status}/context")
 
-    assert %{ancestors: [], descendants: []} == json_response(res_conn, 200)
+    assert %{"ancestors" => [], "descendants" => []} == json_response(res_conn, 200)
   end
 
   test "doesn't include DMs from blocked users", %{conn: conn} do