aboutsummaryrefslogtreecommitdiff
path: root/test/web/common_api
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2020-06-05 16:47:02 +0200
committerlain <lain@soykaf.club>2020-06-05 16:47:02 +0200
commit115d08a7542b92c5e1d889da41c0ee6837a1235e (patch)
tree9f1d3aa8a65f53d5a42b9ab64013c2d9a3296a19 /test/web/common_api
parent65689ba9bd44e291fc626cce2bd5136b93a5da90 (diff)
downloadpleroma-115d08a7542b92c5e1d889da41c0ee6837a1235e.tar.gz
Pipeline: Add a side effects step after the transaction finishes
This is to run things like streaming notifications out, which will sometimes need data that is created by the transaction, but is streamed out asynchronously.
Diffstat (limited to 'test/web/common_api')
-rw-r--r--test/web/common_api/common_api_test.exs45
1 files changed, 36 insertions, 9 deletions
diff --git a/test/web/common_api/common_api_test.exs b/test/web/common_api/common_api_test.exs
index 611a9ae66..63b59820e 100644
--- a/test/web/common_api/common_api_test.exs
+++ b/test/web/common_api/common_api_test.exs
@@ -7,6 +7,7 @@ defmodule Pleroma.Web.CommonAPITest do
alias Pleroma.Activity
alias Pleroma.Chat
alias Pleroma.Conversation.Participation
+ alias Pleroma.Notification
alias Pleroma.Object
alias Pleroma.User
alias Pleroma.Web.ActivityPub.ActivityPub
@@ -39,15 +40,41 @@ defmodule Pleroma.Web.CommonAPITest do
{:ok, upload} = ActivityPub.upload(file, actor: author.ap_id)
- {:ok, activity} =
- CommonAPI.post_chat_message(
- author,
- recipient,
- nil,
- media_id: upload.id
- )
-
- assert activity
+ with_mocks([
+ {
+ Pleroma.Web.Streamer,
+ [],
+ [
+ stream: fn _, _ ->
+ nil
+ end
+ ]
+ },
+ {
+ Pleroma.Web.Push,
+ [],
+ [
+ send: fn _ -> nil end
+ ]
+ }
+ ]) do
+ {:ok, activity} =
+ CommonAPI.post_chat_message(
+ author,
+ recipient,
+ nil,
+ media_id: upload.id
+ )
+
+ notification =
+ Notification.for_user_and_activity(recipient, activity)
+ |> Repo.preload(:activity)
+
+ assert called(Pleroma.Web.Push.send(notification))
+ assert called(Pleroma.Web.Streamer.stream(["user", "user:notification"], notification))
+
+ assert activity
+ end
end
test "it adds html newlines" do