Add Tests

This commit is contained in:
Egor Kislitsyn 2019-05-14 20:12:47 +07:00
parent e82e73478e
commit d474995efa
4 changed files with 68 additions and 0 deletions

View File

@ -113,4 +113,33 @@ defmodule Pleroma.ListTest do
assert owned_list in lists_2
refute not_owned_list in lists_2
end
test "get ap_id by user nickname and list id" do
nickname = "foo"
list_id = 42
expected = Pleroma.Web.Endpoint.url() <> "/users/#{nickname}/lists/#{list_id}"
assert Pleroma.List.ap_id(%Pleroma.User{nickname: nickname}, list_id) == expected
assert Pleroma.List.ap_id({nickname, list_id}) == expected
end
test "get by ap_id" do
user = insert(:user)
{:ok, list} = Pleroma.List.create("foo", user)
ap_id = Pleroma.List.ap_id(user, list.id)
assert Pleroma.List.get_by_ap_id(ap_id) == list
end
test "memberships" do
user = insert(:user)
member = insert(:user)
{:ok, list} = Pleroma.List.create("foo", user)
{:ok, list} = Pleroma.List.follow(list, member)
list_ap_id = Pleroma.List.ap_id(user, list.id)
assert Pleroma.List.memberships(member) == [list_ap_id]
end
end

View File

@ -1156,6 +1156,20 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
end
end
test "fetch_activities/2 returns activities addressed to a list " do
user = insert(:user)
member = insert(:user)
{:ok, list} = Pleroma.List.create("foo", user)
{:ok, list} = Pleroma.List.follow(list, member)
{:ok, activity} =
CommonAPI.post(user, %{"status" => "foobar", "visibility" => "list:#{list.id}"})
activity = Repo.preload(activity, :bookmark)
assert ActivityPub.fetch_activities([], %{"user" => user}) == [activity]
end
def data_uri do
File.read!("test/fixtures/avatar_data_uri")
end

View File

@ -1028,6 +1028,18 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
assert modified["directMessage"] == true
end
test "it strips BCC field" do
user = insert(:user)
{:ok, list} = Pleroma.List.create("foo", user)
{:ok, activity} =
CommonAPI.post(user, %{"status" => "foobar", "visibility" => "list:#{list.id}"})
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
assert is_nil(modified["bcc"])
end
end
describe "user upgrade" do

View File

@ -87,6 +87,19 @@ defmodule Pleroma.Web.CommonAPITest do
assert object.data["content"] == "<p><b>2hu</b></p>alert('xss')"
end
test "it allows to address a list" do
user = insert(:user)
{:ok, list} = Pleroma.List.create("foo", user)
list_ap_id = Pleroma.List.ap_id(user, list.id)
{:ok, activity} =
CommonAPI.post(user, %{"status" => "foobar", "visibility" => "list:#{list.id}"})
assert activity.data["bcc"] == [list_ap_id]
assert activity.recipients == [list_ap_id, user.ap_id]
end
end
describe "reactions" do