Add test to cover rendering update with user

This commit is contained in:
tusooa 2023-04-01 08:47:46 -04:00
parent 050227f118
commit 4cf109d3c4
No known key found for this signature in database
GPG Key ID: 42AEC43D48433C51
1 changed files with 27 additions and 0 deletions

View File

@ -406,5 +406,32 @@ test "disconnect when token is revoked", %{app: app, user: user, token: token} d
assert_receive {:close, _} assert_receive {:close, _}
refute_receive {:close, _} refute_receive {:close, _}
end end
test "receives private statuses", %{user: reading_user, token: token} do
user = insert(:user)
CommonAPI.follow(reading_user, user)
{:ok, _} = start_socket("?stream=user&access_token=#{token.token}")
{:ok, activity} =
CommonAPI.post(user, %{status: "nice echo chamber", visibility: "private"})
assert_receive {:text, raw_json}, 1_000
assert {:ok, json} = Jason.decode(raw_json)
assert "update" == json["event"]
assert json["payload"]
assert {:ok, json} = Jason.decode(json["payload"])
view_json =
Pleroma.Web.MastodonAPI.StatusView.render("show.json",
activity: activity,
for: reading_user
)
|> Jason.encode!()
|> Jason.decode!()
assert json == view_json
end
end end
end end