Skip to content

Commit f39cb9c

Browse files
committed
Failing integration test to reproduce ticket issue [WIP: not failing]
1 parent 557b26f commit f39cb9c

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

integration/test/Test/MLS/Notifications.hs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717

1818
module Test.MLS.Notifications where
1919

20+
import API.Galley
2021
import API.Gundeck
22+
import Control.Concurrent
23+
import Data.Timeout
2124
import MLS.Util
2225
import Notifications
2326
import SetupHelpers
@@ -45,3 +48,49 @@ testWelcomeNotification = do
4548
size = Just 10000
4649
}
4750
>>= getJSON 200
51+
52+
testNotificationPagination :: (HasCallStack) => App ()
53+
testNotificationPagination = do
54+
{-
55+
Create a user with client1
56+
57+
Wait for all the notifications to expire (there should be no notifications which are sent to “All Clients”, i.e. there should be no notifications in the DB where clients field is null.
58+
59+
Send a lot of MLS messages to this client (so that the total payload size goes over 5 MB)
60+
61+
Create another client (say client2)
62+
63+
Fetch notifications for client 2
64+
-}
65+
66+
let overrides = def {gundeckCfg = setField "settings.notificationTTL" (2 #> Second)}
67+
withModifiedBackend overrides $ \dom -> do
68+
-- create a user with client1
69+
[alice, bob] <- createAndConnectUsers [dom, dom]
70+
[alice1, bob1] <- traverse (createMLSClient def) [alice, bob]
71+
traverse_ (uploadNewKeyPackage def) [alice1, bob1]
72+
73+
conv <- postConversation alice1 defMLS >>= getJSON 201
74+
_convQid <- conv %. "qualified_id"
75+
convId <- objConvId conv
76+
createGroup def alice1 convId
77+
void $ createAddCommit alice1 convId [bob] >>= sendAndConsumeCommitBundle
78+
79+
-- let notifs expire
80+
liftIO $ threadDelay 2_300_000
81+
82+
-- bob sends alice > 5MB of MLS messages
83+
let payload = replicate 20_000 '.'
84+
forM_ [1 :: Int .. 260] $ \i -> do
85+
print i
86+
void $ createApplicationMessage convId bob1 payload >>= sendAndConsumeMessage
87+
88+
-- create new client for alice, fetch notifications, and check response consistency.
89+
alice2 :: ClientIdentity <- createMLSClient def alice
90+
getNotifications
91+
alice
92+
def {since = Nothing, size = Nothing, client = Just alice2.client}
93+
`bindResponse` \resp -> do
94+
resp.status `shouldMatchInt` 200
95+
resp.json %. "has_more" `shouldMatch` False
96+
resp.json %. "notifications" `shouldMatch` ([] :: [()])

0 commit comments

Comments
 (0)