Skip to content

Commit

Permalink
fixup! refactor(base): Remove impl From for SyncTimelineEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
richvdh committed Oct 17, 2024
1 parent efd6cda commit 3c1ea11
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion crates/matrix-sdk-ui/src/timeline/tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ async fn test_dedup_pagination() {
let event = timeline
.event_builder
.make_sync_message_event(*ALICE, RoomMessageEventContent::text_plain("o/"));
timeline.handle_live_event(event.clone()).await;
timeline.handle_live_event(SyncTimelineEvent::new(event.clone())).await;
// This cast is not actually correct, sync events aren't valid
// back-paginated events, as they are missing `room_id`. However, the
// timeline doesn't care about that `room_id` and casts back to
Expand Down
9 changes: 5 additions & 4 deletions crates/matrix-sdk-ui/src/timeline/tests/event_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use std::sync::Arc;
use assert_matches::assert_matches;
use assert_matches2::assert_let;
use eyeball_im::VectorDiff;
use matrix_sdk::deserialized_responses::SyncTimelineEvent;
use matrix_sdk_test::{async_test, sync_timeline_event, ALICE, BOB};
use ruma::events::{
room::{
Expand Down Expand Up @@ -164,26 +165,26 @@ async fn test_hide_failed_to_parse() {
// m.room.message events must have a msgtype and body in content, so this
// event with an empty content object should fail to deserialize.
timeline
.handle_live_event(sync_timeline_event!({
.handle_live_event(SyncTimelineEvent::new(sync_timeline_event!({
"content": {},
"event_id": "$eeG0HA0FAZ37wP8kXlNkxx3I",
"origin_server_ts": 10,
"sender": "@alice:example.org",
"type": "m.room.message",
}))
})))
.await;

// Similar to above, the m.room.member state event must also not have an
// empty content object.
timeline
.handle_live_event(sync_timeline_event!({
.handle_live_event(SyncTimelineEvent::new(sync_timeline_event!({
"content": {},
"event_id": "$d5G0HA0FAZ37wP8kXlNkxx3I",
"origin_server_ts": 2179,
"sender": "@alice:example.org",
"type": "m.room.member",
"state_key": "@alice:example.org",
}))
})))
.await;

assert_eq!(timeline.controller.items().await.len(), 0);
Expand Down
13 changes: 7 additions & 6 deletions crates/matrix-sdk-ui/src/timeline/tests/invalid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

use assert_matches2::assert_let;
use eyeball_im::VectorDiff;
use matrix_sdk::deserialized_responses::SyncTimelineEvent;
use matrix_sdk_test::{async_test, sync_timeline_event, ALICE, BOB};
use ruma::{
events::{room::message::MessageType, MessageLikeEventType, StateEventType},
Expand Down Expand Up @@ -59,13 +60,13 @@ async fn test_invalid_event_content() {
// m.room.message events must have a msgtype and body in content, so this
// event with an empty content object should fail to deserialize.
timeline
.handle_live_event(sync_timeline_event!({
.handle_live_event(SyncTimelineEvent::new(sync_timeline_event!({
"content": {},
"event_id": "$eeG0HA0FAZ37wP8kXlNkxx3I",
"origin_server_ts": 10,
"sender": "@alice:example.org",
"type": "m.room.message",
}))
})))
.await;

let item = assert_next_matches!(stream, VectorDiff::PushBack { value } => value);
Expand All @@ -78,14 +79,14 @@ async fn test_invalid_event_content() {
// Similar to above, the m.room.member state event must also not have an
// empty content object.
timeline
.handle_live_event(sync_timeline_event!({
.handle_live_event(SyncTimelineEvent::new(sync_timeline_event!({
"content": {},
"event_id": "$d5G0HA0FAZ37wP8kXlNkxx3I",
"origin_server_ts": 2179,
"sender": "@alice:example.org",
"type": "m.room.member",
"state_key": "@alice:example.org",
}))
})))
.await;

let item = assert_next_matches!(stream, VectorDiff::PushBack { value } => value);
Expand All @@ -106,15 +107,15 @@ async fn test_invalid_event() {
// This event is missing the sender field which the homeserver must add to
// all timeline events. Because the event is malformed, it will be ignored.
timeline
.handle_live_event(sync_timeline_event!({
.handle_live_event(SyncTimelineEvent::new(sync_timeline_event!({
"content": {
"body": "hello world",
"msgtype": "m.text"
},
"event_id": "$eeG0HA0FAZ37wP8kXlNkxx3I",
"origin_server_ts": 10,
"type": "m.room.message",
}))
})))
.await;
assert_eq!(timeline.controller.items().await.len(), 0);
}

0 comments on commit 3c1ea11

Please sign in to comment.