1 defmodule Pleroma.BBS.HandlerTest do
4 alias Pleroma.BBS.Handler
5 alias Pleroma.Web.CommonAPI
9 import ExUnit.CaptureIO
10 import Pleroma.Factory
13 test "getting the home timeline" do
15 followed = insert(:user)
17 {:ok, user} = User.follow(user, followed)
19 {:ok, _first} = CommonAPI.post(user, %{"status" => "hey"})
20 {:ok, _second} = CommonAPI.post(followed, %{"status" => "hello"})
24 Handler.handle_command(%{user: user}, "home")
27 assert output =~ user.nickname
28 assert output =~ followed.nickname
30 assert output =~ "hey"
31 assert output =~ "hello"
39 Handler.handle_command(%{user: user}, "p this is a test post")
42 assert output =~ "Posted"
47 where: fragment("?->>'type' = ?", a.data, "Create")
51 assert activity.actor == user.ap_id
52 assert activity.data["object"]["content"] == "this is a test post"
57 another_user = insert(:user)
59 {:ok, activity} = CommonAPI.post(another_user, %{"status" => "this is a test post"})
63 Handler.handle_command(%{user: user}, "r #{activity.id} this is a reply")
66 assert output =~ "Replied"
71 where: fragment("?->>'type' = ?", a.data, "Create"),
72 where: a.actor == ^user.ap_id
76 assert reply.actor == user.ap_id
77 assert reply.data["object"]["content"] == "this is a reply"
78 assert reply.data["object"]["inReplyTo"] == activity.data["object"]["id"]