mod common;
use common::{setup, start_gateway_session};
use refluxer::http::endpoints::channels::ModifyChannel;
use refluxer::http::endpoints::guilds::CreateGuildChannel;
use refluxer::model::channel::ChannelType;
#[tokio::test]
async fn test_channel_create_modify_delete() {
let (http, guild_id) = setup();
let channel = http
.create_guild_channel(guild_id, &CreateGuildChannel::text("refluxer-test-channel"))
.await
.expect("create_guild_channel failed");
assert_eq!(channel.name.as_deref(), Some("refluxer-test-channel"));
assert_eq!(channel.kind, ChannelType::Text);
assert_eq!(channel.guild_id, Some(guild_id));
println!(
"Created channel: {} (id: {})",
channel.name.as_deref().unwrap_or("?"),
channel.id
);
let fetched = http
.get_channel(channel.id)
.await
.expect("get_channel failed");
assert_eq!(fetched.id, channel.id);
let modified = http
.modify_channel(
channel.id,
&ModifyChannel {
name: Some("refluxer-test-renamed".into()),
topic: Some("integration test channel".into()),
..Default::default()
},
)
.await
.expect("modify_channel failed");
assert_eq!(modified.name.as_deref(), Some("refluxer-test-renamed"));
assert_eq!(modified.topic.as_deref(), Some("integration test channel"));
http.delete_channel(channel.id)
.await
.expect("delete_channel failed");
let result = http.get_channel(channel.id).await;
assert!(result.is_err(), "channel should be deleted");
println!("Channel deleted successfully");
}
#[tokio::test]
async fn test_create_voice_channel_and_delete() {
let (http, guild_id) = setup();
let channel = http
.create_guild_channel(guild_id, &CreateGuildChannel::voice("refluxer-test-voice"))
.await
.expect("create voice channel failed");
assert_eq!(channel.kind, ChannelType::Voice);
http.delete_channel(channel.id)
.await
.expect("delete voice channel failed");
}
#[tokio::test]
async fn test_trigger_typing() {
let (http, guild_id) = setup();
let _gw = start_gateway_session().await;
let channel = http
.create_guild_channel(guild_id, &CreateGuildChannel::text("refluxer-test-typing"))
.await
.expect("create channel failed");
http.trigger_typing(channel.id)
.await
.expect("trigger_typing failed");
println!("Typing indicator test passed");
http.delete_channel(channel.id)
.await
.expect("cleanup channel failed");
}