mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-18 21:52:30 -04:00
test(base): Test RoomInfoNotableUpdateReason::RECENCY_TIMESTAMP is sent.
This patch adds a missing test to ensure that a `RoomInfoNotableUpdateReason::RECENCY_TIMESTAMP` is correctly sent.
This commit is contained in:
@@ -806,7 +806,7 @@ mod tests {
|
||||
rooms::normal::{RoomHero, RoomInfoNotableUpdateReasons},
|
||||
store::MemoryStore,
|
||||
test_utils::logged_in_base_client,
|
||||
BaseClient, Room, RoomState,
|
||||
BaseClient, Room, RoomInfoNotableUpdate, RoomState,
|
||||
};
|
||||
|
||||
#[async_test]
|
||||
@@ -1847,6 +1847,46 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[async_test]
|
||||
async fn test_recency_timestamp_can_trigger_a_notable_update_reason() {
|
||||
// Given a logged-in client
|
||||
let client = logged_in_base_client(None).await;
|
||||
let mut room_info_notable_update_stream = client.room_info_notable_update_receiver();
|
||||
let room_id = room_id!("!r:e.uk");
|
||||
|
||||
// When I send sliding sync response containing a room with a recency timestamp.
|
||||
let room = assign!(v4::SlidingSyncRoom::new(), {
|
||||
timestamp: Some(MilliSecondsSinceUnixEpoch(42u32.into())),
|
||||
});
|
||||
let response = response_with_room(room_id, room);
|
||||
client.process_sliding_sync(&response, &()).await.expect("Failed to process sync");
|
||||
|
||||
// Then a room info notable update is NOT received, because it's the first time the room is seen.
|
||||
assert_matches!(
|
||||
room_info_notable_update_stream.recv().await,
|
||||
Ok(RoomInfoNotableUpdate { room_id: received_room_id, reasons: received_reasons }) => {
|
||||
assert_eq!(received_room_id, room_id);
|
||||
assert!(!received_reasons.contains(RoomInfoNotableUpdateReasons::RECENCY_TIMESTAMP));
|
||||
}
|
||||
);
|
||||
|
||||
// When I send sliding sync response containing a room with a recency timestamp.
|
||||
let room = assign!(v4::SlidingSyncRoom::new(), {
|
||||
timestamp: Some(MilliSecondsSinceUnixEpoch(43u32.into())),
|
||||
});
|
||||
let response = response_with_room(room_id, room);
|
||||
client.process_sliding_sync(&response, &()).await.expect("Failed to process sync");
|
||||
|
||||
// Then a room info notable update is received.
|
||||
assert_matches!(
|
||||
room_info_notable_update_stream.recv().await,
|
||||
Ok(RoomInfoNotableUpdate { room_id: received_room_id, reasons: received_reasons }) => {
|
||||
assert_eq!(received_room_id, room_id);
|
||||
assert!(received_reasons.contains(RoomInfoNotableUpdateReasons::RECENCY_TIMESTAMP));
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
async fn choose_event_to_cache(events: &[SyncTimelineEvent]) -> Option<SyncTimelineEvent> {
|
||||
let room = make_room();
|
||||
let mut room_info = room.clone_info();
|
||||
|
||||
Reference in New Issue
Block a user