diff --git a/tests/prose-core-integration-tests/Cargo.toml b/tests/prose-core-integration-tests/Cargo.toml index a330b24b..98dc8aeb 100644 --- a/tests/prose-core-integration-tests/Cargo.toml +++ b/tests/prose-core-integration-tests/Cargo.toml @@ -10,6 +10,7 @@ anyhow = { workspace = true } async-trait = { workspace = true } chrono = { workspace = true } ctor = "0.2" +itertools = { workspace = true } jid = { workspace = true } minidom = { workspace = true } parking_lot = { workspace = true } diff --git a/tests/prose-core-integration-tests/src/tests/client/helpers/test_client_muc.rs b/tests/prose-core-integration-tests/src/tests/client/helpers/test_client_muc.rs index 96474d50..b2325f75 100644 --- a/tests/prose-core-integration-tests/src/tests/client/helpers/test_client_muc.rs +++ b/tests/prose-core-integration-tests/src/tests/client/helpers/test_client_muc.rs @@ -5,6 +5,7 @@ use anyhow::Result; use chrono::{DateTime, Duration, Utc}; +use jid::BareJid; use minidom::{Element, IntoAttributeValue}; use xmpp_parsers::mam::QueryId; @@ -26,9 +27,9 @@ pub struct JoinRoomStrategy { pub room_name: String, pub room_type: RoomType, pub room_settings: Option, - pub owners: Vec, - pub members: Vec, - pub admins: Vec, + pub owners: Vec, + pub members: Vec, + pub admins: Vec, pub user_affiliation: RoomAffiliation, pub receive_occupant_presences: Box, pub expect_catchup: Box, @@ -87,17 +88,17 @@ impl JoinRoomStrategy { self } - pub fn with_owners(mut self, owners: impl IntoIterator) -> Self { + pub fn with_owners(mut self, owners: impl IntoIterator) -> Self { self.owners = owners.into_iter().collect(); self } - pub fn with_admins(mut self, admins: impl IntoIterator) -> Self { + pub fn with_admins(mut self, admins: impl IntoIterator) -> Self { self.admins = admins.into_iter().collect(); self } - pub fn with_members(mut self, members: impl IntoIterator) -> Self { + pub fn with_members(mut self, members: impl IntoIterator) -> Self { self.members = members.into_iter().collect(); self } @@ -262,7 +263,7 @@ impl TestClient { fn expect_load_affiliations( client: &TestClient, affiliation: RoomAffiliation, - users: impl IntoIterator, + users: impl IntoIterator, ) { let users = users .into_iter() @@ -305,7 +306,7 @@ impl TestClient { RoomAffiliation::Owner, strategy.owners.into_iter().chain( (strategy.user_affiliation == RoomAffiliation::Owner) - .then_some(current_user_id.clone()), + .then_some(current_user_id.clone().into_inner()), ), ); @@ -314,7 +315,7 @@ impl TestClient { RoomAffiliation::Member, strategy.members.into_iter().chain( (strategy.user_affiliation == RoomAffiliation::Member) - .then_some(current_user_id.clone()), + .then_some(current_user_id.clone().into_inner()), ), ); @@ -323,7 +324,7 @@ impl TestClient { RoomAffiliation::Admin, strategy.admins.into_iter().chain( (strategy.user_affiliation == RoomAffiliation::Admin) - .then_some(current_user_id.clone()), + .then_some(current_user_id.clone().into_inner()), ), ); @@ -789,7 +790,7 @@ impl RoomResponse for RoomType { "# - }, + } RoomType::PrivateChannel => unimplemented!(), RoomType::PublicChannel => { r#" diff --git a/tests/prose-core-integration-tests/src/tests/client/muc.rs b/tests/prose-core-integration-tests/src/tests/client/muc.rs index a8664429..2e5c21e6 100644 --- a/tests/prose-core-integration-tests/src/tests/client/muc.rs +++ b/tests/prose-core-integration-tests/src/tests/client/muc.rs @@ -7,6 +7,9 @@ use anyhow::Result; use jid::BareJid; use pretty_assertions::assert_eq; +use super::helpers::{JoinRoomStrategy, TestClient}; +use crate::{event, recv, room_event, send}; +use itertools::Itertools; use prose_core_client::domain::shared::models::AnonOccupantId; use prose_core_client::domain::sidebar::models::BookmarkType; use prose_core_client::dtos::{ @@ -14,10 +17,7 @@ use prose_core_client::dtos::{ }; use prose_core_client::{muc_id, user_id, ClientEvent, ClientRoomEventType}; use prose_proc_macros::mt_test; - -use crate::{event, recv, room_event, send}; - -use super::helpers::TestClient; +use prose_xmpp::bare; #[mt_test] async fn test_joins_room() -> Result<()> { @@ -27,10 +27,29 @@ async fn test_joins_room() -> Result<()> { .expect_login(user_id!("user@prose.org"), "secret") .await?; + let strategy = JoinRoomStrategy::default().with_owners([ + bare!("owner@prose.org"), + // Some rooms may have owners that where the JID doesn't have a node. These should + // be ignored for now. + bare!("prose.org"), + ]); + client - .join_room(muc_id!("room@conference.prose.org"), "anon-id") + .join_room_with_strategy(muc_id!("room@conference.prose.org"), "anon-id", strategy) .await?; + let room = client.get_room(muc_id!("room@conference.prose.org")).await; + + assert_eq!( + vec![user_id!("owner@prose.org"), user_id!("user@prose.org")], + room.to_generic_room() + .participants() + .into_iter() + .filter_map(|p| p.user_id) + .sorted() + .collect::>() + ); + Ok(()) } diff --git a/tests/prose-core-integration-tests/src/tests/client/user_info.rs b/tests/prose-core-integration-tests/src/tests/client/user_info.rs index de244691..67f66d83 100644 --- a/tests/prose-core-integration-tests/src/tests/client/user_info.rs +++ b/tests/prose-core-integration-tests/src/tests/client/user_info.rs @@ -201,7 +201,7 @@ async fn test_joins_room() -> Result<()> { "# ) }).with_members( - [user_id!("john@prose.org")] + [bare!("john@prose.org")] ); client