From 2c58dc43eb4aab040bc7b7f80970e37500aa67f4 Mon Sep 17 00:00:00 2001 From: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com> Date: Fri, 5 Apr 2024 12:23:32 +0400 Subject: [PATCH] more tests --- src/Simplex/Chat/View.hs | 4 +- tests/ChatTests/Forward.hs | 111 +++++++++++++++++++++++++++++++++++-- tests/ChatTests/Local.hs | 2 + 3 files changed, 111 insertions(+), 6 deletions(-) diff --git a/src/Simplex/Chat/View.hs b/src/Simplex/Chat/View.hs index 01c7b2a740..47eb2f87d4 100644 --- a/src/Simplex/Chat/View.hs +++ b/src/Simplex/Chat/View.hs @@ -839,7 +839,9 @@ viewChatCleared :: AChatInfo -> [StyledString] viewChatCleared (AChatInfo _ chatInfo) = case chatInfo of DirectChat ct -> [ttyContact' ct <> ": all messages are removed locally ONLY"] GroupChat gi -> [ttyGroup' gi <> ": all messages are removed locally ONLY"] - _ -> [] + LocalChat _ -> ["notes: all messages are removed"] + ContactRequest _ -> [] + ContactConnection _ -> [] viewContactsList :: [Contact] -> [StyledString] viewContactsList = diff --git a/tests/ChatTests/Forward.hs b/tests/ChatTests/Forward.hs index cf59f271a7..747d0f4f1d 100644 --- a/tests/ChatTests/Forward.hs +++ b/tests/ChatTests/Forward.hs @@ -6,7 +6,7 @@ module ChatTests.Forward where import ChatClient import ChatTests.Utils import qualified Data.ByteString.Char8 as B -import System.Directory (doesFileExist) +import System.Directory (copyFile, doesFileExist) import Test.Hspec hiding (it) chatForwardTests :: SpecWith FilePath @@ -23,7 +23,9 @@ chatForwardTests = do it "from notes to notes" testForwardNotesToNotes -- TODO forward between different folders when supported describe "forward files" $ do it "from contact to contact" testForwardFileNoFilesFolder - it "with relative paths: from contact to contact" testForwardFileRelativePaths + it "with relative paths: from contact to contact" testForwardFileContactToContact + it "with relative paths: from group to notes" testForwardFileGroupToNotes + it "with relative paths: from notes to group" testForwardFileNotesToGroup testForwardContactToContact :: HasCallStack => FilePath -> IO () testForwardContactToContact = @@ -275,8 +277,8 @@ testForwardFileNoFilesFolder = dest2 <- B.readFile "./tests/tmp/test_1.pdf" dest2 `shouldBe` src -testForwardFileRelativePaths :: HasCallStack => FilePath -> IO () -testForwardFileRelativePaths = +testForwardFileContactToContact :: HasCallStack => FilePath -> IO () +testForwardFileContactToContact = testChat3 aliceProfile bobProfile cathProfile $ \alice bob cath -> withXFTPServer $ do setRelativePaths alice "./tests/fixtures" "./tests/tmp/alice_xftp" @@ -329,8 +331,10 @@ testForwardFileRelativePaths = ] cath <## "completed receiving file 1 (test_1.pdf) from bob" + src2 <- B.readFile "./tests/tmp/bob_files/test_1.pdf" + src2 `shouldBe` dest dest2 <- B.readFile "./tests/tmp/cath_files/test_1.pdf" - dest2 `shouldBe` src + dest2 `shouldBe` src2 -- deleting original file doesn't delete forwarded file checkActionDeletesFile "./tests/tmp/bob_files/test.pdf" $ do @@ -338,3 +342,100 @@ testForwardFileRelativePaths = bob <## "alice: all messages are removed locally ONLY" fwdFileExists <- doesFileExist "./tests/tmp/bob_files/test_1.pdf" fwdFileExists `shouldBe` True + +testForwardFileGroupToNotes :: HasCallStack => FilePath -> IO () +testForwardFileGroupToNotes = + testChat2 aliceProfile cathProfile $ + \alice cath -> withXFTPServer $ do + setRelativePaths alice "./tests/fixtures" "./tests/tmp/alice_xftp" + setRelativePaths cath "./tests/tmp/cath_files" "./tests/tmp/cath_xftp" + createGroup2 "team" alice cath + createCCNoteFolder cath + + -- send original file + alice ##> "/_send #1 json {\"filePath\": \"test.pdf\", \"msgContent\": {\"type\": \"text\", \"text\": \"hi\"}}" + alice <# "#team hi" + alice <# "/f #team test.pdf" + alice <## "use /fc 1 to cancel sending" + cath <# "#team alice> hi" + cath <# "#team alice> sends file test.pdf (266.0 KiB / 272376 bytes)" + cath <## "use /fr 1 [