Skip to content

Commit c84f596

Browse files
committed
test(ui): Fix tests according to last change.
This path adds events or state events to force the test to execute as expected since a change in `bump_stamp` alone doesn't trigger a room list update anymore.
1 parent 638028b commit c84f596

File tree

1 file changed

+97
-56
lines changed

1 file changed

+97
-56
lines changed

crates/matrix-sdk-ui/tests/integration/room_list_service.rs

Lines changed: 97 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1744,15 +1744,26 @@ async fn test_dynamic_entries_stream() -> Result<(), Error> {
17441744
"!r0:bar.org": {
17451745
"initial": true,
17461746
"bump_stamp": 9,
1747-
"required_state": [],
1747+
"required_state": [
1748+
{
1749+
"content": {
1750+
"name": "Look, a new name"
1751+
},
1752+
"sender": "@example:bar.org",
1753+
"state_key": "",
1754+
"type": "m.room.name",
1755+
"event_id": "$s8",
1756+
"origin_server_ts": 9,
1757+
},
1758+
],
17481759
},
17491760
},
17501761
},
17511762
};
17521763

17531764
// Assert the dynamic entries.
1754-
// `!r0:bar.org` has a more recent message.
1755-
// The room must move in the room list.
1765+
// `!r0:bar.org` has a new state event. The room must move in the room list
1766+
// because it has the highest recency.
17561767
assert_entries_batch! {
17571768
[dynamic_entries_stream]
17581769
pop back;
@@ -1910,14 +1921,44 @@ async fn test_room_sorting() -> Result<(), Error> {
19101921
},
19111922
},
19121923
"rooms": {
1913-
"!r0:bar.org": {
1924+
"!r0:bar.org": {
19141925
"bump_stamp": 7,
1926+
"timeline": [{
1927+
"content": {
1928+
"body": "foo",
1929+
"msgtype": "m.text"
1930+
},
1931+
"event_id": "$ev7",
1932+
"origin_server_ts": 7,
1933+
"sender": "@example:bar.org",
1934+
"type": "m.room.message",
1935+
}],
19151936
},
19161937
"!r1:bar.org": {
19171938
"bump_stamp": 6,
1939+
"timeline": [{
1940+
"content": {
1941+
"body": "foo",
1942+
"msgtype": "m.text"
1943+
},
1944+
"event_id": "$ev6",
1945+
"origin_server_ts": 6,
1946+
"sender": "@example:bar.org",
1947+
"type": "m.room.message",
1948+
}],
19181949
},
19191950
"!r2:bar.org": {
19201951
"bump_stamp": 9,
1952+
"timeline": [{
1953+
"content": {
1954+
"body": "foo",
1955+
"msgtype": "m.text"
1956+
},
1957+
"event_id": "$ev9",
1958+
"origin_server_ts": 9,
1959+
"sender": "@example:bar.org",
1960+
"type": "m.room.message",
1961+
}],
19211962
},
19221963
},
19231964
},
@@ -1975,6 +2016,23 @@ async fn test_room_sorting() -> Result<(), Error> {
19752016
// | 3 | !r4 | 5 | |
19762017
// | 4 | !r3 | 4 | |
19772018

2019+
// The Latest Events are updated.
2020+
assert_entries_batch! {
2021+
[stream]
2022+
set [ 1 ] [ "!r0:bar.org" ];
2023+
end;
2024+
};
2025+
assert_entries_batch! {
2026+
[stream]
2027+
set [ 2 ] [ "!r1:bar.org" ];
2028+
end;
2029+
};
2030+
assert_entries_batch! {
2031+
[stream]
2032+
set [ 0 ] [ "!r2:bar.org" ];
2033+
end;
2034+
};
2035+
19782036
assert_pending!(stream);
19792037

19802038
sync_then_assert_request_and_fake_response! {
@@ -1999,17 +2057,49 @@ async fn test_room_sorting() -> Result<(), Error> {
19992057
"!r6:bar.org": {
20002058
"initial": true,
20012059
"bump_stamp": 8,
2060+
"timeline": [{
2061+
"content": {
2062+
"body": "foo",
2063+
"msgtype": "m.text"
2064+
},
2065+
"event_id": "$ev8",
2066+
"origin_server_ts": 8,
2067+
"sender": "@example:bar.org",
2068+
"type": "m.room.message",
2069+
}],
20022070
},
20032071
"!r3:bar.org": {
20042072
"bump_stamp": 10,
2073+
"timeline": [{
2074+
"content": {
2075+
"body": "foo",
2076+
"msgtype": "m.text"
2077+
},
2078+
"event_id": "$ev10",
2079+
"origin_server_ts": 10,
2080+
"sender": "@example:bar.org",
2081+
"type": "m.room.message",
2082+
}],
20052083
},
20062084
},
20072085
},
20082086
};
20092087

