mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-08-27 22:34:51 +00:00
core: keep chat item edit history (#2410)
This commit is contained in:
@@ -31,6 +31,7 @@ chatDirectTests = do
|
||||
it "deleting contact deletes profile" testDeleteContactDeletesProfile
|
||||
it "direct message quoted replies" testDirectMessageQuotedReply
|
||||
it "direct message update" testDirectMessageUpdate
|
||||
it "direct message edit history" testDirectMessageEditHistory
|
||||
it "direct message delete" testDirectMessageDelete
|
||||
it "direct live message" testDirectLiveMessage
|
||||
it "repeat AUTH errors disable contact" testRepeatAuthErrorsDisableContact
|
||||
@@ -268,6 +269,73 @@ testDirectMessageUpdate =
|
||||
alice #$> ("/_get chat @2 count=100", chat', chatFeatures' <> [((1, "greetings 🤝"), Nothing), ((0, "hey Alice"), Just (1, "hello 🙂")), ((0, "greetings Alice"), Just (1, "hey 👋"))])
|
||||
bob #$> ("/_get chat @2 count=100", chat', chatFeatures' <> [((0, "greetings 🤝"), Nothing), ((1, "hey Alice"), Just (0, "hello 🙂")), ((1, "greetings Alice"), Just (0, "hey 👋"))])
|
||||
|
||||
testDirectMessageEditHistory :: HasCallStack => FilePath -> IO ()
|
||||
testDirectMessageEditHistory =
|
||||
testChat2 aliceProfile bobProfile $
|
||||
\alice bob -> do
|
||||
connectUsers alice bob
|
||||
alice #> "@bob hello!"
|
||||
bob <# "alice> hello!"
|
||||
|
||||
alice ##> ("/_get item info " <> itemId 1)
|
||||
alice <##. "sent at: "
|
||||
bob ##> ("/_get item info " <> itemId 1)
|
||||
bob <##. "sent at: "
|
||||
bob <##. "received at: "
|
||||
|
||||
alice ##> ("/_update item @2 " <> itemId 1 <> " text hey 👋")
|
||||
alice <# "@bob [edited] hey 👋"
|
||||
bob <# "alice> [edited] hey 👋"
|
||||
|
||||
alice ##> ("/_get item info " <> itemId 1)
|
||||
alice <##. "sent at: "
|
||||
alice <## "message history:"
|
||||
alice .<## ": hey 👋"
|
||||
alice .<## ": hello!"
|
||||
bob ##> ("/_get item info " <> itemId 1)
|
||||
bob <##. "sent at: "
|
||||
bob <##. "received at: "
|
||||
bob <## "message history:"
|
||||
bob .<## ": hey 👋"
|
||||
bob .<## ": hello!"
|
||||
|
||||
alice ##> ("/_update item @2 " <> itemId 1 <> " text hello there")
|
||||
alice <# "@bob [edited] hello there"
|
||||
bob <# "alice> [edited] hello there"
|
||||
|
||||
alice ##> "/item info @bob hello"
|
||||
alice <##. "sent at: "
|
||||
alice <## "message history:"
|
||||
alice .<## ": hello there"
|
||||
alice .<## ": hey 👋"
|
||||
alice .<## ": hello!"
|
||||
bob ##> "/item info @alice hello"
|
||||
bob <##. "sent at: "
|
||||
bob <##. "received at: "
|
||||
bob <## "message history:"
|
||||
bob .<## ": hello there"
|
||||
bob .<## ": hey 👋"
|
||||
bob .<## ": hello!"
|
||||
|
||||
bob #$> ("/_delete item @2 " <> itemId 1 <> " internal", id, "message deleted")
|
||||
|
||||
alice ##> ("/_update item @2 " <> itemId 1 <> " text hey there")
|
||||
alice <# "@bob [edited] hey there"
|
||||
bob <# "alice> [edited] hey there"
|
||||
|
||||
alice ##> "/item info @bob hey"
|
||||
alice <##. "sent at: "
|
||||
alice <## "message history:"
|
||||
alice .<## ": hey there"
|
||||
alice .<## ": hello there"
|
||||
alice .<## ": hey 👋"
|
||||
alice .<## ": hello!"
|
||||
bob ##> "/item info @alice hey"
|
||||
bob <##. "sent at: "
|
||||
bob <##. "received at: "
|
||||
bob <## "message history:"
|
||||
bob .<## ": hey there"
|
||||
|
||||
testDirectMessageDelete :: HasCallStack => FilePath -> IO ()
|
||||
testDirectMessageDelete =
|
||||
testChat2 aliceProfile bobProfile $
|
||||
@@ -359,6 +427,18 @@ testDirectLiveMessage =
|
||||
alice ##> ("/_update item @2 " <> itemId 2 <> " text hello 2")
|
||||
alice <# "@bob [LIVE] hello 2"
|
||||
bob <# "alice> [LIVE ended] hello 2"
|
||||
-- live message has edit history
|
||||
alice ##> ("/_get item info " <> itemId 2)
|
||||
alice <##. "sent at: "
|
||||
alice <## "message history:"
|
||||
alice .<## ": hello 2"
|
||||
alice .<## ":"
|
||||
bob ##> ("/_get item info " <> itemId 2)
|
||||
bob <##. "sent at: "
|
||||
bob <##. "received at: "
|
||||
bob <## "message history:"
|
||||
bob .<## ": hello 2"
|
||||
bob .<## ":"
|
||||
|
||||
testRepeatAuthErrorsDisableContact :: HasCallStack => FilePath -> IO ()
|
||||
testRepeatAuthErrorsDisableContact =
|
||||
|
||||
@@ -32,6 +32,7 @@ chatGroupTests = do
|
||||
it "list groups containing group invitations" testGroupList
|
||||
it "group message quoted replies" testGroupMessageQuotedReply
|
||||
it "group message update" testGroupMessageUpdate
|
||||
it "group message edit history" testGroupMessageEditHistory
|
||||
it "group message delete" testGroupMessageDelete
|
||||
it "group live message" testGroupLiveMessage
|
||||
it "update group profile" testUpdateGroupProfile
|
||||
@@ -875,6 +876,76 @@ testGroupMessageUpdate =
|
||||
bob #$> ("/_get chat #1 count=3", chat', [((0, "greetings 🤝"), Nothing), ((1, "hi alice"), Just (0, "hey 👋")), ((0, "greetings!"), Just (0, "greetings 🤝"))])
|
||||
cath #$> ("/_get chat #1 count=3", chat', [((0, "greetings 🤝"), Nothing), ((0, "hi alice"), Just (0, "hey 👋")), ((1, "greetings!"), Just (0, "greetings 🤝"))])
|
||||
|
||||
testGroupMessageEditHistory :: HasCallStack => FilePath -> IO ()
|
||||
testGroupMessageEditHistory =
|
||||
testChat2 aliceProfile bobProfile $
|
||||
\alice bob -> do
|
||||
createGroup2 "team" alice bob
|
||||
threadDelay 1000000
|
||||
alice #> "#team hello!"
|
||||
bob <# "#team alice> hello!"
|
||||
aliceItemId <- lastItemId alice
|
||||
bobItemId <- lastItemId bob
|
||||
|
||||
alice ##> ("/_get item info " <> aliceItemId)
|
||||
alice <##. "sent at: "
|
||||
bob ##> ("/_get item info " <> bobItemId)
|
||||
bob <##. "sent at: "
|
||||
bob <##. "received at: "
|
||||
|
||||
alice ##> ("/_update item #1 " <> aliceItemId <> " text hey 👋")
|
||||
alice <# "#team [edited] hey 👋"
|
||||
bob <# "#team alice> [edited] hey 👋"
|
||||
|
||||
alice ##> ("/_get item info " <> aliceItemId)
|
||||
alice <##. "sent at: "
|
||||
alice <## "message history:"
|
||||
alice .<## ": hey 👋"
|
||||
alice .<## ": hello!"
|
||||
bob ##> ("/_get item info " <> bobItemId)
|
||||
bob <##. "sent at: "
|
||||
bob <##. "received at: "
|
||||
bob <## "message history:"
|
||||
bob .<## ": hey 👋"
|
||||
bob .<## ": hello!"
|
||||
|
||||
alice ##> ("/_update item #1 " <> aliceItemId <> " text hello there")
|
||||
alice <# "#team [edited] hello there"
|
||||
bob <# "#team alice> [edited] hello there"
|
||||
|
||||
alice ##> "/item info #team hello"
|
||||
alice <##. "sent at: "
|
||||
alice <## "message history:"
|
||||
alice .<## ": hello there"
|
||||
alice .<## ": hey 👋"
|
||||
alice .<## ": hello!"
|
||||
bob ##> "/item info #team hello"
|
||||
bob <##. "sent at: "
|
||||
bob <##. "received at: "
|
||||
bob <## "message history:"
|
||||
bob .<## ": hello there"
|
||||
bob .<## ": hey 👋"
|
||||
bob .<## ": hello!"
|
||||
|
||||
bob #$> ("/_delete item #1 " <> bobItemId <> " internal", id, "message deleted")
|
||||
|
||||
alice ##> ("/_update item #1 " <> aliceItemId <> " text hey there")
|
||||
alice <# "#team [edited] hey there"
|
||||
bob <# "#team alice> [edited] hey there"
|
||||
|
||||
alice ##> "/item info #team hey"
|
||||
alice <##. "sent at: "
|
||||
alice <## "message history:"
|
||||
alice .<## ": hey there"
|
||||
alice .<## ": hello there"
|
||||
alice .<## ": hey 👋"
|
||||
alice .<## ": hello!"
|
||||
bob ##> "/item info #team hey"
|
||||
bob <##. "sent at: "
|
||||
bob <##. "received at: "
|
||||
bob <## "message history:"
|
||||
bob .<## ": hey there"
|
||||
|
||||
testGroupMessageDelete :: HasCallStack => FilePath -> IO ()
|
||||
testGroupMessageDelete =
|
||||
testChat3 aliceProfile bobProfile cathProfile $
|
||||
@@ -981,6 +1052,19 @@ testGroupLiveMessage =
|
||||
alice <# "#team [LIVE] hello 2"
|
||||
bob <# "#team alice> [LIVE ended] hello 2"
|
||||
cath <# "#team alice> [LIVE ended] hello 2"
|
||||
-- live message has edit history
|
||||
alice ##> ("/_get item info " <> msgItemId2)
|
||||
alice <##. "sent at: "
|
||||
alice <## "message history:"
|
||||
alice .<## ": hello 2"
|
||||
alice .<## ":"
|
||||
bobItemId <- lastItemId bob
|
||||
bob ##> ("/_get item info " <> bobItemId)
|
||||
bob <##. "sent at: "
|
||||
bob <##. "received at: "
|
||||
bob <## "message history:"
|
||||
bob .<## ": hello 2"
|
||||
bob .<## ":"
|
||||
|
||||
testUpdateGroupProfile :: HasCallStack => FilePath -> IO ()
|
||||
testUpdateGroupProfile =
|
||||
|
||||
@@ -231,6 +231,13 @@ cc <##. line = do
|
||||
unless prefix $ print ("expected to start from: " <> line, ", got: " <> l)
|
||||
prefix `shouldBe` True
|
||||
|
||||
(.<##) :: HasCallStack => TestCC -> String -> Expectation
|
||||
cc .<## line = do
|
||||
l <- getTermLine cc
|
||||
let suffix = line `isSuffixOf` l
|
||||
unless suffix $ print ("expected to end with: " <> line, ", got: " <> l)
|
||||
suffix `shouldBe` True
|
||||
|
||||
(<#.) :: HasCallStack => TestCC -> String -> Expectation
|
||||
cc <#. line = do
|
||||
l <- dropTime <$> getTermLine cc
|
||||
|
||||
Reference in New Issue
Block a user