🔥 remove: redundant web-account and web-repo tests
Browse files at this commitff1c91325d63db366f4cb12bca48766a057ee9a0Parent: 52ac08d10 changed files +0 -308
- crates/forge-web-account/src/pages/banner.rs +0 -9
- crates/forge-web-account/src/pages/explore.rs +0 -31
- crates/forge-web-account/src/pages/new_repo.rs +0 -24
- crates/forge-web-account/src/pages/org_ctx.rs +0 -15
- crates/forge-web-account/src/pages/palette.rs +0 -40
- crates/forge-web-account/src/pages/settings_appearance.rs +0 -116
- crates/forge-web-account/src/pages/settings_sessions.rs +0 -14
- crates/forge-web-repo/src/pages/ci_badge.rs +0 -31
- crates/forge-web-repo/src/pages/commits.rs +0 -17
- crates/forge-web-repo/src/pages/pulls_list.rs +0 -11
crates/forge-web-account/src/pages/banner.rsmodified+0 -9
| @@ -57,15 +57,6 @@ mod tests { | ||
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - #[test] | |
| 61 | - fn empty_and_expired_banners_are_hidden() { | |
| 62 | - assert!(view_for(&config("", BannerLevel::Info, ""), 0, None).is_none()); | |
| 63 | - let expiry = forge_core::config::parse_banner_expiry("2026-12-31 18:00").unwrap(); | |
| 64 | - let cfg = config("maintenance", BannerLevel::Warning, "2026-12-31 18:00"); | |
| 65 | - assert!(view_for(&cfg, expiry - 1, None).is_some()); | |
| 66 | - assert!(view_for(&cfg, expiry, None).is_none()); | |
| 67 | - } | |
| 68 | - | |
| 69 | 60 | #[test] |
| 70 | 61 | fn a_dismissed_hash_hides_only_that_message() { |
| 71 | 62 | let cfg = config("maintenance tonight", BannerLevel::Info, ""); |
crates/forge-web-account/src/pages/explore.rsmodified+0 -31
| @@ -325,34 +325,3 @@ async fn explore_body( | ||
| 325 | 325 | </div> |
| 326 | 326 | }) |
| 327 | 327 | } |
| 328 | - | |
| 329 | -#[cfg(test)] | |
| 330 | -mod tests { | |
| 331 | - use topcoat::router::request::Request; | |
| 332 | - use topcoat::router::{Body, Router, to_bytes}; | |
| 333 | - | |
| 334 | - async fn get_with_language(router: &Router, uri: &str, language: &str) -> String { | |
| 335 | - let request = Request::builder() | |
| 336 | - .method("GET") | |
| 337 | - .uri(uri) | |
| 338 | - .header("accept-language", language) | |
| 339 | - .body(Body::empty()) | |
| 340 | - .unwrap(); | |
| 341 | - let res = router.handle(request).await; | |
| 342 | - let bytes = to_bytes(res.into_body(), usize::MAX).await.unwrap(); | |
| 343 | - String::from_utf8_lossy(&bytes).into_owned() | |
| 344 | - } | |
| 345 | - | |
| 346 | - #[tokio::test] | |
| 347 | - async fn turkish_viewer_gets_the_turkish_explore_page() { | |
| 348 | - let dir = tempfile::tempdir().expect("tempdir"); | |
| 349 | - let path = dir.path().to_path_buf(); | |
| 350 | - let state = crate::test_support::test_state(&path).await; | |
| 351 | - let router = crate::test_support::app_router(state); | |
| 352 | - | |
| 353 | - let body = get_with_language(&router, "/explore", "tr").await; | |
| 354 | - assert!(body.contains("Keşfet"), "heading in Turkish: {body}"); | |
| 355 | - assert!(body.contains("Herkese açık depolarda ara")); | |
| 356 | - assert!(!body.contains("Public repositories on this forge.")); | |
| 357 | - } | |
| 358 | -} |
crates/forge-web-account/src/pages/new_repo.rsmodified+0 -24
| @@ -577,7 +577,6 @@ mod tests { | ||
| 577 | 577 | struct Site { |
| 578 | 578 | store: Store, |
| 579 | 579 | router: Router, |
| 580 | - tahinli_id: String, | |
| 581 | 580 | data_dir: std::path::PathBuf, |
| 582 | 581 | _dir: tempfile::TempDir, |
| 583 | 582 | } |
| @@ -596,7 +595,6 @@ mod tests { | ||
| 596 | 595 | Site { |
| 597 | 596 | store, |
| 598 | 597 | router, |
| 599 | - tahinli_id: tahinli.id, | |
| 600 | 598 | data_dir, |
| 601 | 599 | _dir: dir, |
| 602 | 600 | } |
| @@ -755,26 +753,4 @@ mod tests { | ||
| 755 | 753 | assert!(license.contains("Copyright (c) "), "{license}"); |
| 756 | 754 | assert!(!license.contains("<year>"), "{license}"); |
| 757 | 755 | } |
| 758 | - | |
| 759 | - #[tokio::test] | |
| 760 | - async fn the_form_is_in_turkish_for_a_turkish_viewer() { | |
| 761 | - let site = site().await; | |
| 762 | - site.store | |
| 763 | - .set_ui_prefs(&site.tahinli_id, "auto", "tr") | |
| 764 | - .await | |
| 765 | - .expect("prefs"); | |
| 766 | - let req = Request::builder() | |
| 767 | - .method("GET") | |
| 768 | - .uri("/new") | |
| 769 | - .header("cookie", format!("__Host-{SESSION_COOKIE}=tahinli-token")) | |
| 770 | - .body(Body::empty()) | |
| 771 | - .expect("request"); | |
| 772 | - let res = site.router.handle(req).await; | |
| 773 | - let status = res.status().as_u16(); | |
| 774 | - let body = to_bytes(res.into_body(), usize::MAX).await.expect("body"); | |
| 775 | - let text = String::from_utf8_lossy(&body).into_owned(); | |
| 776 | - assert_eq!(status, 200, "{text}"); | |
| 777 | - assert!(text.contains("Yeni depo"), "{text}"); | |
| 778 | - assert!(text.contains("Depo oluştur"), "{text}"); | |
| 779 | - } | |
| 780 | 756 | } |
crates/forge-web-account/src/pages/org_ctx.rsmodified+0 -15
| @@ -202,18 +202,3 @@ pub async fn org_notice(cx: &Cx, notice: Option<(&'static str, bool)>) -> Result | ||
| 202 | 202 | } |
| 203 | 203 | }) |
| 204 | 204 | } |
| 205 | - | |
| 206 | -#[cfg(test)] | |
| 207 | -mod tests { | |
| 208 | - use super::*; | |
| 209 | - | |
| 210 | - #[test] | |
| 211 | - fn every_notice_word_is_unique() { | |
| 212 | - for (i, (word, _, _)) in NOTICES.iter().enumerate() { | |
| 213 | - assert!( | |
| 214 | - !NOTICES[i + 1..].iter().any(|(other, _, _)| other == word), | |
| 215 | - "{word} is listed twice" | |
| 216 | - ); | |
| 217 | - } | |
| 218 | - } | |
| 219 | -} |
crates/forge-web-account/src/pages/palette.rsmodified+0 -40
| @@ -465,8 +465,6 @@ mod tests { | ||
| 465 | 465 | use topcoat::router::{Body, to_bytes}; |
| 466 | 466 | |
| 467 | 467 | use crate::auth::SESSION_COOKIE; |
| 468 | - use crate::i18n::Lang; | |
| 469 | - use crate::views::profile_items; | |
| 470 | 468 | |
| 471 | 469 | #[tokio::test] |
| 472 | 470 | async fn admin_destinations_reach_admins_only() { |
| @@ -505,42 +503,4 @@ mod tests { | ||
| 505 | 503 | assert_eq!(hrefs.iter().any(|href| href.contains("#srv-")), is_admin); |
| 506 | 504 | } |
| 507 | 505 | } |
| 508 | - | |
| 509 | - #[tokio::test] | |
| 510 | - async fn palette_lists_every_profile_tab() { | |
| 511 | - let dir = tempfile::tempdir().expect("tempdir"); | |
| 512 | - let state = crate::test_support::test_state(dir.path()).await; | |
| 513 | - let store = state.store.clone(); | |
| 514 | - let router = crate::test_support::app_router(state); | |
| 515 | - let tahinli = store | |
| 516 | - .create_user("tahinli", None, "not-a-real-hash", false) | |
| 517 | - .await | |
| 518 | - .unwrap(); | |
| 519 | - crate::test_support::create_session(&store, &tahinli.id, "palette-token", "palette-csrf") | |
| 520 | - .await; | |
| 521 | - let request = Request::builder() | |
| 522 | - .method("GET") | |
| 523 | - .uri("/-/palette") | |
| 524 | - .header("cookie", format!("__Host-{SESSION_COOKIE}=palette-token")) | |
| 525 | - .body(Body::empty()) | |
| 526 | - .unwrap(); | |
| 527 | - let res = router.handle(request).await; | |
| 528 | - let bytes = to_bytes(res.into_body(), usize::MAX).await.unwrap(); | |
| 529 | - let body: serde_json::Value = serde_json::from_slice(&bytes).unwrap(); | |
| 530 | - let hrefs: Vec<&str> = body["items"] | |
| 531 | - .as_array() | |
| 532 | - .unwrap() | |
| 533 | - .iter() | |
| 534 | - .map(|item| item["href"].as_str().unwrap()) | |
| 535 | - .collect(); | |
| 536 | - let tabs = profile_items(Lang::En, "tahinli", false, true, false); | |
| 537 | - assert!(!tabs.is_empty()); | |
| 538 | - for tab in tabs { | |
| 539 | - assert!( | |
| 540 | - hrefs.contains(&tab.href.as_str()), | |
| 541 | - "palette lacks {}", | |
| 542 | - tab.href | |
| 543 | - ); | |
| 544 | - } | |
| 545 | - } | |
| 546 | 506 | } |
crates/forge-web-account/src/pages/settings_appearance.rsmodified+0 -116
| @@ -670,122 +670,6 @@ mod tests { | ||
| 670 | 670 | ); |
| 671 | 671 | } |
| 672 | 672 | |
| 673 | - #[test] | |
| 674 | - fn a_rejected_colour_says_what_to_choose() { | |
| 675 | - let accent_err = accent_choice(Lang::En, Some("neon"), "sage").unwrap_err(); | |
| 676 | - assert!( | |
| 677 | - accent_err.to_string().contains("accent colour"), | |
| 678 | - "{accent_err}" | |
| 679 | - ); | |
| 680 | - let base_err = base_choice(Lang::En, Some("neon"), "blush").unwrap_err(); | |
| 681 | - assert!(base_err.to_string().contains("background"), "{base_err}"); | |
| 682 | - } | |
| 683 | - | |
| 684 | - #[test] | |
| 685 | - fn stored_colours_are_selected_and_hues_drive_the_stripes() { | |
| 686 | - let options = choices(THEMES, "dark", |code| theme_label(Lang::En, code)); | |
| 687 | - let selected: Vec<&str> = options | |
| 688 | - .iter() | |
| 689 | - .filter(|c| c.selected) | |
| 690 | - .map(|c| c.value) | |
| 691 | - .collect(); | |
| 692 | - assert_eq!(selected, ["dark"], "theme: selected"); | |
| 693 | - | |
| 694 | - let codes: Vec<&'static str> = accent::ids().collect(); | |
| 695 | - let options = choices(&codes, "plum", |id| accent_name(Lang::En, id)); | |
| 696 | - let selected: Vec<&str> = options | |
| 697 | - .iter() | |
| 698 | - .filter(|c| c.selected) | |
| 699 | - .map(|c| c.value) | |
| 700 | - .collect(); | |
| 701 | - assert_eq!(selected, ["plum"], "accent: selected"); | |
| 702 | - assert_eq!( | |
| 703 | - options[0].value, | |
| 704 | - forge_web_app::accent_palette::DEFAULT, | |
| 705 | - "accent: default first" | |
| 706 | - ); | |
| 707 | - | |
| 708 | - let [base_row, _] = colour_group(Lang::En, true, "ink", "plum"); | |
| 709 | - let bases: Vec<&str> = base_row | |
| 710 | - .choices | |
| 711 | - .iter() | |
| 712 | - .filter(|c| c.selected) | |
| 713 | - .map(|c| c.value) | |
| 714 | - .collect(); | |
| 715 | - assert_eq!(bases, ["ink"], "base: selected"); | |
| 716 | - assert_eq!( | |
| 717 | - base_row.choices[0].value, | |
| 718 | - forge_web_app::accent_palette::BASE_DEFAULT, | |
| 719 | - "base: default first" | |
| 720 | - ); | |
| 721 | - | |
| 722 | - let [base_row, accent_row] = colour_group(Lang::En, false, "hue-200", "hue-40"); | |
| 723 | - assert!(base_row.stripe.custom, "custom base hue"); | |
| 724 | - assert_eq!(base_row.stripe.hue, 200, "custom base hue value"); | |
| 725 | - assert!(accent_row.stripe.custom, "custom accent hue"); | |
| 726 | - assert_eq!(accent_row.stripe.hue, 40, "custom accent hue value"); | |
| 727 | - assert!( | |
| 728 | - base_row.choices.iter().all(|c| !c.selected), | |
| 729 | - "custom hue: no base preset checked" | |
| 730 | - ); | |
| 731 | - assert!( | |
| 732 | - accent_row.choices.iter().all(|c| !c.selected), | |
| 733 | - "custom hue: no accent preset checked" | |
| 734 | - ); | |
| 735 | - | |
| 736 | - let [base_row, accent_row] = colour_group(Lang::En, true, "ink", "plum"); | |
| 737 | - let plum_hue = preset_accent_hue("plum").unwrap(); | |
| 738 | - let ink_hue = preset_base_hue("ink").unwrap(); | |
| 739 | - assert!(!accent_row.stripe.custom, "preset accent: not custom"); | |
| 740 | - assert_eq!(accent_row.stripe.hue, plum_hue, "preset accent: knob hue"); | |
| 741 | - assert!(!base_row.stripe.custom, "preset base: not custom"); | |
| 742 | - assert_eq!(base_row.stripe.hue, ink_hue, "preset base: knob hue"); | |
| 743 | - let plum = accent_row | |
| 744 | - .choices | |
| 745 | - .iter() | |
| 746 | - .find(|c| c.value == "plum") | |
| 747 | - .unwrap(); | |
| 748 | - assert!(plum.selected, "preset accent: checked"); | |
| 749 | - assert_eq!(plum.hue, plum_hue.to_string(), "preset accent: hue value"); | |
| 750 | - | |
| 751 | - assert_eq!(hue_of("hue-359"), Some(359), "hue: max"); | |
| 752 | - assert_eq!(hue_of("hue-360"), None, "hue: out of range"); | |
| 753 | - assert_eq!(hue_of("hue-"), None, "hue: empty"); | |
| 754 | - assert_eq!(hue_of("hue-+5"), None, "hue: sign"); | |
| 755 | - assert_eq!(hue_of("sage"), None, "hue: preset id"); | |
| 756 | - } | |
| 757 | - | |
| 758 | - #[test] | |
| 759 | - fn a_stored_hue_and_vividness_fill_the_sliders() { | |
| 760 | - let [base_row, accent_row] = colour_group(Lang::En, true, "hue-95-v80", "hue-95-v80"); | |
| 761 | - let accent = &accent_row.stripe; | |
| 762 | - assert_eq!((accent.hue, accent.vivid), (95, 80), "accent: sliders"); | |
| 763 | - assert!(accent.custom, "accent: custom"); | |
| 764 | - assert_eq!( | |
| 765 | - custom_id(accent.hue, accent.vivid), | |
| 766 | - "hue-95-v80", | |
| 767 | - "accent: value" | |
| 768 | - ); | |
| 769 | - assert_eq!( | |
| 770 | - (base_row.stripe.hue, base_row.stripe.vivid), | |
| 771 | - (95, 80), | |
| 772 | - "base: sliders" | |
| 773 | - ); | |
| 774 | - } | |
| 775 | - | |
| 776 | - #[test] | |
| 777 | - fn labels_follow_the_page_language() { | |
| 778 | - assert_eq!(theme_label(Lang::En, "dark"), "Dark"); | |
| 779 | - assert_eq!(theme_label(Lang::Tr, "dark"), "Koyu"); | |
| 780 | - assert_eq!(base_name(Lang::Tr, "ink"), "M\u{fc}rekkep"); | |
| 781 | - assert_eq!(theme_label(Lang::En, "light"), "Light (default)"); | |
| 782 | - assert_eq!( | |
| 783 | - theme_label(Lang::Tr, "light"), | |
| 784 | - "A\u{e7}\u{131}k (varsay\u{131}lan)" | |
| 785 | - ); | |
| 786 | - assert_eq!(language_label(Lang::Tr, "tr"), "T\u{fc}rk\u{e7}e"); | |
| 787 | - } | |
| 788 | - | |
| 789 | 673 | #[test] |
| 790 | 674 | fn only_left_or_right_passes_for_the_sidebar() { |
| 791 | 675 | assert_eq!( |
crates/forge-web-account/src/pages/settings_sessions.rsmodified+0 -14
| @@ -159,24 +159,10 @@ mod tests { | ||
| 159 | 159 | use topcoat::router::request::Request; |
| 160 | 160 | use topcoat::router::{Body, to_bytes}; |
| 161 | 161 | |
| 162 | - use super::agent_label; | |
| 163 | 162 | use crate::auth::SESSION_COOKIE; |
| 164 | - use crate::i18n::Lang; | |
| 165 | 163 | |
| 166 | 164 | const CSRF: &str = "sessions-test-csrf"; |
| 167 | 165 | |
| 168 | - #[test] | |
| 169 | - fn device_labels_name_the_browser_and_the_system() { | |
| 170 | - let chrome_android = "Mozilla/5.0 (Linux; Android 14; Pixel 8) AppleWebKit/537.36 Chrome/130.0 Mobile Safari/537.36"; | |
| 171 | - assert_eq!(agent_label(Lang::En, chrome_android), "Chrome on Android"); | |
| 172 | - let safari_iphone = "Mozilla/5.0 (iPhone; CPU iPhone OS 18_0 like Mac OS X) AppleWebKit/605.1.15 Version/18.0 Mobile/15E148 Safari/604.1"; | |
| 173 | - assert_eq!(agent_label(Lang::En, safari_iphone), "Safari on iPhone"); | |
| 174 | - assert_eq!( | |
| 175 | - agent_label(Lang::En, "curl/8.0"), | |
| 176 | - "Browser on Unknown system" | |
| 177 | - ); | |
| 178 | - } | |
| 179 | - | |
| 180 | 166 | #[tokio::test] |
| 181 | 167 | async fn sessions_list_moves_to_the_security_sessions_topic() { |
| 182 | 168 | let dir = tempfile::tempdir().expect("tempdir"); |
crates/forge-web-repo/src/pages/ci_badge.rsmodified+0 -31
| @@ -256,27 +256,6 @@ mod tests { | ||
| 256 | 256 | assert!(!svg.contains(&"x".repeat(MAX_LABEL_CHARS + 1))); |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | - #[test] | |
| 260 | - fn every_status_has_its_colour_and_word() { | |
| 261 | - let cases = [ | |
| 262 | - (BadgeStatus::Passing, "#4c1", "passing"), | |
| 263 | - (BadgeStatus::Failing, "#e05d44", "failing"), | |
| 264 | - (BadgeStatus::Error, "#9a5b5b", "error"), | |
| 265 | - (BadgeStatus::Running, "#dfb317", "running"), | |
| 266 | - (BadgeStatus::Pending, "#dfb317", "pending"), | |
| 267 | - (BadgeStatus::Cancelled, "#9f9f9f", "cancelled"), | |
| 268 | - (BadgeStatus::Skipped, "#9f9f9f", "skipped"), | |
| 269 | - (BadgeStatus::NoStatus, "#9f9f9f", "no status"), | |
| 270 | - ]; | |
| 271 | - for (status, color, word) in cases { | |
| 272 | - let svg = render_badge("build", status); | |
| 273 | - assert!(svg.contains(&format!("fill=\"{color}\"")), "{word}"); | |
| 274 | - assert!(svg.contains(&format!(">{word}</text>")), "{word}"); | |
| 275 | - assert!(svg.contains("fill=\"#555\"")); | |
| 276 | - assert!(svg.starts_with("<svg xmlns=\"http://www.w3.org/2000/svg\"")); | |
| 277 | - } | |
| 278 | - } | |
| 279 | - | |
| 280 | 259 | #[test] |
| 281 | 260 | fn run_and_job_states_map_to_badge_statuses() { |
| 282 | 261 | assert_eq!(status_of_run(RunState::Success), BadgeStatus::Passing); |
| @@ -293,14 +272,4 @@ mod tests { | ||
| 293 | 272 | assert_eq!(status_of_job(JobState::Cancelled), BadgeStatus::Cancelled); |
| 294 | 273 | assert_eq!(status_of_job(JobState::Skipped), BadgeStatus::Skipped); |
| 295 | 274 | } |
| 296 | - | |
| 297 | - #[test] | |
| 298 | - fn width_grows_with_text() { | |
| 299 | - assert!(text_box("no status") > text_box("ok")); | |
| 300 | - let svg = render_badge("build", BadgeStatus::Passing); | |
| 301 | - assert!(svg.contains(&format!( | |
| 302 | - "width=\"{}\"", | |
| 303 | - text_box("build") + text_box("passing") | |
| 304 | - ))); | |
| 305 | - } | |
| 306 | 275 | } |
crates/forge-web-repo/src/pages/commits.rsmodified+0 -17
| @@ -342,24 +342,7 @@ async fn commits_page(cx: &Cx) -> Result<impl View> { | ||
| 342 | 342 | mod tests { |
| 343 | 343 | use forge_core::Visibility; |
| 344 | 344 | |
| 345 | - use crate::i18n::Lang; | |
| 346 | 345 | use crate::test_support::fixture::{Fixture, OWNER, REPO, get, git}; |
| 347 | - use crate::views::enc; | |
| 348 | - use crate::views::relative_time; | |
| 349 | - | |
| 350 | - #[test] | |
| 351 | - fn dates_and_relative_units_format() { | |
| 352 | - assert_eq!(relative_time(Lang::En, 990, 1000), "just now"); | |
| 353 | - assert_eq!( | |
| 354 | - relative_time(Lang::En, 10_000 - 3 * 86_400, 10_000), | |
| 355 | - "3 days ago" | |
| 356 | - ); | |
| 357 | - assert_eq!( | |
| 358 | - relative_time(Lang::En, 10_000 - 86_400, 10_000), | |
| 359 | - "1 day ago" | |
| 360 | - ); | |
| 361 | - assert_eq!(enc("a b/c#d"), "a%20b/c%23d"); | |
| 362 | - } | |
| 363 | 346 | |
| 364 | 347 | async fn scenario_pagination(fx: &Fixture) { |
| 365 | 348 | let base = format!("/{OWNER}/{REPO}/commits/main"); |
crates/forge-web-repo/src/pages/pulls_list.rsmodified+0 -11
| @@ -417,17 +417,6 @@ mod tests { | ||
| 417 | 417 | const HEAD_OID: &str = "1111111111111111111111111111111111111111"; |
| 418 | 418 | const BASE_OID: &str = "2222222222222222222222222222222222222222"; |
| 419 | 419 | |
| 420 | - #[tokio::test] | |
| 421 | - async fn empty_repo_says_no_pull_requests_yet() { | |
| 422 | - let fx = fixture(Visibility::Public).await; | |
| 423 | - let reply = send(&fx.router, "GET", &base(), true, None, &[]).await; | |
| 424 | - assert_eq!(reply.status, 200); | |
| 425 | - assert!(reply.text().contains( | |
| 426 | - "No pull requests yet. Push a branch, then open one to propose its changes." | |
| 427 | - )); | |
| 428 | - assert_eq!(rows(&reply.text()), 0); | |
| 429 | - } | |
| 430 | - | |
| 431 | 420 | #[tokio::test] |
| 432 | 421 | async fn list_shows_pulls_not_issues() { |
| 433 | 422 | let fx = fixture(Visibility::Public).await; |