Expose issue via failing test
[akkoma] / test / stats_test.exs
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.StatsTest do
6 use Pleroma.DataCase
7
8 import Pleroma.Factory
9
10 alias Pleroma.Web.CommonAPI
11
12 describe "statuses count" do
13 setup do
14 user = insert(:user)
15 other_user = insert(:user)
16
17 CommonAPI.post(user, %{"visibility" => "public", "status" => "hey"})
18
19 Enum.each(0..1, fn _ ->
20 CommonAPI.post(user, %{
21 "visibility" => "unlisted",
22 "status" => "hey"
23 })
24 end)
25
26 Enum.each(0..2, fn _ ->
27 CommonAPI.post(user, %{
28 "visibility" => "direct",
29 "status" => "hey @#{other_user.nickname}"
30 })
31 end)
32
33 Enum.each(0..3, fn _ ->
34 CommonAPI.post(user, %{
35 "visibility" => "private",
36 "status" => "hey"
37 })
38 end)
39
40 :ok
41 end
42
43 test "it returns total number of statuses" do
44 data = Pleroma.Stats.get_stat_data()
45
46 assert data.stats.status_count.all == 10
47 assert data.stats.status_count.public == 1
48 assert data.stats.status_count.unlisted == 2
49 assert data.stats.status_count.direct == 3
50 assert data.stats.status_count.private == 4
51 end
52 end
53 end