test: cover server host banner edits on beta14
Verify input bounds, cancel, independent and combined changes, and exact restoration through the Slint editor and a second guest. Record fixture-only URL values and the focused live receipt.
This commit is contained in:
1 parent
ec580edc90
commit
a31367cc51
8 files changed
+209
-34
No files matched your search
@@ -26,6 +26,7 @@ struct Headless {
|
||||
queue: Arc<Queue>,
|
||||
windows: RefCell<Vec<Surface>>,
|
||||
started: Instant,
|
||||
deadline: Duration,
|
||||
}
|
||||
impl Platform for Headless {
|
||||
fn create_window_adapter(&self) -> Result<Rc<dyn WindowAdapter>, slint::PlatformError> {
|
||||
@@ -40,7 +41,7 @@ impl Platform for Headless {
|
||||
fn duration_since_start(&self) -> Duration { self.started.elapsed() }
|
||||
fn run_event_loop(&self) -> Result<(), slint::PlatformError> {
|
||||
self.queue.quit.store(false, Ordering::Release);
|
||||
let deadline = Instant::now() + Duration::from_secs(150);
|
||||
let deadline = Instant::now() + self.deadline;
|
||||
while !self.queue.quit.load(Ordering::Acquire) {
|
||||
// Drain a bounded batch so queued workers cannot starve UI timers and input.
|
||||
for _ in 0..256 {
|
||||
@@ -70,8 +71,12 @@ impl Platform for Headless {
|
||||
}
|
||||
}
|
||||
pub fn install() -> Result<(), String> {
|
||||
install_with_deadline(Duration::from_secs(150))
|
||||
}
|
||||
|
||||
pub(super) fn install_with_deadline(deadline: Duration) -> Result<(), String> {
|
||||
slint::platform::set_platform(Box::new(Headless {
|
||||
queue: Arc::new(Queue::default()), windows: RefCell::new(Vec::new()), started: Instant::now(),
|
||||
queue: Arc::new(Queue::default()), windows: RefCell::new(Vec::new()), started: Instant::now(), deadline,
|
||||
})).map_err(|error| error.to_string())
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,9 @@ use serde_json::Value;
|
||||
use slint::{ComponentHandle, LogicalPosition, Model, SharedString, platform::{Key, WindowEvent}};
|
||||
use teamspeach_core::{admin::{AdminCommand, MAX_SAFE_INTEGER}, protocol::Command};
|
||||
|
||||
#[path = "server_host_banner.rs"]
|
||||
pub(super) mod host_banner;
|
||||
|
||||
struct Trial {
|
||||
fixture: &'static str,
|
||||
fields: [&'static str; 2],
|
||||
@@ -72,7 +75,7 @@ pub(super) async fn exercise_quotas(runtime: &AppRuntime, ui: &AppWindow, owner:
|
||||
pub(super) async fn exercise_bandwidth(runtime: &AppRuntime, ui: &AppWindow, owner: &RuntimeServices,
|
||||
tabs: &[SessionKey; 2], uid: &str, initial: &Value) -> SmokeResult<()> {
|
||||
let trial = &BANDWIDTH;
|
||||
let editor = editor_for(runtime, ui, &tabs[0], uid, initial, trial)?;
|
||||
let editor = editor_for(runtime, ui, &tabs[0], uid, initial, trial.fixture, trial.fields, trial.baseline)?;
|
||||
let peer = &tabs[1];
|
||||
let [download, upload] = trial.baseline;
|
||||
let [new_download, new_upload] = trial.changed;
|
||||
@@ -125,19 +128,19 @@ pub(super) async fn exercise_bandwidth(runtime: &AppRuntime, ui: &AppWindow, own
|
||||
editor.closed().await
|
||||
}
|
||||
|
||||
fn editor_for<'a>(runtime: &'a AppRuntime, ui: &'a AppWindow, key: &'a SessionKey, uid: &'a str,
|
||||
initial: &Value, trial: &'a Trial) -> SmokeResult<Editor<'a>> {
|
||||
fn editor_for<'a, const N: usize>(runtime: &'a AppRuntime, ui: &'a AppWindow, key: &'a SessionKey, uid: &'a str,
|
||||
initial: &Value, fixture: &'static str, fields: [&'static str; N], baseline: [&str; N]) -> SmokeResult<Editor<'a, N>> {
|
||||
// Never substitute an editor default for an unrepresentable wire value.
|
||||
let original = trial.fields.map(|id| initial[id].as_str());
|
||||
if initial["virtualserver_name"] != trial.fixture || original != trial.baseline.map(Some) {
|
||||
return Err(format!("expected disposable fixture {:?} with {:?}; read {original:?}", trial.fixture, trial.baseline));
|
||||
let original = fields.map(|id| initial[id].as_str());
|
||||
if initial["virtualserver_name"] != fixture || original != baseline.map(Some) {
|
||||
return Err(format!("expected disposable fixture {fixture:?} with {baseline:?}; read {original:?}"));
|
||||
}
|
||||
Ok(Editor { runtime, ui, key, uid, trial, bridge: ui.global::<DialogBridge>() })
|
||||
Ok(Editor { runtime, ui, key, uid, fixture, fields, bridge: ui.global::<DialogBridge>() })
|
||||
}
|
||||
|
||||
async fn exercise_fields(runtime: &AppRuntime, ui: &AppWindow, owner: &RuntimeServices,
|
||||
tabs: &[SessionKey; 2], uid: &str, initial: &Value, trial: &Trial) -> SmokeResult<()> {
|
||||
let editor = editor_for(runtime, ui, &tabs[0], uid, initial, trial)?;
|
||||
let editor = editor_for(runtime, ui, &tabs[0], uid, initial, trial.fixture, trial.fields, trial.baseline)?;
|
||||
read_peer(owner, &tabs[1], initial, trial, trial.baseline).await?;
|
||||
|
||||
editor.open().await?;
|
||||
@@ -178,12 +181,7 @@ async fn exercise_fields(runtime: &AppRuntime, ui: &AppWindow, owner: &RuntimeSe
|
||||
}
|
||||
|
||||
async fn read_peer(owner: &RuntimeServices, peer: &SessionKey, initial: &Value, trial: &Trial, expected: [&str; 2]) -> SmokeResult<()> {
|
||||
pace_beta14().await?;
|
||||
let reply = owner.request(peer, Command::Admin(AdminCommand::ServerInfo)).await
|
||||
.map_err(|error| format!("peer server_info: {}", error.message))?;
|
||||
let [row] = reply["rows"].as_array().ok_or("peer server_info lacked properties")?.as_slice() else {
|
||||
return Err("peer server_info returned an unexpected row count".into());
|
||||
};
|
||||
let row = read_peer_row(owner, peer).await?;
|
||||
let actual = trial.fields.map(|id| row[id].as_str());
|
||||
if actual != expected.map(Some) {
|
||||
return Err(format!("peer server_info: expected {expected:?} for {:?}, got {actual:?}", trial.fields));
|
||||
@@ -199,16 +197,27 @@ async fn read_peer(owner: &RuntimeServices, peer: &SessionKey, initial: &Value,
|
||||
Ok(())
|
||||
}
|
||||
|
||||
struct Editor<'a> {
|
||||
async fn read_peer_row(owner: &RuntimeServices, peer: &SessionKey) -> SmokeResult<Value> {
|
||||
pace_beta14().await?;
|
||||
let mut reply = owner.request(peer, Command::Admin(AdminCommand::ServerInfo)).await
|
||||
.map_err(|error| format!("peer server_info: {}", error.message))?;
|
||||
let [row] = reply["rows"].as_array_mut().ok_or("peer server_info lacked properties")?.as_mut_slice() else {
|
||||
return Err("peer server_info returned an unexpected row count".into());
|
||||
};
|
||||
Ok(std::mem::take(row))
|
||||
}
|
||||
|
||||
struct Editor<'a, const N: usize> {
|
||||
runtime: &'a AppRuntime,
|
||||
ui: &'a AppWindow,
|
||||
key: &'a SessionKey,
|
||||
uid: &'a str,
|
||||
trial: &'a Trial,
|
||||
fixture: &'static str,
|
||||
fields: [&'static str; N],
|
||||
bridge: DialogBridge<'a>,
|
||||
}
|
||||
|
||||
impl Editor<'_> {
|
||||
impl<const N: usize> Editor<'_, N> {
|
||||
async fn open(&self) -> SmokeResult<()> {
|
||||
pace_beta14().await?;
|
||||
let label = self.runtime.snapshot().catalog.text(label_key(Operation::ServerEdit));
|
||||
@@ -218,36 +227,40 @@ impl Editor<'_> {
|
||||
shell.invoke_invoke(edit.id);
|
||||
until("editor for the original server and session", || self.bridge.get_visible()
|
||||
&& self.runtime.snapshot().dialog.as_ref().is_some_and(|form| form.operation == Operation::ServerEdit
|
||||
&& form.target.session.as_ref() == Some(self.key) && form.confirmation.as_deref() == Some(self.trial.fixture)
|
||||
&& form.target.session.as_ref() == Some(self.key) && form.confirmation.as_deref() == Some(self.fixture)
|
||||
&& matches!(&form.target.entity, Entity::Server { uid } if uid == self.uid))).await?;
|
||||
self.button(self.bridge.get_advanced_label())
|
||||
}
|
||||
|
||||
async fn expect_fields(&self, expected: [&str; 2]) -> SmokeResult<()> {
|
||||
for (id, value) in self.trial.fields.into_iter().zip(expected) {
|
||||
let label = self.field_label(id)?;
|
||||
let item = self.input(&label).await?;
|
||||
let input = item.downcast::<TextInput>().ok_or("missing numeric text input")?;
|
||||
let actual = input.as_pin_ref().text();
|
||||
if actual != value { return Err(format!("reopened {id}: expected {value}, got {actual}")); }
|
||||
async fn expect_fields(&self, expected: [&str; N]) -> SmokeResult<()> {
|
||||
for (id, value) in self.fields.into_iter().zip(expected) {
|
||||
self.expect_field(id, value).await?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn set_fields(&self, values: [&str; 2]) -> SmokeResult<()> {
|
||||
for (id, value) in self.trial.fields.into_iter().zip(values) { self.type_input(&self.field_label(id)?, value).await?; }
|
||||
async fn expect_field(&self, id: &str, expected: &str) -> SmokeResult<()> {
|
||||
let item = self.input(&self.field_label(id)?).await?;
|
||||
let input = item.downcast::<TextInput>().ok_or("missing server text input")?;
|
||||
let actual = input.as_pin_ref().text();
|
||||
if actual != expected { return Err(format!("reopened {id}: expected {expected}, got {actual}")); }
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn change_fields(&self, before: [&str; 2], after: [&str; 2]) -> SmokeResult<()> {
|
||||
for ((id, old), new) in self.trial.fields.into_iter().zip(before).zip(after) {
|
||||
async fn set_fields(&self, values: [&str; N]) -> SmokeResult<()> {
|
||||
for (id, value) in self.fields.into_iter().zip(values) { self.type_input(&self.field_label(id)?, value).await?; }
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn change_fields(&self, before: [&str; N], after: [&str; N]) -> SmokeResult<()> {
|
||||
for ((id, old), new) in self.fields.into_iter().zip(before).zip(after) {
|
||||
if old != new { self.type_input(&self.field_label(id)?, new).await?; }
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn confirm(&self) -> SmokeResult<()> {
|
||||
self.type_input(self.bridge.get_confirmation_label().as_str(), self.trial.fixture).await
|
||||
self.type_input(self.bridge.get_confirmation_label().as_str(), self.fixture).await
|
||||
}
|
||||
|
||||
async fn save(&self) -> SmokeResult<()> {
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
use super::{AppRuntime, AppWindow, ParticipantFixture, RuntimeServices, SessionKey, SmokeResult, Value,
|
||||
TEXT_FIELDS, editor_for, headless, read_peer_row, run_muted_beta14_participant_fixture};
|
||||
use slint::Model;
|
||||
|
||||
const FIXTURE: &str = "TeamsPeach Host Banner QA Fixture";
|
||||
const FIELDS: [&str; 4] = ["virtualserver_hostbanner_url", "virtualserver_hostbanner_gfx_url",
|
||||
"virtualserver_hostbanner_gfx_interval", "virtualserver_hostbanner_mode"];
|
||||
const BASELINE: [&str; 4] = ["https://banner.invalid/base", "https://banner.invalid/base.png", "120", "0"];
|
||||
const SINGLE: [&str; 4] = ["https://banner.invalid/single", "https://banner.invalid/single.png", "180", "1"];
|
||||
const PAIRED: [&str; 4] = ["https://banner.invalid/pair", "https://banner.invalid/pair.png", "240", "2"];
|
||||
|
||||
#[test]
|
||||
#[ignore = "requires exclusive loopback beta14 from native/tests/fixtures/beta14-server-admin.ps1"]
|
||||
fn server_host_banner_roundtrip_on_beta14() {
|
||||
if !headless::in_test_process() { return; }
|
||||
// Six saves each need a paced acknowledgement, peer query, and fresh editor query.
|
||||
headless::install_with_deadline(std::time::Duration::from_secs(180)).unwrap();
|
||||
run_muted_beta14_participant_fixture(ParticipantFixture::HostBanner);
|
||||
}
|
||||
|
||||
pub(in crate::smoke::tabs) async fn exercise(runtime: &AppRuntime, ui: &AppWindow, owner: &RuntimeServices,
|
||||
tabs: &[SessionKey; 2], uid: &str, initial: &Value) -> SmokeResult<()> {
|
||||
let editor = editor_for(runtime, ui, &tabs[0], uid, initial, FIXTURE, FIELDS, BASELINE)?;
|
||||
let peer = &tabs[1];
|
||||
editor.open().await?;
|
||||
editor.expect_fields(BASELINE).await?;
|
||||
editor.confirm().await?;
|
||||
|
||||
let too_long = format!("https://banner.invalid/{}", "x".repeat(1025 - "https://banner.invalid/".len()));
|
||||
let invalid: [&[&str]; 4] = [&[&too_long], &[&too_long], &["-1", "4294967296", "1.5"], &["-1", "3"]];
|
||||
for (index, (id, bad)) in FIELDS.into_iter().zip(invalid).enumerate() {
|
||||
let label = editor.field_label(id)?;
|
||||
for &value in bad {
|
||||
editor.type_input(&label, value).await?;
|
||||
editor.submit()?;
|
||||
let fields = editor.bridge.get_fields();
|
||||
if !editor.bridge.get_visible() || editor.bridge.get_busy()
|
||||
|| !FIELDS.into_iter().zip(BASELINE).enumerate().all(|(i, (field, baseline))| {
|
||||
fields.iter().any(|row| row.id == field && if i == index { row.value == value && !row.error.is_empty() }
|
||||
else { row.value == baseline && row.error.is_empty() })
|
||||
}) {
|
||||
return Err(format!("invalid {id} ({} bytes) did not stay isolated to its field", value.len()));
|
||||
}
|
||||
}
|
||||
editor.type_input(&label, BASELINE[index]).await?;
|
||||
}
|
||||
editor.set_fields(PAIRED).await?;
|
||||
let confirmation = editor.bridge.get_confirmation_label();
|
||||
editor.type_input(confirmation.as_str(), "Wrong fixture name").await?;
|
||||
editor.submit()?;
|
||||
if !editor.bridge.get_visible() || editor.bridge.get_busy() || editor.bridge.get_error().is_empty() {
|
||||
return Err("wrong banner confirmation did not keep the draft with an error".into());
|
||||
}
|
||||
editor.expect_fields(PAIRED).await?;
|
||||
editor.cancel()?;
|
||||
editor.closed().await?;
|
||||
verify_peer(owner, peer, initial, "cancelled", BASELINE).await?;
|
||||
editor.open().await?;
|
||||
editor.expect_fields(BASELINE).await?;
|
||||
|
||||
let mut previous = BASELINE;
|
||||
let changes = FIELDS.into_iter().zip(SINGLE).enumerate().scan(BASELINE, |values, (i, (id, value))| {
|
||||
values[i] = value;
|
||||
Some((id, *values, Some(value)))
|
||||
}).chain([("combined", PAIRED, None), ("restored", BASELINE, None)]);
|
||||
for (stage, next, single) in changes {
|
||||
editor.change_fields(previous, next).await?;
|
||||
editor.save().await?;
|
||||
let peer_read = verify_peer(owner, peer, initial, stage, next).await;
|
||||
editor.open().await?;
|
||||
let reopened = match single {
|
||||
Some(value) => editor.expect_field(stage, value).await,
|
||||
None => editor.expect_fields(next).await,
|
||||
};
|
||||
let readback = peer_read.and(reopened);
|
||||
if readback.is_err() && next != BASELINE {
|
||||
editor.set_fields(BASELINE).await?;
|
||||
editor.save().await?;
|
||||
verify_peer(owner, peer, initial, "restored after mismatch", BASELINE).await?;
|
||||
}
|
||||
readback?;
|
||||
previous = next;
|
||||
}
|
||||
editor.cancel()?;
|
||||
editor.closed().await
|
||||
}
|
||||
|
||||
async fn verify_peer(owner: &RuntimeServices, peer: &SessionKey, initial: &Value, stage: &str, expected: [&str; 4]) -> SmokeResult<()> {
|
||||
let row = read_peer_row(owner, peer).await?;
|
||||
let actual = FIELDS.map(|id| row[id].as_str());
|
||||
if actual != expected.map(Some) { return Err(format!("{stage} peer banner: expected {expected:?}; read {actual:?}")); }
|
||||
if let Some(id) = TEXT_FIELDS.into_iter().chain(["virtualserver_maxclients", "virtualserver_reserved_slots", "virtualserver_weblist_enabled"])
|
||||
.find(|id| row[*id] != initial[*id]) {
|
||||
return Err(format!("{stage} banner edit also changed {id}"));
|
||||
}
|
||||
println!("peer server_info banner ({stage}): {expected:?}");
|
||||
Ok(())
|
||||
}
|
||||
@@ -1165,7 +1165,7 @@ fn participant_context_menu_projects_muted_beta14_capabilities() {
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
#[derive(Clone, Copy, PartialEq)]
|
||||
enum ParticipantFixture { Info, Statistics, Poke, Context, Volume, Commander, Move, ServerInfo, ServerText, WelcomeOnly, ServerCapacity, ServerQuota, ServerBandwidth, ServerLog, VirtualLog, ServerPermissions, GroupLifecycle(teamspeach_core::admin::extra::GroupKind), ChannelSubscriptions, ChannelEditReplacement, VoiceToolbar }
|
||||
enum ParticipantFixture { Info, Statistics, Poke, Context, Volume, Commander, Move, ServerInfo, ServerText, WelcomeOnly, ServerCapacity, ServerQuota, ServerBandwidth, HostBanner, ServerLog, VirtualLog, ServerPermissions, GroupLifecycle(teamspeach_core::admin::extra::GroupKind), ChannelSubscriptions, ChannelEditReplacement, VoiceToolbar }
|
||||
|
||||
#[cfg(target_os="windows")]
|
||||
#[test]
|
||||
@@ -1319,7 +1319,7 @@ fn run_muted_beta14_participant_fixture(scenario: ParticipantFixture) {
|
||||
match scenario {
|
||||
ParticipantFixture::VoiceToolbar => return exercise_voice_toolbar(runtime,ui,&owner,&tabs,clients,&uids).await,
|
||||
ParticipantFixture::ServerInfo | ParticipantFixture::ServerText | ParticipantFixture::WelcomeOnly => return exercise_server_info(runtime,ui,&owner,&tabs,scenario).await,
|
||||
ParticipantFixture::ServerCapacity | ParticipantFixture::ServerQuota | ParticipantFixture::ServerBandwidth => return exercise_server_info(runtime,ui,&owner,&tabs,scenario).await,
|
||||
ParticipantFixture::ServerCapacity | ParticipantFixture::ServerQuota | ParticipantFixture::ServerBandwidth | ParticipantFixture::HostBanner => return exercise_server_info(runtime,ui,&owner,&tabs,scenario).await,
|
||||
ParticipantFixture::ServerLog => return server_log::exercise(runtime, ui, &owner, &tabs).await,
|
||||
ParticipantFixture::VirtualLog => return server_log::permitted(runtime, ui, &owner, &tabs[0]).await,
|
||||
ParticipantFixture::ServerPermissions => return server_permissions::exercise(runtime, ui, &owner, &tabs, None).await,
|
||||
@@ -1481,6 +1481,9 @@ async fn exercise_server_info(runtime:&AppRuntime,ui:&AppWindow,owner:&crate::ap
|
||||
// The bandwidth workflow already reads the same server from the other guest.
|
||||
return server_capacity::exercise_bandwidth(runtime, ui, owner, tabs, uid, row).await;
|
||||
}
|
||||
if scenario == ParticipantFixture::HostBanner {
|
||||
return server_capacity::host_banner::exercise(runtime, ui, owner, tabs, uid, row).await;
|
||||
}
|
||||
if scenario==ParticipantFixture::WelcomeOnly && view==0 {
|
||||
let dialog=ui.global::<crate::DialogBridge>();
|
||||
let label=catalog.text(crate::ui::shell::forms::label_key(Operation::ServerEdit));
|
||||
|
||||
+20
@@ -14,6 +14,10 @@ switch -CaseSensitive ($testName) {
|
||||
$fixtureName = 'TeamsPeach Channel Edit QA Fixture'
|
||||
$permission = 'b_channel_modify_topic'
|
||||
}
|
||||
'smoke::tabs::server_capacity::host_banner::server_host_banner_roundtrip_on_beta14' {
|
||||
$fixtureName = 'TeamsPeach Host Banner QA Fixture'
|
||||
$permission = 'b_virtualserver_modify_hostbanner'
|
||||
}
|
||||
default { throw 'Specify one exact supported beta14 test.' }
|
||||
}
|
||||
$release = $env:TEAMSPEACH_BETA14_RELEASE
|
||||
@@ -166,6 +170,22 @@ try {
|
||||
if ([string]$info[0].$field -cne $seed[$field]) { throw "WebQuery did not confirm the finite baseline for $field." }
|
||||
}
|
||||
Write-Output 'Bootstrap serverinfo bandwidth (bytes/s): download=1048576 upload=2097152; public listing off.'
|
||||
} elseif ($permission -eq 'b_virtualserver_modify_hostbanner') {
|
||||
$seed = [ordered]@{
|
||||
virtualserver_hostbanner_url='https://banner.invalid/base'
|
||||
virtualserver_hostbanner_gfx_url='https://banner.invalid/base.png'
|
||||
virtualserver_hostbanner_gfx_interval='120'
|
||||
virtualserver_hostbanner_mode='0'
|
||||
}
|
||||
foreach ($field in $seed.Keys) {
|
||||
try { [void](Invoke-Query $client "$id/serveredit" @{$field=$seed[$field]}) }
|
||||
catch { throw "Could not seed '$field': $($_.Exception.Message)" }
|
||||
}
|
||||
$info = @(Invoke-Query $client "$id/serverinfo")
|
||||
foreach ($field in $seed.Keys) {
|
||||
if ([string]$info[0].$field -cne $seed[$field]) { throw "WebQuery did not confirm the banner baseline for $field." }
|
||||
}
|
||||
Write-Output 'Bootstrap serverinfo confirmed both .invalid URLs, interval 120, mode 0; public listing off.'
|
||||
} else {
|
||||
$room = @(Invoke-Query $client "$id/channelcreate" @{
|
||||
channel_name='Channel Edit Receipt QA'; channel_topic='Fixture seed'; channel_flag_permanent=1
|
||||
|
||||
Reference in new issue
Block a user