mirror of
https://github.com/Darkatse/TauriTavern.git
synced 2026-10-19 15:45:12 +00:00
perf(test): remove two avoidable waits from the check suite
happy-dom's Element.toString() serializes outerHTML, and Popper stringifies nodes while the app loads, so each browser runtime spent most of its startup serializing the document. The LAN pairing test's stale address was a bound socket that macOS leaves unanswered until the 2 s probe timeout; a listener that closes every connection fails at once on every platform.
This commit is contained in:
parent
2eecdefe51
commit
304d6d3cfe
4 changed files with 7 additions and 13 deletions
1
src-tauri/Cargo.lock
generated
1
src-tauri/Cargo.lock
generated
|
|
@ -9433,7 +9433,6 @@ dependencies = [
|
|||
"rustls",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"socket2",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"tt-contracts",
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ mdns-sd = "0.21.3"
|
|||
|
||||
[dev-dependencies]
|
||||
base64 = "0.23"
|
||||
socket2 = { version = "0.6", features = ["all"] }
|
||||
|
||||
[target.'cfg(target_os = "macos")'.dev-dependencies]
|
||||
mdns-sd = "0.21.3"
|
||||
|
|
|
|||
|
|
@ -397,7 +397,6 @@ mod tests {
|
|||
use async_trait::async_trait;
|
||||
use base64::Engine;
|
||||
use base64::engine::general_purpose::URL_SAFE_NO_PAD;
|
||||
use socket2::{Domain, Protocol, Socket, Type};
|
||||
use tokio::sync::{Mutex, mpsc};
|
||||
use tt_contracts::lan_discovery::LanDiscoveryAnnouncement;
|
||||
use tt_ports::lan_sync::LanPairingClient;
|
||||
|
|
@ -700,17 +699,12 @@ mod tests {
|
|||
completions: Mutex::new(completions),
|
||||
});
|
||||
let events = recording_events();
|
||||
// Reserve a non-listening port so the stale candidate fails without a timing race.
|
||||
let unavailable = Socket::new(Domain::IPV4, Type::STREAM, Some(Protocol::TCP))
|
||||
.expect("reserve stale address");
|
||||
unavailable
|
||||
.bind(&"127.0.0.1:0".parse::<SocketAddr>().unwrap().into())
|
||||
// The stale candidate must fail at once while keeping its port reserved.
|
||||
let stale = tokio::net::TcpListener::bind("127.0.0.1:0")
|
||||
.await
|
||||
.expect("bind stale address");
|
||||
let stale_address = unavailable
|
||||
.local_addr()
|
||||
.expect("stale address")
|
||||
.as_socket()
|
||||
.unwrap();
|
||||
let stale_address = stale.local_addr().expect("stale address");
|
||||
tokio::spawn(async move { while stale.accept().await.is_ok() {} });
|
||||
let handle = spawn_lan_sync_server(
|
||||
"127.0.0.1:0".parse().unwrap(),
|
||||
default_user_dir.clone(),
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@ export function createBrowserRuntime() {
|
|||
return nodeName.get.call(this);
|
||||
},
|
||||
});
|
||||
// Elements must stringify as in browsers, or Popper serializes the document during startup.
|
||||
delete window.Element.prototype.toString;
|
||||
window.document.write(readFileSync(path.join(root, 'index.html'), 'utf8')
|
||||
.replace(/<script\b[^>]*>[\s\S]*?<\/script>/g, ''));
|
||||
for (const file of ['jquery-3.5.1.min.js', 'jquery-ui.min.js', 'jquery.transit.min.js',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue