Skip to content

Commit 1990b6b

Browse files
committed
test: Add mocked responses need for timeline storage
1 parent d5a91ce commit 1990b6b

File tree

3 files changed

+224
-3
lines changed

3 files changed

+224
-3
lines changed

crates/matrix-sdk-test/src/test_json/events.rs

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,102 @@ lazy_static! {
143143
});
144144
}
145145

146+
lazy_static! {
147+
pub static ref SYNC_ROOM_MESSAGES_BATCH_1: JsonValue = json!({
148+
"chunk": [
149+
{
150+
"age": 1042,
151+
"content": {
152+
"body": "hello world",
153+
"msgtype": "m.text"
154+
},
155+
"event_id": "$1444812213350496Caaaf:example.com",
156+
"origin_server_ts": 1444812213737i64,
157+
"room_id": "!Xq3620DUiqCaoxq:example.com",
158+
"sender": "@alice:example.com",
159+
"type": "m.room.message"
160+
},
161+
{
162+
"age": 20123,
163+
"content": {
164+
"body": "the world is big",
165+
"msgtype": "m.text"
166+
},
167+
"event_id": "$1444812213350496Cbbbf:example.com",
168+
"origin_server_ts": 1444812194656i64,
169+
"room_id": "!Xq3620DUiqCaoxq:example.com",
170+
"sender": "@bob:example.com",
171+
"type": "m.room.message"
172+
},
173+
{
174+
"age": 50789,
175+
"content": {
176+
"name": "New room name"
177+
},
178+
"event_id": "$1444812213350496Ccccf:example.com",
179+
"origin_server_ts": 1444812163990i64,
180+
"prev_content": {
181+
"name": "Old room name"
182+
},
183+
"room_id": "!Xq3620DUiqCaoxq:example.com",
184+
"sender": "@bob:example.com",
185+
"state_key": "",
186+
"type": "m.room.name"
187+
}
188+
],
189+
"end": "t47409-4357353_219380_26003_2269",
190+
"start": "t392-516_47314_0_7_1_1_1_11444_1"
191+
});
192+
}
193+
194+
lazy_static! {
195+
pub static ref SYNC_ROOM_MESSAGES_BATCH_2: JsonValue = json!({
196+
"chunk": [
197+
{
198+
"age": 1042,
199+
"content": {
200+
"body": "hello world",
201+
"msgtype": "m.text"
202+
},
203+
"event_id": "$1444812213350496Caaak:example.com",
204+
"origin_server_ts": 1444812213737i64,
205+
"room_id": "!Xq3620DUiqCaoxq:example.com",
206+
"sender": "@alice:example.com",
207+
"type": "m.room.message"
208+
},
209+
{
210+
"age": 20123,
211+
"content": {
212+
"body": "the world is big",
213+
"msgtype": "m.text"
214+
},
215+
"event_id": "$1444812213350496Cbbbk:example.com",
216+
"origin_server_ts": 1444812194656i64,
217+
"room_id": "!Xq3620DUiqCaoxq:example.com",
218+
"sender": "@bob:example.com",
219+
"type": "m.room.message"
220+
},
221+
{
222+
"age": 50789,
223+
"content": {
224+
"name": "New room name"
225+
},
226+
"event_id": "$1444812213350496Cccck:example.com",
227+
"origin_server_ts": 1444812163990i64,
228+
"prev_content": {
229+
"name": "Old room name"
230+
},
231+
"room_id": "!Xq3620DUiqCaoxq:example.com",
232+
"sender": "@bob:example.com",
233+
"state_key": "",
234+
"type": "m.room.name"
235+
}
236+
],
237+
"end": "t47409-4357353_219380_26003_2270",
238+
"start": "t47409-4357353_219380_26003_2269"
239+
});
240+
}
241+
146242
lazy_static! {
147243
pub static ref KEYS_QUERY: JsonValue = json!({
148244
"device_keys": {

crates/matrix-sdk-test/src/test_json/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ pub use events::{
1616
LOGIN_WITH_DISCOVERY, LOGOUT, MEMBER, MEMBER_INVITE, MEMBER_NAME_CHANGE, MEMBER_STRIPPED,
1717
MESSAGE_EDIT, MESSAGE_TEXT, NAME, NAME_STRIPPED, POWER_LEVELS, PRESENCE, PUBLIC_ROOMS,
1818
PUSH_RULES, REACTION, READ_RECEIPT, READ_RECEIPT_OTHER, REDACTED, REDACTED_INVALID,
19-
REDACTED_STATE, REDACTION, REGISTRATION_RESPONSE_ERR, ROOM_ID, ROOM_MESSAGES, TAG, TOPIC,
20-
TYPING,
19+
REDACTED_STATE, REDACTION, REGISTRATION_RESPONSE_ERR, ROOM_ID, ROOM_MESSAGES,
20+
SYNC_ROOM_MESSAGES_BATCH_1, SYNC_ROOM_MESSAGES_BATCH_2, TAG, TOPIC, TYPING,
2121
};
2222
pub use members::MEMBERS;
2323
pub use sync::{
24-
DEFAULT_SYNC_SUMMARY, INVITE_SYNC, LEAVE_SYNC, LEAVE_SYNC_EVENT, MORE_SYNC, SYNC, VOIP_SYNC,
24+
DEFAULT_SYNC_SUMMARY, INVITE_SYNC, LEAVE_SYNC, LEAVE_SYNC_EVENT, MORE_SYNC, MORE_SYNC_2, SYNC,
25+
VOIP_SYNC,
2526
};
2627

2728
lazy_static! {

crates/matrix-sdk-test/src/test_json/sync.rs

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,130 @@ lazy_static! {
717717
});
718718
}
719719

720+
lazy_static! {
721+
pub static ref MORE_SYNC_2: JsonValue = json!({
722+
"next_batch": "s526_47314_0_7_1_1_1_11444_3",
723+
"rooms": {
724+
"join": {
725+
"!SVkFJHzfwvuaIEawgC:localhost": {
726+
"timeline": {
727+
"events": [
728+
{
729+
"content": {
730+
"body": "baba",
731+
"format": "org.matrix.custom.html",
732+
"formatted_body": "<strong>baba</strong>",
733+
"msgtype": "m.text"
734+
},
735+
"event_id": "$152037280074GZeOm2:localhost",
736+
"origin_server_ts": 152037280,
737+
"sender": "@example:localhost",
738+
"type": "m.room.message",
739+
"unsigned": {
740+
"age": 598971425
741+
}
742+
},
743+
{
744+
"content": {
745+
"body": " * edited message",
746+
"m.new_content": {
747+
"body": "edited message",
748+
"msgtype": "m.text"
749+
},
750+
"m.relates_to": {
751+
"event_id": "$someeventid:localhost",
752+
"rel_type": "m.replace"
753+
},
754+
"msgtype": "m.text"
755+
},
756+
"event_id": "$editevid2:localhost",
757+
"origin_server_ts": 159026265,
758+
"sender": "@alice:matrix.org",
759+
"type": "m.room.message",
760+
"unsigned": {
761+
"age": 85
762+
}
763+
},
764+
{
765+
"content": {
766+
"reason": "😀"
767+
},
768+
"event_id": "$151957878228ssqrJ2:localhost",
769+
"origin_server_ts": 151957878,
770+
"sender": "@example:localhost",
771+
"type": "m.room.redaction",
772+
"redacts": "$151957878228ssqrj:localhost",
773+
"unsigned": {
774+
"age": 85
775+
}
776+
},
777+
{
778+
"content": {},
779+
"event_id": "$15275046980maRLj2:localhost",
780+
"origin_server_ts": 152750469,
781+
"sender": "@example:localhost",
782+
"type": "m.room.message",
783+
"unsigned": {
784+
"age": 19334,
785+
"redacted_because": {
786+
"content": {},
787+
"event_id": "$15275047031IXQRi:localhost",
788+
"origin_server_ts": 152750470,
789+
"redacts": "$15275046980maRLj:localhost",
790+
"sender": "@example:localhost",
791+
"type": "m.room.redaction",
792+
"unsigned": {
793+
"age": 14523
794+
}
795+
},
796+
"redacted_by": "$15275047031IXQRi:localhost"
797+
}
798+
},
799+
{
800+
"content": {
801+
"m.relates_to": {
802+
"event_id": "$15275047031IXQRi:localhost",
803+
"key": "👍",
804+
"rel_type": "m.annotation"
805+
}
806+
},
807+
"event_id": "$15275047031IXQRi2:localhost",
808+
"origin_server_ts": 159027581,
809+
"sender": "@alice:matrix.org",
810+
"type": "m.reaction",
811+
"unsigned": {
812+
"age": 85
813+
}
814+
},
815+
{
816+
"content": {
817+
"body": "This is a notice",
818+
"format": "org.matrix.custom.html",
819+
"formatted_body": "<em>This is a notice</em>",
820+
"msgtype": "m.notice"
821+
},
822+
"event_id": "$098237280074GZeOm2:localhost",
823+
"origin_server_ts": 162037280,
824+
"sender": "@bot:localhost",
825+
"type": "m.room.message",
826+
"unsigned": {
827+
"age": 25
828+
}
829+
},
830+
],
831+
"limited": true,
832+
"prev_batch": "s526_47314_0_7_1_1_1_11444_2"
833+
},
834+
"unread_notifications": {
835+
"highlight_count": 0,
836+
"notification_count": 11
837+
}
838+
}
839+
},
840+
},
841+
});
842+
}
843+
720844
lazy_static! {
721845
pub static ref INVITE_SYNC: JsonValue = json!({
722846
"device_one_time_keys_count": {},

0 commit comments

Comments
 (0)