Exercise channel moderation threshold through the native editor
This commit is contained in:
1 parent
e696e7cc2d
commit
b0fc91f652
3 files changed
+36
-11
No files matched your search
@@ -395,9 +395,38 @@ fn talk_request_form_and_withdrawal_reach_peer() {
|
||||
generation: moderator.generation, parent_id: 0, properties,
|
||||
})).await.map_err(|e| e.message)?;
|
||||
let channel = created["channel_id"].as_u64().filter(|id| *id != 0).ok_or("missing temporary channel ID")?;
|
||||
let properties = Properties::channel_edit(json!({"channel_needed_talk_power":50}).as_object().unwrap().clone()).map_err(|e| e.message)?;
|
||||
owner.request(&moderator, Command::Admin(AdminCommand::ChannelEdit { generation: moderator.generation, channel_id: channel, properties }))
|
||||
.await.map_err(|e| format!("setting moderation threshold: {}", e.message))?;
|
||||
let threshold = |n:i64| both(&|s|s["channels"].as_array().is_some_and(|rows|rows.iter().any(|r|
|
||||
r["id"]==channel && r["name"]==channel_name && r["needed_talk_power"]==n)));
|
||||
// Both guests share the fixture's command budget.
|
||||
let pace = async || -> SmokeResult<()> {
|
||||
let (tx,rx)=tokio::sync::oneshot::channel();
|
||||
slint::Timer::single_shot(std::time::Duration::from_secs(5), move || {let _=tx.send(());});
|
||||
rx.await.map_err(|e|e.to_string())
|
||||
};
|
||||
until("new room with no talk power requirement",||threshold(0)).await?;
|
||||
let dialog = ui.global::<DialogBridge>();
|
||||
let shell = ui.global::<ShellBridge>();
|
||||
let moderator_tab=format!("tab/{}",moderator.connection_id);
|
||||
shell.invoke_select(moderator_tab.as_str().into());
|
||||
until("moderator tab selected",||shell.get_tabs().iter().any(|t|t.selected && t.connected && t.id.as_str()==moderator_tab)).await?;
|
||||
let room=Target{session:Some(moderator.clone()),entity:Entity::Channel{id:channel},name:channel_name.clone(),..Target::application()};
|
||||
for (expected,save) in [(0,false),(0,true),(50,false)] {
|
||||
pace().await?;
|
||||
runtime.dispatch_shell(ShellAction::Invoke{target:room.clone(),operation:Operation::ChannelEdit}).map_err(|e|e.message)?;
|
||||
let shown=expected.to_string();
|
||||
until("acknowledged threshold in the channel editor",||dialog.get_visible() && runtime.snapshot().dialog.as_ref().is_some_and(|f|f.target==room)
|
||||
&& dialog.get_fields().iter().any(|f|f.id=="channel_needed_talk_power" && f.value.as_str()==shown)).await?;
|
||||
if expected==0 {
|
||||
for invalid in ["-2147483649","2147483648"] {
|
||||
dialog.invoke_edit("channel_needed_talk_power".into(),invalid.into());dialog.invoke_submit();
|
||||
assert!(dialog.get_fields().iter().any(|f|f.id=="channel_needed_talk_power" && f.value==invalid && !f.error.is_empty()));
|
||||
}
|
||||
dialog.invoke_edit("channel_needed_talk_power".into(),"50".into());
|
||||
}
|
||||
if save {pace().await?;dialog.invoke_submit();} else {dialog.invoke_cancel();}
|
||||
until("threshold after edit",||!dialog.get_visible() && threshold(if save {50} else {expected})).await
|
||||
.map_err(|e|format!("{e}: {} {}",dialog.get_error(),runtime.snapshot().error))?;
|
||||
}
|
||||
for session in [&moderator, &guest] {
|
||||
if !manager.snapshot().get(&session.connection_id).and_then(|c| c.server.as_ref()).is_some_and(|s| s["own_channel_id"] == channel) {
|
||||
owner.request(session, Command::JoinChannel { channel_id: channel, password: None }).await.map_err(|e| e.message)?;
|
||||
@@ -420,18 +449,11 @@ fn talk_request_form_and_withdrawal_reach_peer() {
|
||||
&& r["channel_type"] == "temporary" && r["needed_talk_power"] == 50)
|
||||
})) && observed(false, None) && roster(moderator_id, &|r| r["is_talker"] == false)).await?;
|
||||
|
||||
let shell = ui.global::<ShellBridge>();
|
||||
let view = async |session: &SessionKey| -> SmokeResult<()> {
|
||||
let tab = format!("tab/{}", session.connection_id);
|
||||
shell.invoke_select(tab.as_str().into());
|
||||
until("selected live moderation tab", || shell.get_tabs().iter().any(|t| t.selected && t.connected && t.id.as_str() == tab)).await
|
||||
};
|
||||
// Let the fixture's normal command budget recover between moderation workflows.
|
||||
let pace = async || -> SmokeResult<()> {
|
||||
let (tx,rx)=tokio::sync::oneshot::channel();
|
||||
slint::Timer::single_shot(std::time::Duration::from_secs(5), move || {let _=tx.send(());});
|
||||
rx.await.map_err(|e|e.to_string())
|
||||
};
|
||||
pace().await?;
|
||||
view(&moderator).await?;
|
||||
activate_talk_menu(runtime, ui, &speaker_name, &speaker_name, Operation::TalkGrant, Some(Operation::TalkRevoke)).await?;
|
||||
@@ -442,7 +464,6 @@ fn talk_request_form_and_withdrawal_reach_peer() {
|
||||
.map_err(|e| format!("{e}: {}", runtime.snapshot().error))?;
|
||||
|
||||
let target = Target { session: Some(guest.clone()), entity: Entity::Connection, ..Target::application() };
|
||||
let dialog = ui.global::<DialogBridge>();
|
||||
let request = async |message: &str| -> SmokeResult<()> {
|
||||
runtime.dispatch_shell(ShellAction::Invoke { target: target.clone(), operation: Operation::TalkRequest }).map_err(|e| e.message)?;
|
||||
until("talk request form", || dialog.get_visible() && runtime.snapshot().dialog.as_ref().is_some_and(|f| f.operation == Operation::TalkRequest)).await?;
|
||||
|
||||
Reference in new issue
Block a user