-
Notifications
You must be signed in to change notification settings - Fork 268
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ui: Add tests for Sent In Clear shield.
- Loading branch information
Showing
2 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use eyeball_im::VectorDiff; | ||
use matrix_sdk_base::deserialized_responses::ShieldState; | ||
use matrix_sdk_test::{async_test, ALICE}; | ||
use ruma::events::room::message::RoomMessageEventContent; | ||
use stream_assert::assert_next_matches; | ||
|
||
use crate::timeline::tests::TestTimeline; | ||
|
||
#[async_test] | ||
async fn test_no_shield_in_unencrypted_room() { | ||
let timeline = TestTimeline::new(); | ||
let mut stream = timeline.subscribe().await; | ||
|
||
timeline | ||
.handle_live_message_event( | ||
&ALICE, | ||
RoomMessageEventContent::text_plain("Unencrypted message."), | ||
) | ||
.await; | ||
|
||
let item = assert_next_matches!(stream, VectorDiff::PushBack { value } => value); | ||
let shield = item.as_event().unwrap().get_shield(false); | ||
assert!(shield.is_none()); | ||
} | ||
|
||
#[async_test] | ||
async fn test_sent_in_clear_shield() { | ||
let timeline = TestTimeline::with_is_room_encrypted(true); | ||
let mut stream = timeline.subscribe().await; | ||
|
||
timeline | ||
.handle_live_message_event( | ||
&ALICE, | ||
RoomMessageEventContent::text_plain("Unencrypted message."), | ||
) | ||
.await; | ||
|
||
let item = assert_next_matches!(stream, VectorDiff::PushBack { value } => value); | ||
let shield = item.as_event().unwrap().get_shield(false); | ||
assert_eq!(shield, Some(ShieldState::Grey { message: "Sent in clear." })); | ||
} |