use std::time::Duration; use crate::common::boot_forge; use reqwest::header::ACCEPT_LANGUAGE; #[tokio::test] async fn snippets_page_follows_the_browser_language() { let root = tempfile::tempdir().expect("temp dir"); let dir = root.path().to_path_buf(); let (_server, ports) = boot_forge(&dir, "", &[&["create-user", "tahinli"]]).await; let client = reqwest::Client::builder() .timeout(Duration::from_secs(60)) .build() .expect("http client"); let base = format!("http://127.0.0.1:{}", ports.http); let turkish = client .get(format!("{base}/snippets")) .header(ACCEPT_LANGUAGE, "tr-TR,tr;q=0.9,en;q=0.8") .send() .await .expect("GET /snippets (tr)"); assert_eq!(turkish.status().as_u16(), 200); let body = turkish.text().await.expect("read body"); assert!(body.contains("Parçacıklar"), "Turkish heading"); assert!( body.contains("Gösterilecek parçacık yok."), "Turkish empty state" ); assert!(!body.contains("No snippets to show."), "no English left"); let english = client .get(format!("{base}/snippets")) .header(ACCEPT_LANGUAGE, "en-US,en;q=0.9") .send() .await .expect("GET /snippets (en)"); let body = english.text().await.expect("read body"); assert!(body.contains("

Snippets

"), "English heading"); assert!(body.contains("No snippets to show."), "English empty state"); }