Skip to content

Commit

Permalink
WIP: Test - Guard by tweaking settings
Browse files Browse the repository at this point in the history
  • Loading branch information
mdimjasevic committed Jan 10, 2024
1 parent 7b41633 commit 3552a9e
Showing 1 changed file with 43 additions and 21 deletions.
64 changes: 43 additions & 21 deletions integration/test/Test/Conversation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -662,28 +662,50 @@ testDeleteTeamConversationWithUnreachableRemoteMembers = do

testDeleteTeamMember :: HasCallStack => App ()
testDeleteTeamMember = do
(alice, team, [alex]) <- createTeam OwnDomain 2
[amy, bob] <- for [OwnDomain, OtherDomain] $ flip randomUser def
forM_ [amy, bob] $ connectTwoUsers alice
[aliceId, alexId, amyId, bobId] <-
forM [alice, alex, amy, bob] (%. "qualified_id")
let nc = (defProteus {qualifiedUsers = [alexId, amyId, bobId], team = Just team})
conv <- postConversation alice nc >>= getJSON 201
withWebSockets [alice, amy, bob] $ \[wsAlice, wsAmy, wsBob] -> do
void $ deleteTeamMember team alice alex >>= getBody 202
assertConvLeaveNotif wsAmy alexId
do
n <- awaitMatch isTeamMemberLeaveNotif wsAlice
let overrides =
def
{ galleyCfg = \conf ->
conf
& setField
"settings.featureFlags.limitedEventFanout"
( object
[ "defaults"
.= ( object
[ "status" .= "enabled",
"lockStatus" .= "locked"
]
)
]
)
}
startDynamicBackends [overrides] $ \[domainA] -> do
(alice, team, [alex, alison]) <- createTeam domainA 3
otherDomain <- asString OtherDomain
[amy, bob] <- for [domainA, otherDomain] $ flip randomUser def
forM_ [amy, bob] $ connectTwoUsers alice
[aliceId, alexId, amyId, alisonId, bobId] <-
forM [alice, alex, amy, bob, alison] (%. "qualified_id")
let nc = (defProteus {qualifiedUsers = [alexId, amyId, alisonId, bobId], team = Just team})
conv <- postConversation alice nc >>= getJSON 201
withWebSockets [alice, amy, bob, alison] $ \[wsAlice, wsAmy, wsBob, wsAlison] -> do
void $ deleteTeamMember team alice alex >>= getBody 202
assertConvLeaveNotif wsAmy alexId
alexUId <- alex %. "id"
nPayload n %. "data.user" `shouldMatch` alexUId
assertConvLeaveNotif wsAlice alexId
do
bindResponse (getConversation bob conv) $ \resp -> do
resp.status `shouldMatchInt` 200
mems <- resp.json %. "members.others" & asList
memIds <- forM mems (%. "qualified_id")
memIds `shouldMatchSet` [aliceId, amyId]
assertConvLeaveNotif wsBob alexId
do
n <- awaitMatch isTeamMemberLeaveNotif wsAlice
nPayload n %. "data.user" `shouldMatch` alexUId
assertConvLeaveNotif wsAlice alexId
do
n <- awaitMatch isTeamMemberLeaveNotif wsAlison
nPayload n %. "data.user" `shouldMatch` alexUId
assertConvLeaveNotif wsAlison alexId
do
bindResponse (getConversation bob conv) $ \resp -> do
resp.status `shouldMatchInt` 200
mems <- resp.json %. "members.others" & asList
memIds <- forM mems (%. "qualified_id")
memIds `shouldMatchSet` [aliceId, amyId]
assertConvLeaveNotif wsBob alexId
where
assertConvLeaveNotif :: MakesValue leaverId => WebSocket -> leaverId -> App ()
assertConvLeaveNotif ws leaverId = do
Expand Down

0 comments on commit 3552a9e

Please sign in to comment.