Skip to content

Commit

Permalink
Test temp events with explicit client lists
Browse files Browse the repository at this point in the history
  • Loading branch information
pcapriotti committed Dec 11, 2024
1 parent a0fefcf commit 9e3e64a
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions integration/test/Test/Events.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Control.Retry
import Data.ByteString.Conversion (toByteString')
import qualified Data.Text as Text
import Data.Timeout
import MLS.Util
import qualified Network.WebSockets as WS
import Notifications
import SetupHelpers
Expand Down Expand Up @@ -85,6 +86,45 @@ testConsumeTempEvents = do

assertNoEvent ws

testMLSTempEvents :: (HasCallStack) => App ()
testMLSTempEvents = do
[alice, bob] <- createAndConnectUsers [OwnDomain, OwnDomain]
clients@[alice1, _, _] <-
traverse
( createMLSClient
def
def
{ clientArgs =
def
{ acapabilities = Just ["consumable-notifications"]
}
}
)
[alice, bob, bob]

traverse_ (uploadNewKeyPackage def) clients
convId <- createNewGroup def alice1

runCodensity (createEventsWebSocket bob Nothing) $ \ws -> do
commit <- createAddCommit alice1 convId [bob]
void $ postMLSCommitBundle commit.sender (mkBundle commit) >>= getJSON 201

-- FUTUREWORK: we should not rely on events arriving in this particular order

void $ assertEvent ws $ \e -> do
e %. "type" `shouldMatch` "event"
e %. "data.event.payload.0.type" `shouldMatch` "conversation.member-join"
user <- assertOne =<< (e %. "data.event.payload.0.data.users" & asList)
user %. "qualified_id" `shouldMatch` (bob %. "qualified_id")
ackEvent ws e

void $ assertEvent ws $ \e -> do
e %. "type" `shouldMatch` "event"
e %. "data.event.payload.0.type" `shouldMatch` "conversation.mls-welcome"
ackEvent ws e

assertNoEvent ws

testConsumeEventsForDifferentUsers :: (HasCallStack) => App ()
testConsumeEventsForDifferentUsers = do
alice <- randomUser OwnDomain def
Expand Down

0 comments on commit 9e3e64a

Please sign in to comment.