1 defmodule Pleroma.BBS.HandlerTest do
4 alias Pleroma.BBS.Handler
8 alias Pleroma.Web.CommonAPI
10 import ExUnit.CaptureIO
11 import Pleroma.Factory
14 test "getting the home timeline" do
16 followed = insert(:user)
18 {:ok, user} = User.follow(user, followed)
20 {:ok, _first} = CommonAPI.post(user, %{"status" => "hey"})
21 {:ok, _second} = CommonAPI.post(followed, %{"status" => "hello"})
25 Handler.handle_command(%{user: user}, "home")
28 assert output =~ user.nickname
29 assert output =~ followed.nickname
31 assert output =~ "hey"
32 assert output =~ "hello"
40 Handler.handle_command(%{user: user}, "p this is a test post")
43 assert output =~ "Posted"
48 where: fragment("?->>'type' = ?", a.data, "Create")
52 assert activity.actor == user.ap_id
53 object = Object.normalize(activity)
54 assert object.data["content"] == "this is a test post"
59 another_user = insert(:user)
61 {:ok, activity} = CommonAPI.post(another_user, %{"status" => "this is a test post"})
65 Handler.handle_command(%{user: user}, "r #{activity.id} this is a reply")
68 assert output =~ "Replied"
73 where: fragment("?->>'type' = ?", a.data, "Create"),
74 where: a.actor == ^user.ap_id
78 assert reply.actor == user.ap_id
79 object = Object.normalize(reply)
80 assert object.data["content"] == "this is a reply"
81 assert object.data["inReplyTo"] == activity.data["object"]