//! KVT-fork: the extra sign-in tab (`kvt_open_tab`) on a real Chrome. use std::time::Duration; use browser::{Browser, Config}; const TEST_PORT: u16 = 9445; #[tokio::test] #[ignore = "starts a real Chrome on port 9445 with a throwaway profile"] async fn kvt_tab_opens_the_exact_url_evaluates_and_closes() { let profile_name = format!("rusty-teams-kvt-test-{}", std::process::id()); let config = Config::detect() .unwrap() .with_port(TEST_PORT) .with_profile_name(&profile_name); let mode_file = config.mode_file.clone(); let profile_directory = mode_file.with_extension(""); let browser = Browser::new(config); assert!(!browser.is_running().await, "port {TEST_PORT} is in use"); let outcome = async { browser.ensure_running().await.unwrap(); let url = "data:text/html,

ok

#a=1&b=%20c"; let tab = browser.kvt_open_tab(url).await.unwrap(); tokio::time::sleep(Duration::from_secs(1)).await; let href = browser.kvt_evaluate(&tab, "window.kvt").await.unwrap(); assert_eq!(href.as_str(), Some(url)); let tabs_before = browser.tabs().await.unwrap().len(); browser.kvt_close_tab(&tab).await.unwrap(); tokio::time::sleep(Duration::from_millis(500)).await; assert_eq!(browser.tabs().await.unwrap().len(), tabs_before - 1); browser.stop().await.unwrap(); } .await; let _ = browser.stop().await; tokio::time::sleep(Duration::from_secs(2)).await; let _ = std::fs::remove_dir_all(&profile_directory); let _ = std::fs::remove_file(&mode_file); outcome }