Add test for correct AP outbox pagination

This commit is contained in:
D Anzorge 2019-09-19 16:09:24 +02:00
parent 0e6085da10
commit 9aca2cc95d

View File

@ -142,4 +142,27 @@ test "sets correct totalItems when follows are hidden but the follow counter is
assert %{"totalItems" => 1} = UserView.render("following.json", %{user: user})
end
end
test "outbox paginates correctly" do
user = insert(:user)
posts =
for i <- 0..25 do
{:ok, activity} = CommonAPI.post(user, %{"status" => "post #{i}"})
activity
end
# outbox sorts chronologically, newest first, with ten per page
posts = Enum.reverse(posts)
%{"first" => %{"next" => next_url}} =
UserView.render("outbox.json", %{user: user, max_id: nil})
next_id = Enum.at(posts, 9).id
assert next_url =~ next_id
%{"next" => next_url} = UserView.render("outbox.json", %{user: user, max_id: next_id})
next_id = Enum.at(posts, 19).id
assert next_url =~ next_id
end
end