@@ -828,3 +828,39 @@ def test_unread_counts_batch(self, client: StreamChat, channel, random_users: Di
828828 assert (
829829 response ["counts_by_user" ][user_id ]["total_unread_threads_count" ] == 1
830830 )
831+
832+ def test_query_message_history (
833+ self , client : StreamChat , channel , random_user : Dict
834+ ):
835+ msg_id = str (uuid .uuid4 ())
836+ channel .send_message ({"id" : msg_id , "text" : "helloworld" }, random_user ["id" ])
837+ client .update_message (
838+ {"id" : msg_id , "text" : "helloworld-1" , "user_id" : random_user ["id" ]}
839+ )
840+ client .update_message (
841+ {"id" : msg_id , "text" : "helloworld-2" , "user_id" : random_user ["id" ]}
842+ )
843+ client .update_message (
844+ {"id" : msg_id , "text" : "helloworld-3" , "user_id" : random_user ["id" ]}
845+ )
846+ client .update_message (
847+ {"id" : msg_id , "text" : "helloworld-4" , "user_id" : random_user ["id" ]}
848+ )
849+
850+ response = client .query_message_history (
851+ {"message_id" : {"$eq" : msg_id }},
852+ sort = [{"message_updated_at" : - 1 }],
853+ ** {"limit" : 1 },
854+ )
855+
856+ assert len (response ["message_history" ]) == 1
857+ assert response ["message_history" ][0 ]["text" ] == "helloworld-3"
858+
859+ response_next = client .query_message_history (
860+ {"message_id" : {"$eq" : msg_id }},
861+ sort = [{"message_updated_at" : - 1 }],
862+ ** {"limit" : 1 , "next" : response ["next" ]},
863+ )
864+
865+ assert len (response_next ["message_history" ]) == 1
866+ assert response_next ["message_history" ][0 ]["text" ] == "helloworld-2"
0 commit comments