test: twitterapi: fix the test breakage for real
[akkoma] / test / web / twitter_api / util_controller_test.exs
1 defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do
2 use Pleroma.Web.ConnCase
3
4 import Pleroma.Factory
5
6 describe "POST /api/pleroma/follow_import" do
7 test "it returns HTTP 200", %{conn: conn} do
8 user1 = insert(:user)
9 user2 = insert(:user)
10
11 response =
12 conn
13 |> assign(:user, user1)
14 |> post("/api/pleroma/follow_import", %{"list" => "#{user2.ap_id}"})
15 |> json_response(:ok)
16
17 assert response == "job started"
18 end
19 end
20
21 describe "POST /api/pleroma/blocks_import" do
22 test "it returns HTTP 200", %{conn: conn} do
23 user1 = insert(:user)
24 user2 = insert(:user)
25
26 response =
27 conn
28 |> assign(:user, user1)
29 |> post("/api/pleroma/blocks_import", %{"list" => "#{user2.ap_id}"})
30 |> json_response(:ok)
31
32 assert response == "job started"
33 end
34 end
35
36 describe "GET /api/statusnet/config.json" do
37 test "it returns the managed config", %{conn: conn} do
38 Pleroma.Config.put([:instance, :managed_config], false)
39 Pleroma.Config.put([:fe, :theme], "rei-ayanami-towel")
40
41 response =
42 conn
43 |> get("/api/statusnet/config.json")
44 |> json_response(:ok)
45
46 refute response["site"]["pleromafe"]
47
48 Pleroma.Config.put([:instance, :managed_config], true)
49
50 response =
51 conn
52 |> get("/api/statusnet/config.json")
53 |> json_response(:ok)
54
55 assert response["site"]["pleromafe"]
56 end
57
58 test "if :pleroma, :fe is false, it returns the new style config settings", %{conn: conn} do
59 Pleroma.Config.put([:instance, :managed_config], true)
60 Pleroma.Config.put([:fe, :theme], "rei-ayanami-towel")
61 Pleroma.Config.put([:frontend_configurations, :pleroma_fe], %{theme: "asuka-hospital"})
62
63 response =
64 conn
65 |> get("/api/statusnet/config.json")
66 |> json_response(:ok)
67
68 assert response["site"]["pleromafe"]["theme"] == "rei-ayanami-towel"
69
70 Pleroma.Config.put([:fe], false)
71
72 response =
73 conn
74 |> get("/api/statusnet/config.json")
75 |> json_response(:ok)
76
77 assert response["site"]["pleromafe"]["theme"] == "asuka-hospital"
78 end
79 end
80
81 describe "GET /api/pleroma/frontend_configurations" do
82 test "returns everything in :pleroma, :frontend_configurations", %{conn: conn} do
83 config = [
84 frontend_a: %{
85 x: 1,
86 y: 2
87 },
88 frontend_b: %{
89 z: 3
90 }
91 ]
92
93 Pleroma.Config.put(:frontend_configurations, config)
94
95 response =
96 conn
97 |> get("/api/pleroma/frontend_configurations")
98 |> json_response(:ok)
99
100 assert response == Jason.encode!(config |> Enum.into(%{})) |> Jason.decode!()
101 end
102 end
103 end