From be6da14f166c68cb9a26e1ecc17fdb127fef8bdb Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Fri, 15 Sep 2023 13:46:41 +0200 Subject: [PATCH] test(ui): Add more tests. --- .../src/room_list_service/room_list.rs | 11 ++++---- .../tests/integration/room_list_service.rs | 28 +++++++++++++++++++ crates/matrix-sdk/src/sliding_sync/cache.rs | 1 - 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/crates/matrix-sdk-ui/src/room_list_service/room_list.rs b/crates/matrix-sdk-ui/src/room_list_service/room_list.rs index de9e8693c..2b1b22246 100644 --- a/crates/matrix-sdk-ui/src/room_list_service/room_list.rs +++ b/crates/matrix-sdk-ui/src/room_list_service/room_list.rs @@ -110,10 +110,10 @@ impl RoomList { /// possible to “paginate” over the entries by `page_size`. /// /// The returned stream will only start yielding diffs once a filter is set - /// through the returned `DynamicRoomListController`. For every call to - /// [`DynamicRoomListController::set`], the stream will yield a - /// [`VectorDiff::Reset`] followed by any updates of the room list under - /// that filter (until the next reset). + /// through the returned [`RoomListDynamicEntriesController`]. For every + /// call to [`RoomListDynamicEntriesController::set_filter`], the stream + /// will yield a [`VectorDiff::Truncate`] followed by any updates of the + /// room list under that filter (until the next reset). pub fn entries_with_dynamic_adapters( &self, page_size: usize, @@ -240,7 +240,8 @@ impl RoomListDynamicEntriesController { } } - /// Add one page. + /// Add one page, i.e. view `page_size` more entries in the room list if + /// any. pub fn add_one_page(&self) { if let Some(max) = self.maximum_number_of_rooms.borrow_mut().next_now() { let max: usize = max.try_into().unwrap(); diff --git a/crates/matrix-sdk-ui/tests/integration/room_list_service.rs b/crates/matrix-sdk-ui/tests/integration/room_list_service.rs index 616449d98..8e8f2a31a 100644 --- a/crates/matrix-sdk-ui/tests/integration/room_list_service.rs +++ b/crates/matrix-sdk-ui/tests/integration/room_list_service.rs @@ -1809,6 +1809,34 @@ async fn test_dynamic_entries_stream() -> Result<(), Error> { }; assert_pending!(dynamic_entries_stream); + // Let's reset to one page. + dynamic_entries.reset_to_one_page(); + + // Assert the dynamic entries. + assert_entries_batch! { + [dynamic_entries_stream] + // Receive a `truncate`. + truncate [5]; + end; + } + assert_pending!(dynamic_entries_stream); + + // Let's ask one more page again, because it's fun. + dynamic_entries.add_one_page(); + + // Assert the dynamic entries. + assert_entries_batch! { + [dynamic_entries_stream] + // Receive the next values. + append [ + F("!r5:bar.org"), + F("!r6:bar.org"), + F("!r7:bar.org"), + ]; + end; + }; + assert_pending!(dynamic_entries_stream); + Ok(()) } diff --git a/crates/matrix-sdk/src/sliding_sync/cache.rs b/crates/matrix-sdk/src/sliding_sync/cache.rs index e3072e92e..65ca3bd8b 100644 --- a/crates/matrix-sdk/src/sliding_sync/cache.rs +++ b/crates/matrix-sdk/src/sliding_sync/cache.rs @@ -279,7 +279,6 @@ mod tests { use std::sync::{Arc, RwLock}; use assert_matches::assert_matches; - use futures_util::StreamExt; use matrix_sdk_test::async_test; use super::{