use hemx_axum::runtime_js_path; use hemx_test::{inspect_wire, EffectInspector}; use hemx_workout_example::ui::BUILD_FINGERPRINT; use std::io::{Read, Write}; use std::net::{TcpListener, TcpStream}; use std::process::{Child, Command, Stdio}; use std::time::{Duration, Instant}; struct Server { child: Child, addr: String, } impl Server { fn start() -> Self { let listener = TcpListener::bind("127.0.0.1:0").expect("reserve test port"); let addr = listener.local_addr().unwrap().to_string(); drop(listener); let bin = env!("CARGO_BIN_EXE_hemx-workout-example"); let child = Command::new(bin) .env("HEMX_WORKOUT_ADDR", &addr) .stdout(Stdio::null()) .stderr(Stdio::null()) .spawn() .expect("start hemx-workout-example"); let deadline = Instant::now() + Duration::from_secs(5); while Instant::now() < deadline { if TcpStream::connect(&addr).is_ok() { return Self { child, addr }; } std::thread::sleep(Duration::from_millis(25)); } panic!("hemx-workout-example did not listen on {addr}"); } } impl Drop for Server { fn drop(&mut self) { let _ = self.child.kill(); let _ = self.child.wait(); } } #[test] fn workout_is_e2e_working_over_http() { // req: examples/001 req: local/001 req: local/003 req: local/004 req: host/001 let server = Server::start(); let home = get(&server, "/"); assert_eq!(home.status, 200); assert!(home.header("content-type").contains("text/html")); assert!(home.text().contains("Now-first Workout Copilot")); assert!(home.text().contains("Private event log")); assert!(home.text().contains("Replay export")); assert!(home .text() .contains(&format!("