BlueGit

ict rusty-teams

Files

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

live_chrome.rs

chore: cargo fmt the workspace
metis Daniel Däschle · pushed by metis · 2 weeks ago
a6592765 History
live_chrome.rs 1.5 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()
12 .unwrap()
13 .with_port(TEST_PORT)
14 .with_profile_name(&profile_name);
15 let mode_file = config.mode_file.clone();
16 let profile_directory = mode_file.with_extension("");
17 let browser = Browser::new(config);
18 assert!(!browser.is_running().await, "port {TEST_PORT} is in use");
19
20 let outcome = async {
21 browser.ensure_running().await.unwrap();
22 let status = browser.status().await.unwrap();
23 assert!(status.running);
24 assert_eq!(status.mode, Mode::Headless);
25 assert_eq!(status.tabs.len(), 2);
26 tokio::time::sleep(Duration::from_secs(5)).await;
27 let status = browser.status().await.unwrap();
28 println!("login state after load: {:?}", status.login_state);
29 assert_ne!(status.login_state, LoginState::Unknown);
30 browser.stop().await.unwrap();
31 assert!(!browser.is_running().await);
32 }
33 .await;
34
35 let _ = browser.stop().await;
36 tokio::time::sleep(Duration::from_secs(2)).await;
37 let _ = std::fs::remove_dir_all(&profile_directory);
38 let _ = std::fs::remove_file(&mode_file);
39 outcome
40}