Skip to content

Commit

Permalink
More integration test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pcapriotti committed Dec 1, 2022
1 parent b0c843e commit b6c87d3
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 22 deletions.
28 changes: 15 additions & 13 deletions services/galley/test/integration/API.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1689,7 +1689,8 @@ getConvsOk = do
usr <- randomUser
convs <- getAllConvs usr
liftIO $
[toUUID usr] @?= map (toUUID . qUnqualified . cnvQualifiedId) convs
[selfConv usr, mlsSelfConvId usr]
@?= map (qUnqualified . cnvQualifiedId) convs

getConvsOk2 :: TestM ()
getConvsOk2 = do
Expand Down Expand Up @@ -1806,14 +1807,15 @@ testListConvIds = do
[alice, bob] <- randomUsers 2
connectUsers alice (singleton bob)
void $ postO2OConv alice bob (Just "gossip")
-- Each of the users has a Proteus self-conversation, an MLS self-conversation
-- and the one-to-one coversation.
getConvIdsV2 alice Nothing (Just 5) !!! do
const 200 === statusCode
const (Right 3) === fmap length . decodeQualifiedConvIdList
getConvIdsV2 bob Nothing (Just 5) !!! do
const 200 === statusCode
const (Right 3) === fmap length . decodeQualifiedConvIdList
-- Each user has a Proteus self-conversation and the one-to-one coversation.
for_ [alice, bob] $ \u -> do
r :: ConversationList ConvId <-
responseJsonError
=<< getConvIdsV2 u Nothing (Just 5)
<!! const 200 === statusCode
liftIO $ do
length (convList r) @?= 2
convHasMore r @?= False

paginateConvListIds :: TestM ()
paginateConvListIds = do
Expand Down Expand Up @@ -1949,11 +1951,11 @@ getConvsPagingOk :: TestM ()
getConvsPagingOk = do
[ally, bill, carl] <- randomUsers 3
connectUsers ally (list1 bill [carl])
replicateM_ 11 $ postConv ally [bill, carl] (Just "gossip") [] Nothing Nothing
replicateM_ 10 $ postConv ally [bill, carl] (Just "gossip") [] Nothing Nothing

walk ally [3, 3, 3, 3, 2] -- 11 (group) + 2 (1:1) + 1 (self)
walk bill [3, 3, 3, 3, 1] -- 11 (group) + 1 (1:1) + 1 (self)
walk carl [3, 3, 3, 3, 1] -- 11 (group) + 1 (1:1) + 1 (self)
walk ally [3, 3, 3, 3, 2] -- 10 (group) + 2 (1:1) + 2 (self)
walk bill [3, 3, 3, 3, 1] -- 10 (group) + 1 (1:1) + 2 (self)
walk carl [3, 3, 3, 3, 1] -- 10 (group) + 1 (1:1) + 2 (self)
where
walk :: Foldable t => UserId -> t Int -> TestM ()
walk u = foldM_ (next u 3) Nothing
Expand Down
25 changes: 17 additions & 8 deletions services/galley/test/integration/API/Federation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,14 @@ getConversationsAllFound = do
=<< iUpsertOne2OneConversation createO2O
liftIO $ assertEqual "Mismatch in the generated conversation ID" cnv1IdReturned cnv1Id

getConvs bob [cnv1Id, cnvQualifiedId cnv2] !!! do
const 200 === statusCode
const (Just . Just . sort $ [cnv1Id, cnvQualifiedId cnv2])
=== fmap (fmap (sort . map cnvQualifiedId . convList)) . responseJsonMaybe
do
convs <-
responseJsonError
=<< getConvs bob [cnv1Id, cnvQualifiedId cnv2] <!! do
const 200 === statusCode
liftIO $
map cnvQualifiedId (crFound convs)
@?= sort [cnv1Id, cnvQualifiedId cnv2]

-- get conversations

Expand Down Expand Up @@ -165,14 +169,19 @@ getConversationsNotPartOf = do
-- FUTUREWORK: make alice / bob remote users
[alice, bob] <- randomUsers 2
connectUsers alice (singleton bob)
localDomain <- viewFederationDomain
-- create & get one2one conv
cnv1 <- responseJsonUnsafeWithMsg "conversation" <$> postO2OConv alice bob (Just "gossip1")
getConvs alice [cnvQualifiedId cnv1] !!! do
const 200 === statusCode
const (Just [cnvQualifiedId cnv1]) === fmap (map cnvQualifiedId . convList) . responseJsonUnsafe
do
convs <-
responseJsonError
=<< getConvs alice [cnvQualifiedId cnv1] <!! do
const 200 === statusCode
liftIO $
map cnvQualifiedId (crFound convs)
@?= [cnvQualifiedId cnv1]

fedGalleyClient <- view tsFedGalleyClient
localDomain <- viewFederationDomain
rando <- Id <$> liftIO nextRandom
GetConversationsResponse convs <-
runFedClient @"get-conversations" fedGalleyClient localDomain $
Expand Down
2 changes: 1 addition & 1 deletion services/galley/test/integration/API/Util.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1142,7 +1142,7 @@ getConvIdsV2 u r s = do
g <- fmap (addPrefixAtVersion V2 .) (view tsUnversionedGalley)
get $
g
. path "/v2/conversations/ids"
. path "/conversations/ids"
. zUser u
. zConn "conn"
. zType "access"
Expand Down

0 comments on commit b6c87d3

Please sign in to comment.