mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-15 19:45:34 -04:00
test(ui): Add a test specifically for RoomList::invites.
This commit is contained in:
@@ -994,7 +994,7 @@ async fn test_entries_stream() -> Result<(), Error> {
|
||||
set[1] [ F("!r1:bar.org") ];
|
||||
set[2] [ F("!r2:bar.org") ];
|
||||
pending;
|
||||
}
|
||||
};
|
||||
|
||||
sync_then_assert_request_and_fake_response! {
|
||||
[server, room_list, sync]
|
||||
@@ -1002,13 +1002,14 @@ async fn test_entries_stream() -> Result<(), Error> {
|
||||
assert request = {
|
||||
"lists": {
|
||||
ALL_ROOMS: {
|
||||
"ranges": [
|
||||
[0, 9],
|
||||
],
|
||||
"ranges": [[0, 9]],
|
||||
},
|
||||
VISIBLE_ROOMS: {
|
||||
"ranges": [[0, 19]],
|
||||
},
|
||||
INVITES: {
|
||||
"ranges": [[0, 99]],
|
||||
},
|
||||
},
|
||||
},
|
||||
respond with = {
|
||||
@@ -1028,7 +1029,7 @@ async fn test_entries_stream() -> Result<(), Error> {
|
||||
{
|
||||
"op": "INSERT",
|
||||
"index": 0,
|
||||
"room_id": "!r3:bar.org"
|
||||
"room_id": "!r3:bar.org",
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -1055,7 +1056,7 @@ async fn test_entries_stream() -> Result<(), Error> {
|
||||
remove[0];
|
||||
insert[0] [ F("!r3:bar.org") ];
|
||||
pending;
|
||||
}
|
||||
};
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -1201,6 +1202,162 @@ async fn test_entries_stream_with_updated_filter() -> Result<(), Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[async_test]
|
||||
async fn test_invites_stream() -> Result<(), Error> {
|
||||
let (server, room_list) = new_room_list().await?;
|
||||
|
||||
let sync = room_list.sync();
|
||||
pin_mut!(sync);
|
||||
|
||||
// The invites aren't accessible yet.
|
||||
assert!(room_list.invites().await.is_err());
|
||||
|
||||
sync_then_assert_request_and_fake_response! {
|
||||
[server, room_list, sync]
|
||||
states = Init => FirstRooms,
|
||||
assert request = {
|
||||
"lists": {
|
||||
ALL_ROOMS: {
|
||||
"ranges": [[0, 19]],
|
||||
},
|
||||
},
|
||||
},
|
||||
respond with = {
|
||||
"pos": "0",
|
||||
"lists": {
|
||||
ALL_ROOMS: {
|
||||
"count": 0,
|
||||
},
|
||||
},
|
||||
"rooms": {},
|
||||
},
|
||||
};
|
||||
|
||||
// The invites aren't accessible yet.
|
||||
assert!(room_list.invites().await.is_err());
|
||||
|
||||
let room_id_0 = room_id!("!r0:bar.org");
|
||||
|
||||
sync_then_assert_request_and_fake_response! {
|
||||
[server, room_list, sync]
|
||||
states = FirstRooms => AllRooms,
|
||||
assert request = {
|
||||
"lists": {
|
||||
ALL_ROOMS: {
|
||||
"ranges": [[0, 0]],
|
||||
},
|
||||
VISIBLE_ROOMS: {
|
||||
"ranges": [[0, 19]],
|
||||
},
|
||||
INVITES: {
|
||||
"ranges": [[0, 99]],
|
||||
},
|
||||
},
|
||||
},
|
||||
respond with = {
|
||||
"pos": "1",
|
||||
"lists": {
|
||||
ALL_ROOMS: {
|
||||
"count": 0,
|
||||
},
|
||||
VISIBLE_ROOMS: {
|
||||
"count": 0,
|
||||
},
|
||||
INVITES: {
|
||||
"count": 1,
|
||||
"ops": [
|
||||
{
|
||||
"op": "SYNC",
|
||||
"range": [0, 0],
|
||||
"room_ids": [
|
||||
room_id_0,
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
"rooms": {
|
||||
room_id_0: {
|
||||
"name": "Invitation for Room #0",
|
||||
"initial": true,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
let (previous_invites, invites_stream) = room_list.invites().await?;
|
||||
pin_mut!(invites_stream);
|
||||
|
||||
assert_eq!(previous_invites.len(), 1);
|
||||
assert_matches!(&previous_invites[0], RoomListEntry::Filled(room_id) => {
|
||||
assert_eq!(room_id, room_id_0);
|
||||
});
|
||||
|
||||
assert_entries_stream! {
|
||||
[invites_stream]
|
||||
pending;
|
||||
};
|
||||
|
||||
sync_then_assert_request_and_fake_response! {
|
||||
[server, room_list, sync]
|
||||
states = AllRooms => CarryOn,
|
||||
assert request = {
|
||||
"lists": {
|
||||
ALL_ROOMS: {
|
||||
"ranges": [[0, 0]],
|
||||
},
|
||||
VISIBLE_ROOMS: {
|
||||
"ranges": [[0, 19]],
|
||||
},
|
||||
INVITES: {
|
||||
"ranges": [[0, 0]],
|
||||
},
|
||||
},
|
||||
},
|
||||
respond with = {
|
||||
"pos": "2",
|
||||
"lists": {
|
||||
ALL_ROOMS: {
|
||||
"count": 0,
|
||||
},
|
||||
VISIBLE_ROOMS: {
|
||||
"count": 0,
|
||||
},
|
||||
INVITES: {
|
||||
"count": 1,
|
||||
"ops": [
|
||||
{
|
||||
"op": "DELETE",
|
||||
"index": 0,
|
||||
},
|
||||
{
|
||||
|
||||
"op": "INSERT",
|
||||
"index": 0,
|
||||
"room_id": "!r1:bar.org",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
"rooms": {
|
||||
"!r1:bar.org": {
|
||||
"name": "Invitation for Room #1",
|
||||
"initial": true,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
assert_entries_stream! {
|
||||
[invites_stream]
|
||||
remove[0];
|
||||
insert[0] [ F("!r1:bar.org") ];
|
||||
pending;
|
||||
};
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[async_test]
|
||||
async fn test_room() -> Result<(), Error> {
|
||||
let (server, room_list) = new_room_list().await?;
|
||||
|
||||
Reference in New Issue
Block a user