tests: add support for the global account IgnoredUserList event in the event factory
This commit is contained in:
@@ -3010,8 +3010,8 @@ pub(crate) mod tests {
|
||||
RoomState,
|
||||
};
|
||||
use matrix_sdk_test::{
|
||||
async_test, GlobalAccountDataTestEvent, JoinedRoomBuilder, StateTestEvent,
|
||||
SyncResponseBuilder, DEFAULT_TEST_ROOM_ID,
|
||||
async_test, event_factory::EventFactory, GlobalAccountDataTestEvent, JoinedRoomBuilder,
|
||||
StateTestEvent, SyncResponseBuilder, DEFAULT_TEST_ROOM_ID,
|
||||
};
|
||||
#[cfg(target_family = "wasm")]
|
||||
wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
|
||||
@@ -3029,7 +3029,7 @@ pub(crate) mod tests {
|
||||
ignored_user_list::IgnoredUserListEventContent,
|
||||
media_preview_config::{InviteAvatars, MediaPreviewConfigEventContent, MediaPreviews},
|
||||
},
|
||||
owned_room_id, room_alias_id, room_id, RoomId, ServerName, UserId,
|
||||
owned_room_id, owned_user_id, room_alias_id, room_id, RoomId, ServerName, UserId,
|
||||
};
|
||||
use serde_json::json;
|
||||
use stream_assert::{assert_next_matches, assert_pending};
|
||||
@@ -3054,10 +3054,13 @@ pub(crate) mod tests {
|
||||
let server = MatrixMockServer::new().await;
|
||||
let client = server.client_builder().build().await;
|
||||
|
||||
let f = EventFactory::new();
|
||||
server
|
||||
.mock_sync()
|
||||
.ok_and_run(&client, |builder| {
|
||||
builder.add_global_account_data_event(GlobalAccountDataTestEvent::IgnoredUserList);
|
||||
builder.add_global_account_data(
|
||||
f.ignored_user_list([owned_user_id!("@someone:example.org")]).into_raw(),
|
||||
);
|
||||
})
|
||||
.await;
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ use ruma::{
|
||||
notify::{ApplicationType, CallNotifyEventContent, NotifyType},
|
||||
},
|
||||
direct::{DirectEventContent, OwnedDirectUserIdentifier},
|
||||
ignored_user_list::IgnoredUserListEventContent,
|
||||
member_hints::MemberHintsEventContent,
|
||||
poll::{
|
||||
unstable_end::UnstablePollEndEventContent,
|
||||
@@ -999,6 +1000,16 @@ impl EventFactory {
|
||||
builder
|
||||
}
|
||||
|
||||
/// Create a new `m.ignored_user_list` global account data event.
|
||||
pub fn ignored_user_list(
|
||||
&self,
|
||||
users: impl IntoIterator<Item = OwnedUserId>,
|
||||
) -> EventBuilder<IgnoredUserListEventContent> {
|
||||
let mut builder = self.event(IgnoredUserListEventContent::users(users));
|
||||
builder.is_global = true;
|
||||
builder
|
||||
}
|
||||
|
||||
/// Set the next server timestamp.
|
||||
///
|
||||
/// Timestamps will continue to increase by 1 (millisecond) from that value.
|
||||
|
||||
@@ -152,7 +152,6 @@ impl SyncResponseBuilder {
|
||||
) -> &mut Self {
|
||||
let val = match event {
|
||||
GlobalAccountDataTestEvent::PushRules => test_json::PUSH_RULES.to_owned(),
|
||||
GlobalAccountDataTestEvent::IgnoredUserList => test_json::IGNORED_USER_LIST.to_owned(),
|
||||
GlobalAccountDataTestEvent::Custom(json) => json,
|
||||
};
|
||||
|
||||
|
||||
@@ -150,7 +150,6 @@ impl From<PresenceTestEvent> for Raw<PresenceEvent> {
|
||||
/// Test events that can be added to the global account data.
|
||||
pub enum GlobalAccountDataTestEvent {
|
||||
PushRules,
|
||||
IgnoredUserList,
|
||||
Custom(JsonValue),
|
||||
}
|
||||
|
||||
@@ -158,9 +157,6 @@ impl From<GlobalAccountDataTestEvent> for JsonValue {
|
||||
fn from(val: GlobalAccountDataTestEvent) -> Self {
|
||||
match val {
|
||||
GlobalAccountDataTestEvent::PushRules => test_json::sync_events::PUSH_RULES.to_owned(),
|
||||
GlobalAccountDataTestEvent::IgnoredUserList => {
|
||||
test_json::sync_events::IGNORED_USER_LIST.to_owned()
|
||||
}
|
||||
GlobalAccountDataTestEvent::Custom(json) => json,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,10 +29,9 @@ pub use sync::{
|
||||
VOIP_SYNC,
|
||||
};
|
||||
pub use sync_events::{
|
||||
ALIAS, ALIASES, ENCRYPTION, IGNORED_USER_LIST, MEMBER, MEMBER_ADDITIONAL, MEMBER_BAN,
|
||||
MEMBER_INVITE, MEMBER_LEAVE, MEMBER_NAME_CHANGE, MEMBER_STRIPPED, NAME, NAME_STRIPPED,
|
||||
POWER_LEVELS, PRESENCE, PUSH_RULES, REDACTED_INVALID, REDACTED_STATE, TAG, TOPIC,
|
||||
TOPIC_REDACTION,
|
||||
ALIAS, ALIASES, ENCRYPTION, MEMBER, MEMBER_ADDITIONAL, MEMBER_BAN, MEMBER_INVITE, MEMBER_LEAVE,
|
||||
MEMBER_NAME_CHANGE, MEMBER_STRIPPED, NAME, NAME_STRIPPED, POWER_LEVELS, PRESENCE, PUSH_RULES,
|
||||
REDACTED_INVALID, REDACTED_STATE, TAG, TOPIC, TOPIC_REDACTION,
|
||||
};
|
||||
|
||||
/// An empty response.
|
||||
|
||||
@@ -723,14 +723,3 @@ pub static MARKED_UNREAD: Lazy<JsonValue> = Lazy::new(|| {
|
||||
"type": "m.marked_unread",
|
||||
})
|
||||
});
|
||||
|
||||
pub static IGNORED_USER_LIST: Lazy<JsonValue> = Lazy::new(|| {
|
||||
json!({
|
||||
"content": {
|
||||
"ignored_users": {
|
||||
"@someone:example.org": {},
|
||||
},
|
||||
},
|
||||
"type": "m.ignored_user_list",
|
||||
})
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user