20102088
assert_entries_batch! {
20112089
[stream]
2012-
insert [ 1 ] [ "!r6:bar.org" ];
2090+
insert [ 3 ] [ "!r6:bar.org" ];
2091+
end;
2092+
};
2093+
2094+
// The Latest Event is updated.
2095+
assert_entries_batch! {
2096+
[stream]
2097+
set [ 3 ] [ "!r6:bar.org" ];
2098+
end;
2099+
};
2100+
assert_entries_batch! {
2101+
[stream]
2102+
set [ 3 ] [ "!r6:bar.org" ];
20132103
end;
20142104
};
20152105

@@ -2042,67 +2132,18 @@ async fn test_room_sorting() -> Result<(), Error> {
20422132
// | 4 | !r1 | 6 | Aaa |
20432133
// | 5 | !r4 | 5 | |
20442134

2045-
// TODO (@hywan): Remove as soon as `RoomInfoNotableUpdateReasons::NONE` is
2046-
// removed.
2047-
assert_entries_batch! {
2048-
[stream]
2049-
set [ 2 ] [ "!r6:bar.org" ];
2050-
end;
2051-
};
2052-
2053-
// TODO (@hywan): Remove as soon as `RoomInfoNotableUpdateReasons::NONE` is
2054-
// removed.
2135+
// The Latest Events are updated.
20552136
assert_entries_batch! {
20562137
[stream]
2057-
set [ 2 ] [ "!r6:bar.org" ];
2138+
set [ 4 ] [ "!r6:bar.org" ];
20582139
end;
20592140
};
2060-
2061-
assert_pending!(stream);
2062-
2063-
sync_then_assert_request_and_fake_response! {
2064-
[server, room_list, sync]
2065-
states = Running => Running,
2066-
assert request >= {
2067-
"lists": {
2068-
ALL_ROOMS: {
2069-
"ranges": [[0, 5]],
2070-
"timeline_limit": 1,
2071-
},
2072-
},
2073-
},
2074-
respond with = {
2075-
"pos": "3",
2076-
"lists": {
2077-
ALL_ROOMS: {
2078-
"count": 6,
2079-
},
2080-
},
2081-
"rooms": {
2082-
"!r3:bar.org": {
2083-
"bump_stamp": 11,
2084-
},
2085-
},
2086-
},
2087-
};
2088-
20892141
assert_entries_batch! {
20902142
[stream]
20912143
set [ 0 ] [ "!r3:bar.org" ];
20922144
end;
20932145
};
20942146

2095-
// Now we have:
2096-
//
2097-
// | index | room ID | recency | name |
2098-
// |-------|---------|---------|------|
2099-
// | 0 | !r3 | 11 | |
2100-
// | 1 | !r2 | 9 | |
2101-
// | 2 | !r6 | 8 | |
2102-
// | 3 | !r0 | 7 | Bbb |
2103-
// | 4 | !r1 | 6 | Aaa |
2104-
// | 5 | !r4 | 5 | |
2105-
21062147
assert_pending!(stream);
21072148

21082149
Ok(())

0 commit comments

Comments
 (0)