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 cf6ec16 commit 143a27c
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions crates/matrix-sdk-ui/src/timeline/tests/encryption.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use matrix_sdk::{
crypto::{decrypt_room_key_export, types::events::UtdCause, OlmMachine},
test_utils::test_client_builder,
};
use matrix_sdk_base::deserialized_responses::SyncTimelineEvent;
use matrix_sdk_test::{async_test, BOB};
use ruma::{
assign,
Expand Down Expand Up @@ -475,7 +476,9 @@ async fn test_utd_cause_for_nonmember_event_is_found() {
let mut stream = timeline.subscribe().await;

// When we add an event with "membership: leave"
timeline.handle_live_event(raw_event_with_unsigned(json!({ "membership": "leave" }))).await;
timeline
.handle_live_event(sync_timeline_event_with_unsigned(json!({ "membership": "leave" })))
.await;

// Then its UTD cause is membership
let item = assert_next_matches!(stream, VectorDiff::PushBack { value } => value);
Expand All @@ -495,7 +498,7 @@ async fn test_utd_cause_for_nonmember_event_is_found_unstable_prefix() {

// When we add an event with "io.element.msc4115.membership: leave"
timeline
.handle_live_event(raw_event_with_unsigned(
.handle_live_event(sync_timeline_event_with_unsigned(
json!({ "io.element.msc4115.membership": "leave" }),
))
.await;
Expand All @@ -517,7 +520,9 @@ async fn test_utd_cause_for_member_event_is_unknown() {
let mut stream = timeline.subscribe().await;

// When we add an event with "membership: join"
timeline.handle_live_event(raw_event_with_unsigned(json!({ "membership": "join" }))).await;
timeline
.handle_live_event(sync_timeline_event_with_unsigned(json!({ "membership": "join" })))
.await;

// Then its UTD cause is membership
let item = assert_next_matches!(stream, VectorDiff::PushBack { value } => value);
Expand All @@ -536,7 +541,7 @@ async fn test_utd_cause_for_missing_membership_is_unknown() {
let mut stream = timeline.subscribe().await;

// When we add an event with no membership in unsigned
timeline.handle_live_event(raw_event_with_unsigned(json!({}))).await;
timeline.handle_live_event(sync_timeline_event_with_unsigned(json!({}))).await;

// Then its UTD cause is membership
let item = assert_next_matches!(stream, VectorDiff::PushBack { value } => value);
Expand All @@ -548,8 +553,8 @@ async fn test_utd_cause_for_missing_membership_is_unknown() {
assert_eq!(*cause, UtdCause::Unknown);
}

fn raw_event_with_unsigned(unsigned: serde_json::Value) -> Raw<AnySyncTimelineEvent> {
Raw::from_json(
fn sync_timeline_event_with_unsigned(unsigned: serde_json::Value) -> SyncTimelineEvent {
SyncTimelineEvent::new(Raw::from_json(
to_raw_value(&json!({
"event_id": "$myevent",
"sender": "@u:s",
Expand All @@ -566,5 +571,5 @@ fn raw_event_with_unsigned(unsigned: serde_json::Value) -> Raw<AnySyncTimelineEv

}))
.unwrap(),
)
))
}

0 comments on commit 143a27c

Please sign in to comment.