summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorEkaterina Vaartis <vaartis@cock.li>2019-09-10 21:16:30 +0300
committerEkaterina Vaartis <vaartis@cock.li>2019-09-19 00:16:33 +0300
commit9eb2ee4df0478daec1172eec2289868105b72756 (patch)
treef174ffac58a298cd8cc7b49df7ef4b2105aecdff /test
parent13cd93a0d314238427c217ec0ab8f59f329321f5 (diff)
downloadpleroma-9eb2ee4df0478daec1172eec2289868105b72756.tar.gz
pleroma-9eb2ee4df0478daec1172eec2289868105b72756.zip
Allow importing old (emoji.txt / plain) packs from the filesystem
Diffstat (limited to 'test')
-rw-r--r--test/instance_static/emoji/test_pack_for_import/blank.pngbin0 -> 95 bytes
-rw-r--r--test/web/emoji_api_controller_test.exs41
2 files changed, 41 insertions, 0 deletions
diff --git a/test/instance_static/emoji/test_pack_for_import/blank.png b/test/instance_static/emoji/test_pack_for_import/blank.png
new file mode 100644
index 000000000..8f50fa023
--- /dev/null
+++ b/test/instance_static/emoji/test_pack_for_import/blank.png
Binary files differ
diff --git a/test/web/emoji_api_controller_test.exs b/test/web/emoji_api_controller_test.exs
index fa194a26c..8b2a942ce 100644
--- a/test/web/emoji_api_controller_test.exs
+++ b/test/web/emoji_api_controller_test.exs
@@ -365,4 +365,45 @@ defmodule Pleroma.Web.EmojiAPI.EmojiAPIControllerTest do
refute File.exists?("#{@emoji_dir_path}/test_created/pack.json")
end
+
+ test "filesystem import" do
+ on_exit(fn ->
+ File.rm!("#{@emoji_dir_path}/test_pack_for_import/emoji.txt")
+ File.rm!("#{@emoji_dir_path}/test_pack_for_import/pack.json")
+ end)
+
+ conn = build_conn()
+ resp = conn |> get(emoji_api_path(conn, :list_packs)) |> json_response(200)
+
+ refute Map.has_key?(resp, "test_pack_for_import")
+
+ admin = insert(:user, info: %{is_admin: true})
+
+ assert conn
+ |> assign(:user, admin)
+ |> post(emoji_api_path(conn, :import_from_fs))
+ |> json_response(200) == ["test_pack_for_import"]
+
+ resp = conn |> get(emoji_api_path(conn, :list_packs)) |> json_response(200)
+ assert resp["test_pack_for_import"]["files"] == %{"blank" => "blank.png"}
+
+ File.rm!("#{@emoji_dir_path}/test_pack_for_import/pack.json")
+ refute File.exists?("#{@emoji_dir_path}/test_pack_for_import/pack.json")
+
+ emoji_txt_content = "blank, blank.png, Fun\n\nblank2, blank.png"
+
+ File.write!("#{@emoji_dir_path}/test_pack_for_import/emoji.txt", emoji_txt_content)
+
+ assert conn
+ |> assign(:user, admin)
+ |> post(emoji_api_path(conn, :import_from_fs))
+ |> json_response(200) == ["test_pack_for_import"]
+
+ resp = conn |> get(emoji_api_path(conn, :list_packs)) |> json_response(200)
+
+ assert resp["test_pack_for_import"]["files"] == %{
+ "blank" => "blank.png",
+ "blank2" => "blank.png"
+ }
+ end
end