Skip to content

Commit

Permalink
WIP: Migrate test testAddRemoteUsersToLocalConv
Browse files Browse the repository at this point in the history
  • Loading branch information
mdimjasevic committed Sep 15, 2023
1 parent 85a2f40 commit e07188e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
18 changes: 18 additions & 0 deletions integration/test/API/Galley.hs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,24 @@ addMembers usr qcnv newMembers = do
req <- baseRequest usr Galley Versioned (joinHttpPath ["conversations", convDomain, convId, "members"])
submit "POST" (req & addJSONObject ["qualified_users" .= qUsers])

addMembersV1 :: (HasCallStack, MakesValue user, MakesValue conv) => user -> conv -> Maybe String -> [Value] -> App Response
addMembersV1 usr cnv role newMembers = do
cnvId <- objId cnv
qUsers <- mapM objQidObject newMembers
req <-
addJSONObject
( ["conversation_role" .= r | r <- maybeToList role]
<> ["qualified_users" .= qUsers]
)
<$> baseRequest
usr
Galley
(ExplicitVersion 1)
(joinHttpPath ["conversations", cnvId, "members", "v2"])
submit "POST" (req & addJSONObject ["qualified_users" .= qUsers])

-- let invite = InviteQualified (userQualifiedId bob :| []) roleNameWireAdmin

removeMember :: (HasCallStack, MakesValue remover, MakesValue conv, MakesValue removed) => remover -> conv -> removed -> App Response
removeMember remover qcnv removed = do
(convDomain, convId) <- objQid qcnv
Expand Down
18 changes: 18 additions & 0 deletions integration/test/Test/Conversation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -828,3 +828,21 @@ testUpdateConversationByRemoteAdmin = do
void $ withWebSocket alice $ \ws -> do
void $ updateReceiptMode bob conv (41 :: Int) >>= getBody 200
awaitMatch 10 isReceiptModeUpdateNotif ws

testAddRemoteUsersToLocalConv :: HasCallStack => App ()
testAddRemoteUsersToLocalConv = do
[alice, bob] <- createAndConnectUsers [OwnDomain, OtherDomain]
conv <-
postConversation alice defProteus
>>= getJSON 201
[aliceId, bobId] <- for [alice, bob] (%. "qualified_id")
void $ addMembersV1 alice conv (Just "wire_admin") [bobId] >>= getBody 200
assertConv aliceId conv bobId
assertConv bobId conv aliceId
where
assertConv :: HasCallStack => Value -> Value -> Value -> App ()
assertConv getter c other = do
conv <- getConversation getter c >>= getJSON 200
mems <- conv %. "members.others" & asList
memIds <- for mems (%. "qualified_id")
memIds `shouldMatch` [other]

0 comments on commit e07188e

Please sign in to comment.