BlueGit

ict rusty-teams

Files

rusty-teams / crates / browser / tests / live_chrome.rs

live_chrome.rs

Initial commit
metis Daniel Däschle · pushed by metis · 7 weeks ago
06e0ae51 History
live_chrome.rs 1.4 KiB Download Raw
1use std::time::Duration;
2
3use browser::{Browser, Config, LoginState, Mode};
4
5const TEST_PORT: u16 = 9444;
6
7#[tokio::test]
8#[ignore = "starts a real Chrome on port 9444 with a throwaway profile"]
9async fn start_status_stop_on_a_separate_port_and_profile() {
10 let profile_name = format!("rusty-teams-chrome-test-{}", std::process::id());
11 let config = Config::detect().unwrap().with_port(TEST_PORT).with_profile_name(&profile_name);
12 let mode_file = config.mode_file.clone();
13 let profile_directory = mode_file.with_extension("");
14 let browser = Browser::new(config);
15 assert!(!browser.is_running().await, "port {TEST_PORT} is in use");
16
17 let outcome = async {
18 browser.ensure_running().await.unwrap();
19 let status = browser.status().await.unwrap();
20 assert!(status.running);
21 assert_eq!(status.mode, Mode::Headless);
22 assert_eq!(status.tabs.len(), 2);
23 tokio::time::sleep(Duration::from_secs(5)).await;
24 let status = browser.status().await.unwrap();
25 println!("login state after load: {:?}", status.login_state);
26 assert_ne!(status.login_state, LoginState::Unknown);
27 browser.stop().await.unwrap();
28 assert!(!browser.is_running().await);
29 }
30 .await;
31
32 let _ = browser.stop().await;
33 tokio::time::sleep(Duration::from_secs(2)).await;
34 let _ = std::fs::remove_dir_all(&profile_directory);
35 let _ = std::fs::remove_file(&mode_file);
36 outcome
37}