From aff819a0eeb73a0a5451a31cc8521e0529d101fc Mon Sep 17 00:00:00 2001 From: IC Rainbow Date: Fri, 29 Dec 2023 15:22:38 +0200 Subject: [PATCH] add preview pagination test --- tests/ChatTests/ChatList.hs | 2 +- tests/ChatTests/Local.hs | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/tests/ChatTests/ChatList.hs b/tests/ChatTests/ChatList.hs index 540125524e..e4ecc79cf1 100644 --- a/tests/ChatTests/ChatList.hs +++ b/tests/ChatTests/ChatList.hs @@ -14,7 +14,7 @@ chatListTests = do it "filter favorite" testFilterFavorite it "filter unread" testFilterUnread it "filter favorite or unread" testFilterFavoriteOrUnread - fit "sort and filter chats of all types" testPaginationAllChatTypes + it "sort and filter chats of all types" testPaginationAllChatTypes testPaginationLast :: HasCallStack => FilePath -> IO () testPaginationLast = diff --git a/tests/ChatTests/Local.hs b/tests/ChatTests/Local.hs index 2e79c844b8..b16deed3bf 100644 --- a/tests/ChatTests/Local.hs +++ b/tests/ChatTests/Local.hs @@ -8,13 +8,16 @@ import ChatTests.Utils import System.Directory (copyFile, doesFileExist) import Test.Hspec import System.FilePath (takeFileName, ()) +import Data.Time (getCurrentTime) +import ChatTests.ChatList (getChats_) +import Data.Time.Format.ISO8601 (iso8601Show) chatLocalTests :: SpecWith FilePath chatLocalTests = do describe "note folders" $ do it "create folders, add notes, read, search" testNotes it "switch users" testUserNotes - it "pagination in all modes" testPagination + it "preview pagination for notes" testPreviewsPagination it "stores files" testFiles testNotes :: FilePath -> IO () @@ -60,6 +63,22 @@ testUserNotes tmp = withNewTestChat tmp "alice" aliceProfile $ \alice -> do alice ##> "/_delete item $1 1 internal" alice <## "chat db error: SENoteFolderNotFound {noteFolderId = 1}" +testPreviewsPagination :: FilePath -> IO () +testPreviewsPagination tmp = withNewTestChat tmp "alice" aliceProfile $ \alice -> do + tsS <- iso8601Show <$> getCurrentTime + alice #> "$notes first" + tsM <- iso8601Show <$> getCurrentTime + alice #> "$notes last" + tsE <- iso8601Show <$> getCurrentTime + + -- there's only one folder that got updated after tsM and before tsE + getChats_ alice "count=3" [("$notes", "last")] + getChats_ alice ("after=" <> tsE <> " count=10") [] + getChats_ alice ("after=" <> tsS <> " count=10") [("$notes", "last")] + getChats_ alice ("before=" <> tsM <> " count=10") [] + getChats_ alice ("before=" <> tsE <> " count=10") [("$notes", "last")] + getChats_ alice ("before=" <> tsS <> " count=10") [] + testFiles :: FilePath -> IO () testFiles tmp = withNewTestChat tmp "alice" aliceProfile $ \alice -> do -- setup