test: Move room messages test JSON to the only module that uses it

This commit is contained in:
Jonas Platte
2023-09-28 13:53:25 +02:00
committed by Jonas Platte
parent 75d64e697e
commit b9c05ca934
3 changed files with 54 additions and 62 deletions

View File

@@ -18,18 +18,17 @@ use assert_matches::assert_matches;
use eyeball_im::VectorDiff;
use futures_util::future::join;
use matrix_sdk::config::SyncSettings;
use matrix_sdk_test::{
async_test, test_json, JoinedRoomBuilder, StateTestEvent, SyncResponseBuilder,
};
use matrix_sdk_test::{async_test, JoinedRoomBuilder, StateTestEvent, SyncResponseBuilder};
use matrix_sdk_ui::timeline::{
AnyOtherFullStateEventContent, BackPaginationStatus, PaginationOptions, RoomExt,
TimelineItemContent, VirtualTimelineItem,
};
use once_cell::sync::Lazy;
use ruma::{
events::{room::message::MessageType, FullStateEventContent},
room_id,
};
use serde_json::json;
use serde_json::{json, Value as JsonValue};
use stream_assert::{assert_next_eq, assert_next_matches};
use wiremock::{
matchers::{header, method, path_regex},
@@ -59,7 +58,7 @@ async fn back_pagination() {
Mock::given(method("GET"))
.and(path_regex(r"^/_matrix/client/r0/rooms/.*/messages$"))
.and(header("authorization", "Bearer 1234"))
.respond_with(ResponseTemplate::new(200).set_body_json(&*test_json::ROOM_MESSAGES_BATCH_1))
.respond_with(ResponseTemplate::new(200).set_body_json(&*ROOM_MESSAGES_BATCH_1))
.expect(1)
.named("messages_batch_1")
.mount(&server)
@@ -224,3 +223,53 @@ async fn back_pagination_highlighted() {
// `m.room.tombstone` should be highlighted by default.
assert!(remote_event.is_highlighted());
}
pub static ROOM_MESSAGES_BATCH_1: Lazy<JsonValue> = Lazy::new(|| {
json!({
"chunk": [
{
"age": 1042,
"content": {
"body": "hello world",
"msgtype": "m.text"
},
"event_id": "$1444812213350496Caaaf:example.com",
"origin_server_ts": 1444812213737i64,
"room_id": "!Xq3620DUiqCaoxq:example.com",
"sender": "@alice:example.com",
"type": "m.room.message"
},
{
"age": 20123,
"content": {
"body": "the world is big",
"msgtype": "m.text"
},
"event_id": "$1444812213350496Cbbbf:example.com",
"origin_server_ts": 1444812194656i64,
"room_id": "!Xq3620DUiqCaoxq:example.com",
"sender": "@bob:example.com",
"type": "m.room.message"
},
{
"age": 50789,
"content": {
"name": "New room name"
},
"event_id": "$1444812213350496Ccccf:example.com",
"origin_server_ts": 1444812163990i64,
"unsigned": {
"prev_content": {
"name": "Old room name",
},
},
"room_id": "!Xq3620DUiqCaoxq:example.com",
"sender": "@bob:example.com",
"state_key": "",
"type": "m.room.name"
}
],
"end": "t47409-4357353_219380_26003_2269",
"start": "t392-516_47314_0_7_1_1_1_11444_1"
})
});

View File

@@ -1,55 +0,0 @@
//! Example responses from calls to `GET
//! /_matrix/client/v3/rooms/{roomId}/messages`.
use once_cell::sync::Lazy;
use serde_json::{json, Value as JsonValue};
pub static ROOM_MESSAGES_BATCH_1: Lazy<JsonValue> = Lazy::new(|| {
json!({
"chunk": [
{
"age": 1042,
"content": {
"body": "hello world",
"msgtype": "m.text"
},
"event_id": "$1444812213350496Caaaf:example.com",
"origin_server_ts": 1444812213737i64,
"room_id": "!Xq3620DUiqCaoxq:example.com",
"sender": "@alice:example.com",
"type": "m.room.message"
},
{
"age": 20123,
"content": {
"body": "the world is big",
"msgtype": "m.text"
},
"event_id": "$1444812213350496Cbbbf:example.com",
"origin_server_ts": 1444812194656i64,
"room_id": "!Xq3620DUiqCaoxq:example.com",
"sender": "@bob:example.com",
"type": "m.room.message"
},
{
"age": 50789,
"content": {
"name": "New room name"
},
"event_id": "$1444812213350496Ccccf:example.com",
"origin_server_ts": 1444812163990i64,
"unsigned": {
"prev_content": {
"name": "Old room name",
},
},
"room_id": "!Xq3620DUiqCaoxq:example.com",
"sender": "@bob:example.com",
"state_key": "",
"type": "m.room.name"
}
],
"end": "t47409-4357353_219380_26003_2269",
"start": "t392-516_47314_0_7_1_1_1_11444_1"
})
});

View File

@@ -9,7 +9,6 @@ use serde_json::{json, Value as JsonValue};
pub mod api_responses;
pub mod members;
pub mod messages;
pub mod search_users;
pub mod sync;
pub mod sync_events;
@@ -21,7 +20,6 @@ pub use api_responses::{
UNKNOWN_TOKEN_SOFT_LOGOUT, VERSIONS, WELL_KNOWN, WHOAMI,
};
pub use members::MEMBERS;
pub use messages::ROOM_MESSAGES_BATCH_1;
pub use sync::{
DEFAULT_SYNC_ROOM_ID, DEFAULT_SYNC_SUMMARY, INVITE_SYNC, LEAVE_SYNC, LEAVE_SYNC_EVENT,
MORE_SYNC, MORE_SYNC_2, SYNC, VOIP_SYNC,