diff --git a/tests/Bots/DirectoryTests.hs b/tests/Bots/DirectoryTests.hs index 22d73f72ea..f15a419c31 100644 --- a/tests/Bots/DirectoryTests.hs +++ b/tests/Bots/DirectoryTests.hs @@ -14,8 +14,9 @@ import Control.Concurrent (threadDelay) import Control.Concurrent.Async (async, cancel) import Control.Concurrent.STM (atomically, peekTQueue, tryReadTMVar) import Control.Exception (finally) -import Control.Monad (forM_, when, void) +import Control.Monad (forM_, replicateM, when, void) import qualified Data.Aeson as J +import Data.List (partition) import qualified Data.Text as T import Directory.Captcha import Directory.Listing @@ -421,12 +422,16 @@ testJoinGroup ps = cath <## "connection request sent!" cath <## "#privacy: joining the group..." cath <## "#privacy: you joined the group, pending approval" - cath <# "#privacy (support) 'SimpleX Directory_1'> Captcha is generated by SimpleX Directory service." - cath <## "" - cath <## "Send captcha text to join the group privacy." - captcha <- dropStrPrefix "#privacy (support) 'SimpleX Directory_1'> " . dropTime <$> getTermLine cath - cath <## "contact and member are merged: 'SimpleX Directory', #privacy 'SimpleX Directory_1'" - cath <## "use @'SimpleX Directory' to send messages" + let mergedLines = + [ "contact and member are merged: 'SimpleX Directory', #privacy 'SimpleX Directory_1'", + "use @'SimpleX Directory' to send messages" + ] + directoryMsg = T.unpack . T.replace "'SimpleX Directory_1'> " "'SimpleX Directory'> " . T.pack . dropTime + (merged, captchaLines) <- partition (`elem` mergedLines) <$> replicateM 6 (getTermLine cath) + merged `shouldBe` mergedLines + [intro, "", "Send captcha text to join the group privacy.", captchaLine] <- pure captchaLines + directoryMsg intro `shouldBe` "#privacy (support) 'SimpleX Directory'> Captcha is generated by SimpleX Directory service." + let captcha = dropStrPrefix "#privacy (support) 'SimpleX Directory'> " $ directoryMsg captchaLine cath #> ("#privacy (support) " <> captcha) cath <# ("#privacy (support) 'SimpleX Directory'!> > cath " <> captcha) cath <## " Correct, you joined the group privacy"