Add Tests
This commit is contained in:
parent
e82e73478e
commit
d474995efa
|
@ -113,4 +113,33 @@ test "getting own lists a given user belongs to" do
|
||||||
assert owned_list in lists_2
|
assert owned_list in lists_2
|
||||||
refute not_owned_list in lists_2
|
refute not_owned_list in lists_2
|
||||||
end
|
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
|
end
|
||||||
|
|
|
@ -1156,6 +1156,20 @@ test "it can create a Flag activity" do
|
||||||
end
|
end
|
||||||
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
|
def data_uri do
|
||||||
File.read!("test/fixtures/avatar_data_uri")
|
File.read!("test/fixtures/avatar_data_uri")
|
||||||
end
|
end
|
||||||
|
|
|
@ -1028,6 +1028,18 @@ test "the directMessage flag is present" do
|
||||||
|
|
||||||
assert modified["directMessage"] == true
|
assert modified["directMessage"] == true
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
describe "user upgrade" do
|
describe "user upgrade" do
|
||||||
|
|
|
@ -87,6 +87,19 @@ test "it filters out obviously bad tags when accepting a post as Markdown" do
|
||||||
|
|
||||||
assert object.data["content"] == "<p><b>2hu</b></p>alert('xss')"
|
assert object.data["content"] == "<p><b>2hu</b></p>alert('xss')"
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
describe "reactions" do
|
describe "reactions" do
|
||||||
|
|
Loading…
Reference in New Issue