test(tui): make snapshots independent of local settings

This commit is contained in:
objz committed 2026-09-25 11:22:49 +02:00
1 parent 9d480f8bfb
commit 28c0731478
3 files changed
+12 -3

No files matched your search

+9 -2
View File
@@ -77,6 +77,7 @@ impl Default for ThemeConfig {
} }
} }
#[cfg(not(test))]
fn load_theme_config() -> ThemeConfig { fn load_theme_config() -> ThemeConfig {
let path = super::get_config_path().join("theme.toml"); let path = super::get_config_path().join("theme.toml");
ensure_theme_exists(&path); ensure_theme_exists(&path);
@@ -89,6 +90,7 @@ fn load_theme_config() -> ThemeConfig {
} }
} }
#[cfg(not(test))]
fn ensure_theme_exists(path: &Path) { fn ensure_theme_exists(path: &Path) {
if path.exists() { if path.exists() {
return; return;
@@ -207,8 +209,13 @@ impl BorderStyleStore {
} }
} }
static THEME_CONFIG: LazyLock<RwLock<ThemeConfig>> = static THEME_CONFIG: LazyLock<RwLock<ThemeConfig>> = LazyLock::new(|| {
LazyLock::new(|| RwLock::new(load_theme_config())); #[cfg(test)]
let config = ThemeConfig::default();
#[cfg(not(test))]
let config = load_theme_config();
RwLock::new(config)
});
pub static THEME: LazyLock<ThemeStore> = LazyLock::new(|| { pub static THEME: LazyLock<ThemeStore> = LazyLock::new(|| {
let config = THEME_CONFIG let config = THEME_CONFIG
+2 -1
View File
@@ -133,7 +133,8 @@ fn install_summary_checks_selected_mod_release_not_picker_version() {
}) })
.unwrap(); .unwrap();
assert!( assert!(
format!("{}", terminal.backend()).contains("Mod version may be incompatible with 26.3") format!("{}", terminal.backend())
.contains("This mod version may be incompatible with 26.3")
); );
assert!(!format!("{}", terminal.backend()).contains("Warning:")); assert!(!format!("{}", terminal.backend()).contains("Warning:"));
} }
@@ -1400,6 +1400,7 @@ mod tests {
#[test] #[test]
fn launcher_choices_toggles_and_maintenance_are_interactive() { fn launcher_choices_toggles_and_maintenance_are_interactive() {
let mut state = State::new(); let mut state = State::new();
state.config.ui.image_protocol = ImageProtocol::Auto;
state.selected = 2; state.selected = 2;
state.handle_key(&KeyEvent::from(KeyCode::Enter)); state.handle_key(&KeyEvent::from(KeyCode::Enter));
assert_eq!(state.choice_picker, Some(ChoicePicker::ImageProtocol)); assert_eq!(state.choice_picker, Some(ChoicePicker::ImageProtocol));