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.Web.PleromaAPI.EmojiPackControllerTest do
6 use Pleroma.Web.ConnCase
11 @emoji_path Path.join(
12 Pleroma.Config.get!([:instance, :static_dir]),
15 setup do: clear_config([:auth, :enforce_oauth_admin_scope_usage], false)
17 setup do: clear_config([:instance, :public], true)
20 admin = insert(:user, is_admin: true)
21 token = insert(:oauth_admin_token, user: admin)
25 |> assign(:user, admin)
26 |> assign(:token, token)
28 Pleroma.Emoji.reload()
29 {:ok, %{admin_conn: admin_conn}}
32 test "GET /api/pleroma/emoji/packs when :public: false", %{conn: conn} do
33 Config.put([:instance, :public], false)
34 conn |> get("/api/pleroma/emoji/packs") |> json_response_and_validate_schema(200)
37 test "GET /api/pleroma/emoji/packs", %{conn: conn} do
38 resp = conn |> get("/api/pleroma/emoji/packs") |> json_response_and_validate_schema(200)
40 assert resp["count"] == 3
46 shared = resp["packs"]["test_pack"]
47 assert shared["files"] == %{"blank" => "blank.png", "blank2" => "blank2.png"}
48 assert Map.has_key?(shared["pack"], "download-sha256")
49 assert shared["pack"]["can-download"]
50 assert shared["pack"]["share-files"]
52 non_shared = resp["packs"]["test_pack_nonshared"]
53 assert non_shared["pack"]["share-files"] == false
54 assert non_shared["pack"]["can-download"] == false
58 |> get("/api/pleroma/emoji/packs?page_size=1")
59 |> json_response_and_validate_schema(200)
61 assert resp["count"] == 3
63 packs = Map.keys(resp["packs"])
65 assert length(packs) == 1
71 |> get("/api/pleroma/emoji/packs?page_size=1&page=2")
72 |> json_response_and_validate_schema(200)
74 assert resp["count"] == 3
75 packs = Map.keys(resp["packs"])
76 assert length(packs) == 1
81 |> get("/api/pleroma/emoji/packs?page_size=1&page=3")
82 |> json_response_and_validate_schema(200)
84 assert resp["count"] == 3
85 packs = Map.keys(resp["packs"])
86 assert length(packs) == 1
88 assert [pack1, pack2, pack3] |> Enum.uniq() |> length() == 3
91 describe "GET /api/pleroma/emoji/packs/remote" do
92 test "shareable instance", %{admin_conn: admin_conn, conn: conn} do
95 |> get("/api/pleroma/emoji/packs")
96 |> json_response_and_validate_schema(200)
99 %{method: :get, url: "https://example.com/.well-known/nodeinfo"} ->
100 json(%{links: [%{href: "https://example.com/nodeinfo/2.1.json"}]})
102 %{method: :get, url: "https://example.com/nodeinfo/2.1.json"} ->
103 json(%{metadata: %{features: ["shareable_emoji_packs"]}})
105 %{method: :get, url: "https://example.com/api/pleroma/emoji/packs"} ->
110 |> get("/api/pleroma/emoji/packs/remote?url=https://example.com")
111 |> json_response_and_validate_schema(200) == resp
114 test "non shareable instance", %{admin_conn: admin_conn} do
116 %{method: :get, url: "https://example.com/.well-known/nodeinfo"} ->
117 json(%{links: [%{href: "https://example.com/nodeinfo/2.1.json"}]})
119 %{method: :get, url: "https://example.com/nodeinfo/2.1.json"} ->
120 json(%{metadata: %{features: []}})
124 |> get("/api/pleroma/emoji/packs/remote?url=https://example.com")
125 |> json_response_and_validate_schema(500) == %{
126 "error" => "The requested instance does not support sharing emoji packs"
131 describe "GET /api/pleroma/emoji/packs/:name/archive" do
132 test "download shared pack", %{conn: conn} do
135 |> get("/api/pleroma/emoji/packs/test_pack/archive")
138 {:ok, arch} = :zip.unzip(resp, [:memory])
140 assert Enum.find(arch, fn {n, _} -> n == 'pack.json' end)
141 assert Enum.find(arch, fn {n, _} -> n == 'blank.png' end)
144 test "non existing pack", %{conn: conn} do
146 |> get("/api/pleroma/emoji/packs/test_pack_for_import/archive")
147 |> json_response_and_validate_schema(:not_found) == %{
148 "error" => "Pack test_pack_for_import does not exist"
152 test "non downloadable pack", %{conn: conn} do
154 |> get("/api/pleroma/emoji/packs/test_pack_nonshared/archive")
155 |> json_response_and_validate_schema(:forbidden) == %{
157 "Pack test_pack_nonshared cannot be downloaded from this instance, either pack sharing was disabled for this pack or some files are missing"
162 describe "POST /api/pleroma/emoji/packs/download" do
163 test "shared pack from remote and non shared from fallback-src", %{
164 admin_conn: admin_conn,
168 %{method: :get, url: "https://example.com/.well-known/nodeinfo"} ->
169 json(%{links: [%{href: "https://example.com/nodeinfo/2.1.json"}]})
171 %{method: :get, url: "https://example.com/nodeinfo/2.1.json"} ->
172 json(%{metadata: %{features: ["shareable_emoji_packs"]}})
176 url: "https://example.com/api/pleroma/emoji/packs/test_pack"
179 |> get("/api/pleroma/emoji/packs/test_pack")
180 |> json_response_and_validate_schema(200)
185 url: "https://example.com/api/pleroma/emoji/packs/test_pack/archive"
188 |> get("/api/pleroma/emoji/packs/test_pack/archive")
194 url: "https://example.com/api/pleroma/emoji/packs/test_pack_nonshared"
197 |> get("/api/pleroma/emoji/packs/test_pack_nonshared")
198 |> json_response_and_validate_schema(200)
203 url: "https://nonshared-pack"
205 text(File.read!("#{@emoji_path}/test_pack_nonshared/nonshared.zip"))
209 |> put_req_header("content-type", "multipart/form-data")
210 |> post("/api/pleroma/emoji/packs/download", %{
211 url: "https://example.com",
215 |> json_response_and_validate_schema(200) == "ok"
217 assert File.exists?("#{@emoji_path}/test_pack2/pack.json")
218 assert File.exists?("#{@emoji_path}/test_pack2/blank.png")
221 |> delete("/api/pleroma/emoji/packs/test_pack2")
222 |> json_response_and_validate_schema(200) == "ok"
224 refute File.exists?("#{@emoji_path}/test_pack2")
227 |> put_req_header("content-type", "multipart/form-data")
229 "/api/pleroma/emoji/packs/download",
231 url: "https://example.com",
232 name: "test_pack_nonshared",
233 as: "test_pack_nonshared2"
236 |> json_response_and_validate_schema(200) == "ok"
238 assert File.exists?("#{@emoji_path}/test_pack_nonshared2/pack.json")
239 assert File.exists?("#{@emoji_path}/test_pack_nonshared2/blank.png")
242 |> delete("/api/pleroma/emoji/packs/test_pack_nonshared2")
243 |> json_response_and_validate_schema(200) == "ok"
245 refute File.exists?("#{@emoji_path}/test_pack_nonshared2")
248 test "nonshareable instance", %{admin_conn: admin_conn} do
250 %{method: :get, url: "https://old-instance/.well-known/nodeinfo"} ->
251 json(%{links: [%{href: "https://old-instance/nodeinfo/2.1.json"}]})
253 %{method: :get, url: "https://old-instance/nodeinfo/2.1.json"} ->
254 json(%{metadata: %{features: []}})
258 |> put_req_header("content-type", "multipart/form-data")
260 "/api/pleroma/emoji/packs/download",
262 url: "https://old-instance",
267 |> json_response_and_validate_schema(500) == %{
268 "error" => "The requested instance does not support sharing emoji packs"
272 test "checksum fail", %{admin_conn: admin_conn} do
274 %{method: :get, url: "https://example.com/.well-known/nodeinfo"} ->
275 json(%{links: [%{href: "https://example.com/nodeinfo/2.1.json"}]})
277 %{method: :get, url: "https://example.com/nodeinfo/2.1.json"} ->
278 json(%{metadata: %{features: ["shareable_emoji_packs"]}})
282 url: "https://example.com/api/pleroma/emoji/packs/pack_bad_sha"
284 {:ok, pack} = Pleroma.Emoji.Pack.load_pack("pack_bad_sha")
285 %Tesla.Env{status: 200, body: Jason.encode!(pack)}
289 url: "https://example.com/api/pleroma/emoji/packs/pack_bad_sha/archive"
293 body: File.read!("test/instance_static/emoji/pack_bad_sha/pack_bad_sha.zip")
298 |> put_req_header("content-type", "multipart/form-data")
299 |> post("/api/pleroma/emoji/packs/download", %{
300 url: "https://example.com",
301 name: "pack_bad_sha",
304 |> json_response_and_validate_schema(:internal_server_error) == %{
305 "error" => "SHA256 for the pack doesn't match the one sent by the server"
309 test "other error", %{admin_conn: admin_conn} do
311 %{method: :get, url: "https://example.com/.well-known/nodeinfo"} ->
312 json(%{links: [%{href: "https://example.com/nodeinfo/2.1.json"}]})
314 %{method: :get, url: "https://example.com/nodeinfo/2.1.json"} ->
315 json(%{metadata: %{features: ["shareable_emoji_packs"]}})
319 url: "https://example.com/api/pleroma/emoji/packs/test_pack"
321 {:ok, pack} = Pleroma.Emoji.Pack.load_pack("test_pack")
322 %Tesla.Env{status: 200, body: Jason.encode!(pack)}
326 |> put_req_header("content-type", "multipart/form-data")
327 |> post("/api/pleroma/emoji/packs/download", %{
328 url: "https://example.com",
332 |> json_response_and_validate_schema(:internal_server_error) == %{
334 "The pack was not set as shared and there is no fallback src to download from"
339 describe "PATCH /api/pleroma/emoji/packs/:name" do
341 pack_file = "#{@emoji_path}/test_pack/pack.json"
342 original_content = File.read!(pack_file)
345 File.write!(pack_file, original_content)
349 pack_file: pack_file,
351 "license" => "Test license changed",
352 "homepage" => "https://pleroma.social",
353 "description" => "Test description",
354 "share-files" => false
358 test "for a pack without a fallback source", ctx do
359 assert ctx[:admin_conn]
360 |> put_req_header("content-type", "multipart/form-data")
361 |> patch("/api/pleroma/emoji/packs/test_pack", %{"metadata" => ctx[:new_data]})
362 |> json_response_and_validate_schema(200) == ctx[:new_data]
364 assert Jason.decode!(File.read!(ctx[:pack_file]))["pack"] == ctx[:new_data]
367 test "for a pack with a fallback source", ctx do
371 url: "https://nonshared-pack"
373 text(File.read!("#{@emoji_path}/test_pack_nonshared/nonshared.zip"))
376 new_data = Map.put(ctx[:new_data], "fallback-src", "https://nonshared-pack")
381 "fallback-src-sha256",
382 "1967BB4E42BCC34BCC12D57BE7811D3B7BE52F965BCE45C87BD377B9499CE11D"
385 assert ctx[:admin_conn]
386 |> put_req_header("content-type", "multipart/form-data")
387 |> patch("/api/pleroma/emoji/packs/test_pack", %{metadata: new_data})
388 |> json_response_and_validate_schema(200) == new_data_with_sha
390 assert Jason.decode!(File.read!(ctx[:pack_file]))["pack"] == new_data_with_sha
393 test "when the fallback source doesn't have all the files", ctx do
397 url: "https://nonshared-pack"
399 {:ok, {'empty.zip', empty_arch}} = :zip.zip('empty.zip', [], [:memory])
403 new_data = Map.put(ctx[:new_data], "fallback-src", "https://nonshared-pack")
405 assert ctx[:admin_conn]
406 |> put_req_header("content-type", "multipart/form-data")
407 |> patch("/api/pleroma/emoji/packs/test_pack", %{metadata: new_data})
408 |> json_response_and_validate_schema(:bad_request) == %{
409 "error" => "The fallback archive does not have all files specified in pack.json"
414 describe "POST/PATCH/DELETE /api/pleroma/emoji/packs/:name/files" do
416 pack_file = "#{@emoji_path}/test_pack/pack.json"
417 original_content = File.read!(pack_file)
420 File.write!(pack_file, original_content)
426 test "create shortcode exists", %{admin_conn: admin_conn} do
428 |> put_req_header("content-type", "multipart/form-data")
429 |> post("/api/pleroma/emoji/packs/test_pack/files", %{
431 filename: "dir/blank.png",
433 filename: "blank.png",
434 path: "#{@emoji_path}/test_pack/blank.png"
437 |> json_response_and_validate_schema(:conflict) == %{
438 "error" => "An emoji with the \"blank\" shortcode already exists"
442 test "don't rewrite old emoji", %{admin_conn: admin_conn} do
443 on_exit(fn -> File.rm_rf!("#{@emoji_path}/test_pack/dir/") end)
446 |> put_req_header("content-type", "multipart/form-data")
447 |> post("/api/pleroma/emoji/packs/test_pack/files", %{
449 filename: "dir/blank.png",
451 filename: "blank.png",
452 path: "#{@emoji_path}/test_pack/blank.png"
455 |> json_response_and_validate_schema(200) == %{
456 "blank" => "blank.png",
457 "blank2" => "blank2.png",
458 "blank3" => "dir/blank.png"
461 assert File.exists?("#{@emoji_path}/test_pack/dir/blank.png")
464 |> put_req_header("content-type", "multipart/form-data")
465 |> patch("/api/pleroma/emoji/packs/test_pack/files", %{
467 new_shortcode: "blank2",
468 new_filename: "dir_2/blank_3.png"
470 |> json_response_and_validate_schema(:conflict) == %{
472 "New shortcode \"blank2\" is already used. If you want to override emoji use 'force' option"
476 test "rewrite old emoji with force option", %{admin_conn: admin_conn} do
477 on_exit(fn -> File.rm_rf!("#{@emoji_path}/test_pack/dir_2/") end)
480 |> put_req_header("content-type", "multipart/form-data")
481 |> post("/api/pleroma/emoji/packs/test_pack/files", %{
483 filename: "dir/blank.png",
485 filename: "blank.png",
486 path: "#{@emoji_path}/test_pack/blank.png"
489 |> json_response_and_validate_schema(200) == %{
490 "blank" => "blank.png",
491 "blank2" => "blank2.png",
492 "blank3" => "dir/blank.png"
495 assert File.exists?("#{@emoji_path}/test_pack/dir/blank.png")
498 |> put_req_header("content-type", "multipart/form-data")
499 |> patch("/api/pleroma/emoji/packs/test_pack/files", %{
501 new_shortcode: "blank4",
502 new_filename: "dir_2/blank_3.png",
505 |> json_response_and_validate_schema(200) == %{
506 "blank" => "blank.png",
507 "blank2" => "blank2.png",
508 "blank4" => "dir_2/blank_3.png"
511 assert File.exists?("#{@emoji_path}/test_pack/dir_2/blank_3.png")
514 test "with empty filename", %{admin_conn: admin_conn} do
516 |> put_req_header("content-type", "multipart/form-data")
517 |> post("/api/pleroma/emoji/packs/test_pack/files", %{
521 filename: "blank.png",
522 path: "#{@emoji_path}/test_pack/blank.png"
525 |> json_response_and_validate_schema(:bad_request) == %{
526 "error" => "pack name, shortcode or filename cannot be empty"
530 test "add file with not loaded pack", %{admin_conn: admin_conn} do
532 |> put_req_header("content-type", "multipart/form-data")
533 |> post("/api/pleroma/emoji/packs/not_loaded/files", %{
535 filename: "dir/blank.png",
537 filename: "blank.png",
538 path: "#{@emoji_path}/test_pack/blank.png"
541 |> json_response_and_validate_schema(:bad_request) == %{
542 "error" => "pack \"not_loaded\" is not found"
546 test "remove file with not loaded pack", %{admin_conn: admin_conn} do
548 |> delete("/api/pleroma/emoji/packs/not_loaded/files?shortcode=blank3")
549 |> json_response_and_validate_schema(:bad_request) == %{
550 "error" => "pack \"not_loaded\" is not found"
554 test "remove file with empty shortcode", %{admin_conn: admin_conn} do
556 |> delete("/api/pleroma/emoji/packs/not_loaded/files?shortcode=")
557 |> json_response_and_validate_schema(:bad_request) == %{
558 "error" => "pack name or shortcode cannot be empty"
562 test "update file with not loaded pack", %{admin_conn: admin_conn} do
564 |> put_req_header("content-type", "multipart/form-data")
565 |> patch("/api/pleroma/emoji/packs/not_loaded/files", %{
567 new_shortcode: "blank3",
568 new_filename: "dir_2/blank_3.png"
570 |> json_response_and_validate_schema(:bad_request) == %{
571 "error" => "pack \"not_loaded\" is not found"
575 test "new with shortcode as file with update", %{admin_conn: admin_conn} do
577 |> put_req_header("content-type", "multipart/form-data")
578 |> post("/api/pleroma/emoji/packs/test_pack/files", %{
580 filename: "dir/blank.png",
582 filename: "blank.png",
583 path: "#{@emoji_path}/test_pack/blank.png"
586 |> json_response_and_validate_schema(200) == %{
587 "blank" => "blank.png",
588 "blank4" => "dir/blank.png",
589 "blank2" => "blank2.png"
592 assert File.exists?("#{@emoji_path}/test_pack/dir/blank.png")
595 |> put_req_header("content-type", "multipart/form-data")
596 |> patch("/api/pleroma/emoji/packs/test_pack/files", %{
598 new_shortcode: "blank3",
599 new_filename: "dir_2/blank_3.png"
601 |> json_response_and_validate_schema(200) == %{
602 "blank3" => "dir_2/blank_3.png",
603 "blank" => "blank.png",
604 "blank2" => "blank2.png"
607 refute File.exists?("#{@emoji_path}/test_pack/dir/")
608 assert File.exists?("#{@emoji_path}/test_pack/dir_2/blank_3.png")
611 |> delete("/api/pleroma/emoji/packs/test_pack/files?shortcode=blank3")
612 |> json_response_and_validate_schema(200) == %{
613 "blank" => "blank.png",
614 "blank2" => "blank2.png"
617 refute File.exists?("#{@emoji_path}/test_pack/dir_2/")
619 on_exit(fn -> File.rm_rf!("#{@emoji_path}/test_pack/dir") end)
622 test "new with shortcode from url", %{admin_conn: admin_conn} do
626 url: "https://test-blank/blank_url.png"
628 text(File.read!("#{@emoji_path}/test_pack/blank.png"))
632 |> put_req_header("content-type", "multipart/form-data")
633 |> post("/api/pleroma/emoji/packs/test_pack/files", %{
634 shortcode: "blank_url",
635 file: "https://test-blank/blank_url.png"
637 |> json_response_and_validate_schema(200) == %{
638 "blank_url" => "blank_url.png",
639 "blank" => "blank.png",
640 "blank2" => "blank2.png"
643 assert File.exists?("#{@emoji_path}/test_pack/blank_url.png")
645 on_exit(fn -> File.rm_rf!("#{@emoji_path}/test_pack/blank_url.png") end)
648 test "new without shortcode", %{admin_conn: admin_conn} do
649 on_exit(fn -> File.rm_rf!("#{@emoji_path}/test_pack/shortcode.png") end)
652 |> put_req_header("content-type", "multipart/form-data")
653 |> post("/api/pleroma/emoji/packs/test_pack/files", %{
655 filename: "shortcode.png",
656 path: "#{Pleroma.Config.get([:instance, :static_dir])}/add/shortcode.png"
659 |> json_response_and_validate_schema(200) == %{
660 "shortcode" => "shortcode.png",
661 "blank" => "blank.png",
662 "blank2" => "blank2.png"
666 test "remove non existing shortcode in pack.json", %{admin_conn: admin_conn} do
668 |> delete("/api/pleroma/emoji/packs/test_pack/files?shortcode=blank3")
669 |> json_response_and_validate_schema(:bad_request) == %{
670 "error" => "Emoji \"blank3\" does not exist"
674 test "update non existing emoji", %{admin_conn: admin_conn} do
676 |> put_req_header("content-type", "multipart/form-data")
677 |> patch("/api/pleroma/emoji/packs/test_pack/files", %{
679 new_shortcode: "blank4",
680 new_filename: "dir_2/blank_3.png"
682 |> json_response_and_validate_schema(:bad_request) == %{
683 "error" => "Emoji \"blank3\" does not exist"
687 test "update with empty shortcode", %{admin_conn: admin_conn} do
689 "error" => "Missing field: new_shortcode."
692 |> put_req_header("content-type", "multipart/form-data")
693 |> patch("/api/pleroma/emoji/packs/test_pack/files", %{
695 new_filename: "dir_2/blank_3.png"
697 |> json_response_and_validate_schema(:bad_request)
701 describe "POST/DELETE /api/pleroma/emoji/packs/:name" do
702 test "creating and deleting a pack", %{admin_conn: admin_conn} do
704 |> post("/api/pleroma/emoji/packs/test_created")
705 |> json_response_and_validate_schema(200) == "ok"
707 assert File.exists?("#{@emoji_path}/test_created/pack.json")
709 assert Jason.decode!(File.read!("#{@emoji_path}/test_created/pack.json")) == %{
716 |> delete("/api/pleroma/emoji/packs/test_created")
717 |> json_response_and_validate_schema(200) == "ok"
719 refute File.exists?("#{@emoji_path}/test_created/pack.json")
722 test "if pack exists", %{admin_conn: admin_conn} do
723 path = Path.join(@emoji_path, "test_created")
725 pack_file = Jason.encode!(%{files: %{}, pack: %{}})
726 File.write!(Path.join(path, "pack.json"), pack_file)
729 |> post("/api/pleroma/emoji/packs/test_created")
730 |> json_response_and_validate_schema(:conflict) == %{
731 "error" => "A pack named \"test_created\" already exists"
734 on_exit(fn -> File.rm_rf(path) end)
737 test "with empty name", %{admin_conn: admin_conn} do
739 |> post("/api/pleroma/emoji/packs/ ")
740 |> json_response_and_validate_schema(:bad_request) == %{
741 "error" => "pack name cannot be empty"
746 test "deleting nonexisting pack", %{admin_conn: admin_conn} do
748 |> delete("/api/pleroma/emoji/packs/non_existing")
749 |> json_response_and_validate_schema(:not_found) == %{
750 "error" => "Pack non_existing does not exist"
754 test "deleting with empty name", %{admin_conn: admin_conn} do
756 |> delete("/api/pleroma/emoji/packs/ ")
757 |> json_response_and_validate_schema(:bad_request) == %{
758 "error" => "pack name cannot be empty"
762 test "filesystem import", %{admin_conn: admin_conn, conn: conn} do
764 File.rm!("#{@emoji_path}/test_pack_for_import/emoji.txt")
765 File.rm!("#{@emoji_path}/test_pack_for_import/pack.json")
768 resp = conn |> get("/api/pleroma/emoji/packs") |> json_response_and_validate_schema(200)
770 refute Map.has_key?(resp["packs"], "test_pack_for_import")
773 |> get("/api/pleroma/emoji/packs/import")
774 |> json_response_and_validate_schema(200) == ["test_pack_for_import"]
776 resp = conn |> get("/api/pleroma/emoji/packs") |> json_response_and_validate_schema(200)
777 assert resp["packs"]["test_pack_for_import"]["files"] == %{"blank" => "blank.png"}
779 File.rm!("#{@emoji_path}/test_pack_for_import/pack.json")
780 refute File.exists?("#{@emoji_path}/test_pack_for_import/pack.json")
782 emoji_txt_content = """
783 blank, blank.png, Fun
785 foo, /emoji/test_pack_for_import/blank.png
789 File.write!("#{@emoji_path}/test_pack_for_import/emoji.txt", emoji_txt_content)
792 |> get("/api/pleroma/emoji/packs/import")
793 |> json_response_and_validate_schema(200) == ["test_pack_for_import"]
795 resp = conn |> get("/api/pleroma/emoji/packs") |> json_response_and_validate_schema(200)
797 assert resp["packs"]["test_pack_for_import"]["files"] == %{
798 "blank" => "blank.png",
799 "blank2" => "blank.png",
804 describe "GET /api/pleroma/emoji/packs/:name" do
805 test "shows pack.json", %{conn: conn} do
810 "can-download" => true,
811 "description" => "Test description",
812 "download-sha256" => _,
813 "homepage" => "https://pleroma.social",
814 "license" => "Test license",
815 "share-files" => true
819 |> get("/api/pleroma/emoji/packs/test_pack")
820 |> json_response_and_validate_schema(200)
822 assert files == %{"blank" => "blank.png", "blank2" => "blank2.png"}
829 |> get("/api/pleroma/emoji/packs/test_pack?page_size=1")
830 |> json_response_and_validate_schema(200)
832 assert files |> Map.keys() |> length() == 1
839 |> get("/api/pleroma/emoji/packs/test_pack?page_size=1&page=2")
840 |> json_response_and_validate_schema(200)
842 assert files |> Map.keys() |> length() == 1
845 test "non existing pack", %{conn: conn} do
847 |> get("/api/pleroma/emoji/packs/non_existing")
848 |> json_response_and_validate_schema(:not_found) == %{
849 "error" => "Pack non_existing does not exist"
853 test "error name", %{conn: conn} do
855 |> get("/api/pleroma/emoji/packs/ ")
856 |> json_response_and_validate_schema(:bad_request) == %{
857 "error" => "pack name cannot be empty"