1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.BBS.HandlerTest do
8 alias Pleroma.BBS.Handler
12 alias Pleroma.Web.CommonAPI
14 import ExUnit.CaptureIO
15 import Pleroma.Factory
18 test "getting the home timeline" do
20 followed = insert(:user)
22 {:ok, user} = User.follow(user, followed)
24 {:ok, _first} = CommonAPI.post(user, %{status: "hey"})
25 {:ok, _second} = CommonAPI.post(followed, %{status: "hello"})
29 Handler.handle_command(%{user: user}, "home")
32 assert output =~ user.nickname
33 assert output =~ followed.nickname
35 assert output =~ "hey"
36 assert output =~ "hello"
44 Handler.handle_command(%{user: user}, "p this is a test post")
47 assert output =~ "Posted"
52 where: fragment("?->>'type' = ?", a.data, "Create")
56 assert activity.actor == user.ap_id
57 object = Object.normalize(activity)
58 assert object.data["content"] == "this is a test post"
63 another_user = insert(:user)
65 {:ok, activity} = CommonAPI.post(another_user, %{status: "this is a test post"})
66 activity_object = Object.normalize(activity)
70 Handler.handle_command(%{user: user}, "r #{activity.id} this is a reply")
73 assert output =~ "Replied"
78 where: fragment("?->>'type' = ?", a.data, "Create"),
79 where: a.actor == ^user.ap_id
83 assert reply.actor == user.ap_id
85 reply_object_data = Object.normalize(reply).data
86 assert reply_object_data["content"] == "this is a reply"
87 assert reply_object_data["inReplyTo"] == activity_object.data["id"]