diff options
Diffstat (limited to 'test')
4 files changed, 26 insertions, 8 deletions
diff --git a/test/web/activity_pub/activity_pub_test.exs b/test/web/activity_pub/activity_pub_test.exs index 2c6f67621..5cfd46238 100644 --- a/test/web/activity_pub/activity_pub_test.exs +++ b/test/web/activity_pub/activity_pub_test.exs @@ -94,6 +94,20 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do assert length(activities) == 10 assert last == last_expected end + + test "retrieves ids up to max_id" do + _first_activities = ActivityBuilder.insert_list(10) + activities = ActivityBuilder.insert_list(20) + later_activities = ActivityBuilder.insert_list(10) + max_id = List.first(later_activities).id + last_expected = List.last(activities) + + activities = ActivityPub.fetch_public_activities(%{"max_id" => max_id}) + last = List.last(activities) + + assert length(activities) == 20 + assert last == last_expected + end end describe "uploading files" do diff --git a/test/web/twitter_api/representers/activity_representer_test.exs b/test/web/twitter_api/representers/activity_representer_test.exs index 256d920c0..f1f2b4c9c 100644 --- a/test/web/twitter_api/representers/activity_representer_test.exs +++ b/test/web/twitter_api/representers/activity_representer_test.exs @@ -23,8 +23,9 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do } } - content = "Some content mentioning @shp" - date = DateTime.utc_now() |> DateTime.to_iso8601 + content_html = "Some content mentioning <a href='shp'>@shp</shp>" + content = HtmlSanitizeEx.strip_tags(content_html) + date = DateTime.from_naive!(~N[2016-05-24 13:26:08.003], "Etc/UTC") |> DateTime.to_iso8601 activity = %Activity{ id: 1, @@ -39,7 +40,7 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do "object" => %{ "published" => date, "type" => "Note", - "content" => content, + "content" => content_html, "inReplyToStatusId" => 213123, "statusnetConversationId" => 4711, "attachment" => [ @@ -56,10 +57,10 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do "user" => UserRepresenter.to_map(user, %{for: follower}), "is_local" => true, "attentions" => [], - "statusnet_html" => content, + "statusnet_html" => content_html, "text" => content, "is_post_verb" => true, - "created_at" => date, + "created_at" => "Tue May 24 13:26:08 +0000 2016", "in_reply_to_status_id" => 213123, "statusnet_conversation_id" => 4711, "attachments" => [ diff --git a/test/web/twitter_api/twitter_api_controller_test.exs b/test/web/twitter_api/twitter_api_controller_test.exs index bead7a5a1..80ec9e4bb 100644 --- a/test/web/twitter_api/twitter_api_controller_test.exs +++ b/test/web/twitter_api/twitter_api_controller_test.exs @@ -127,7 +127,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do current_user = Repo.get(User, current_user.id) assert current_user.following == [User.ap_followers(followed)] - assert json_response(conn, 200) == UserRepresenter.to_map(followed) + assert json_response(conn, 200) == UserRepresenter.to_map(followed, %{for: current_user}) end end @@ -150,7 +150,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do current_user = Repo.get(User, current_user.id) assert current_user.following == [] - assert json_response(conn, 200) == UserRepresenter.to_map(followed) + assert json_response(conn, 200) == UserRepresenter.to_map(followed, %{for: current_user}) end end diff --git a/test/web/twitter_api/twitter_api_test.exs b/test/web/twitter_api/twitter_api_test.exs index ad932131a..e8853a910 100644 --- a/test/web/twitter_api/twitter_api_test.exs +++ b/test/web/twitter_api/twitter_api_test.exs @@ -82,15 +82,18 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do test "fetch friends' statuses" do ActivityBuilder.public_and_non_public + {:ok, activity} = ActivityBuilder.insert(%{"to" => ["someguy/followers"]}) + {:ok, direct_activity} = ActivityBuilder.insert(%{"to" => ["some other id"]}) {:ok, user} = UserBuilder.insert(%{ap_id: "some other id", following: ["someguy/followers"]}) statuses = TwitterAPI.fetch_friend_statuses(user) activity_user = Repo.get_by(User, ap_id: activity.data["actor"]) - assert length(statuses) == 1 + assert length(statuses) == 2 assert Enum.at(statuses, 0) == ActivityRepresenter.to_map(activity, %{user: activity_user}) + assert Enum.at(statuses, 1) == ActivityRepresenter.to_map(direct_activity, %{user: activity_user, mentioned: [user]}) end test "fetch a single status" do |