Skip to content

Commit

Permalink
Added steps to handle removal proposals in tests
Browse files Browse the repository at this point in the history
TODO: handle the removals in code (backend)
  • Loading branch information
elland committed Jan 9, 2023
1 parent 9085b60 commit 52eee93
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 9 deletions.
5 changes: 4 additions & 1 deletion services/galley/src/Galley/API/MLS/Message.hs
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,7 @@ data ProposalAction = ProposalAction
-- to know if a commit has one when processing external commits
paExternalInit :: Any
}
deriving Show

instance Semigroup ProposalAction where
ProposalAction add1 rem1 init1 <> ProposalAction add2 rem2 init2 =
Expand Down Expand Up @@ -1252,7 +1253,9 @@ executeProposalAction ::
ConvOrSubConv ->
ProposalAction ->
Sem r [LocalConversationUpdate]
executeProposalAction _loc _qusr _con (SubConv _ _) _action = pure []
executeProposalAction _loc _qusr _con (SubConv _ _) _action = do
-- TODO: handle removal action
pure []
executeProposalAction loc qusr con (Conv mlsConv) action = do
let lconv = qualifyAs loc . mcConv $ mlsConv
mlsMeta = mcMLSData mlsConv
Expand Down
40 changes: 32 additions & 8 deletions services/galley/test/integration/API/MLS.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2594,13 +2594,37 @@ testRemoveUserMain = do
for_ [alice1, bob2, charlie1, charlie2] $ \c ->
void $ createExternalCommit c Nothing qcs >>= sendAndConsumeCommitBundle

-- TODO(elland): creator is not mapped correctly inside a subconversation
-- so removing them has issues
[(_, kpref1), (_, kpref2)] <- getClientsFromGroupState alice1 charlie

-- bob leaves the main conversation
liftTest $ do
deleteMemberQualified (qUnqualified bob) bob qcnv
!!! const 200 === statusCode
mlsBracket [alice1, bob1, bob2] $ \wss -> do
liftTest $ do
deleteMemberQualified (qUnqualified charlie) charlie qcnv
!!! const 200 === statusCode

-- Remove charlie from our state as well
State.modify $ \mls ->
mls
{ mlsMembers = Set.difference (mlsMembers mls) (Set.fromList [charlie1, charlie2])
}

sub :: PublicSubConversation <-
responseJsonError
=<< getSubConv (qUnqualified alice) qcnv (SubConvId "conference")
<!! const 200 === statusCode
print sub
msg1 <- WS.assertMatchN (5 # Second) wss $ \n ->
wsAssertBackendRemoveProposal charlie qcnv kpref1 n

traverse_ (uncurry consumeMessage1) (zip [alice1, bob1, bob2] msg1)

msg2 <- WS.assertMatchN (5 # Second) wss $ \n ->
wsAssertBackendRemoveProposal charlie qcnv kpref2 n

traverse_ (uncurry consumeMessage1) (zip [alice1, bob1, bob2] msg2)

void $ createPendingProposalCommit alice1 >>= sendAndConsumeCommitBundle

liftTest $ do
sub :: PublicSubConversation <-
responseJsonError
=<< getSubConv (qUnqualified charlie) qcnv (SubConvId "conference")
<!! const 200 === statusCode
print $ pscMembers sub

0 comments on commit 52eee93

Please sign in to comment.