Skip to content

Commit 0e70a2f

Browse files
committed
test(sdk): add a regression test for the thread relation forwarding for poll start events
This got fixed in Ruma, and the Ruma's bump in the parent commit includes this fix.
1 parent d70d758 commit 0e70a2f

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

crates/matrix-sdk/src/room/reply.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,4 +455,47 @@ mod tests {
455455
assert_eq!(thread.in_reply_to.as_ref().unwrap().event_id, event_id);
456456
assert!(thread.is_falling_back);
457457
}
458+
459+
#[async_test]
460+
async fn test_reply_forwarding_thread_for_poll_start() {
461+
let thread_root = event_id!("$thread_root");
462+
let event_id = event_id!("$thread_reply");
463+
let own_user_id = user_id!("@me:saucisse.bzh");
464+
465+
let mut cache = TestEventCache::default();
466+
let f = EventFactory::new();
467+
468+
cache.events.insert(
469+
event_id.to_owned(),
470+
f.poll_start(
471+
"would you rather… A) eat a pineapple pizza, B) drink pickle juice",
472+
"would you rather…",
473+
vec!["eat a pineapple pizza", "drink pickle juice"],
474+
)
475+
.in_thread(thread_root, thread_root)
476+
.event_id(event_id)
477+
.sender(own_user_id)
478+
.into(),
479+
);
480+
481+
let content = RoomMessageEventContentWithoutRelation::text_plain("the reply");
482+
483+
let reply_event = make_reply_event(
484+
cache,
485+
own_user_id,
486+
content,
487+
Reply {
488+
event_id: event_id.into(),
489+
enforce_thread: EnforceThread::Threaded(ReplyWithinThread::No),
490+
},
491+
)
492+
.await
493+
.unwrap();
494+
495+
assert_let!(Some(Relation::Thread(thread)) = &reply_event.relates_to);
496+
497+
assert_eq!(thread.event_id, thread_root);
498+
assert_eq!(thread.in_reply_to.as_ref().unwrap().event_id, event_id);
499+
assert!(thread.is_falling_back);
500+
}
458501
}

0 commit comments

Comments
 (0)