From 80dc5d9022fba44c6a60b212ac6db4f5f867b985 Mon Sep 17 00:00:00 2001 From: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com> Date: Thu, 4 Sep 2025 16:32:39 +0400 Subject: [PATCH] better test --- tests/ChatClient.hs | 3 +++ tests/ChatTests/Groups.hs | 32 +++++++++++++++++++++++++------- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/tests/ChatClient.hs b/tests/ChatClient.hs index b868671f3b..3f491d6b63 100644 --- a/tests/ChatClient.hs +++ b/tests/ChatClient.hs @@ -477,6 +477,9 @@ testChat3 = testChatCfgOpts3 testCfg testOpts testChatCfg3 :: HasCallStack => ChatConfig -> Profile -> Profile -> Profile -> (HasCallStack => TestCC -> TestCC -> TestCC -> IO ()) -> TestParams -> IO () testChatCfg3 cfg = testChatCfgOpts3 cfg testOpts +testChatOpts3 :: HasCallStack => ChatOpts -> Profile -> Profile -> Profile -> (HasCallStack => TestCC -> TestCC -> TestCC -> IO ()) -> TestParams -> IO () +testChatOpts3 = testChatCfgOpts3 testCfg + testChatCfgOpts3 :: HasCallStack => ChatConfig -> ChatOpts -> Profile -> Profile -> Profile -> (HasCallStack => TestCC -> TestCC -> TestCC -> IO ()) -> TestParams -> IO () testChatCfgOpts3 cfg opts p1 p2 p3 test = testChatN cfg opts [p1, p2, p3] test_ where diff --git a/tests/ChatTests/Groups.hs b/tests/ChatTests/Groups.hs index 981b46b5c8..0ce14a362e 100644 --- a/tests/ChatTests/Groups.hs +++ b/tests/ChatTests/Groups.hs @@ -8046,28 +8046,46 @@ testScopedSupportUnreadStatsOnDelete = testScopedSupportUnreadStatsCorrectOnOpen :: HasCallStack => TestParams -> IO () testScopedSupportUnreadStatsCorrectOnOpen = - testChatOpts2 opts aliceProfile bobProfile $ \alice bob -> do - createGroup2 "team" alice bob + testChatOpts3 opts aliceProfile bobProfile cathProfile $ \alice bob cath -> do + createGroup3' "team" alice (bob, GRMember) (cath, GRModerator) bob #> "#team (support) 1" - alice <# "#team (support: bob) bob> 1" + [alice, cath] *<# "#team (support: bob) bob> 1" bob #> "#team (support) 2" - alice <# "#team (support: bob) bob> 2" + [alice, cath] *<# "#team (support: bob) bob> 2" alice ##> "/member support chats #team" alice <## "bob (Bob) (id 2): unread: 2, require attention: 2, mentions: 0" + threadDelay 1000000 + + cath #> "#team (support: bob) 3" + alice <# "#team (support: bob) cath> 3" + bob <# "#team (support) cath> 3" + + alice ##> "/member support chats #team" + alice <## "bob (Bob) (id 2): unread: 3, require attention: 0, mentions: 0" + + bob #> "#team (support) 4" + [alice, cath] *<# "#team (support: bob) bob> 4" + + bob #> "#team (support) 5" + [alice, cath] *<# "#team (support: bob) bob> 5" + + alice ##> "/member support chats #team" + alice <## "bob (Bob) (id 2): unread: 5, require attention: 2, mentions: 0" + void $ withCCTransaction alice $ \db -> DB.execute db "UPDATE group_members SET support_chat_items_member_attention=100 WHERE group_member_id=?" (Only (2 :: Int64)) alice ##> "/member support chats #team" - alice <## "bob (Bob) (id 2): unread: 2, require attention: 100, mentions: 0" + alice <## "bob (Bob) (id 2): unread: 5, require attention: 100, mentions: 0" - alice #$> ("/_get chat #1(_support:2) count=100", chat, [(0, "1"), (0, "2")]) + alice #$> ("/_get chat #1(_support:2) count=100", chat, [(0, "1"), (0, "2"), (0, "3"), (0, "4"), (0, "5")]) alice ##> "/member support chats #team" - alice <## "bob (Bob) (id 2): unread: 2, require attention: 2, mentions: 0" + alice <## "bob (Bob) (id 2): unread: 5, require attention: 2, mentions: 0" where opts = testOpts