fix: ignore stale TUI results and show narrow settings

This commit is contained in:
objz committed 2026-10-01 17:45:17 +02:00
1 parent 0d1cafcb10
commit 75c74333c5
14 files changed
+268 -93

No files matched your search

+56
View File
@@ -3,6 +3,62 @@
use super::*;
#[test]
fn narrow_settings_shows_the_selected_pane() {
let tmp = tempfile::tempdir().unwrap();
let mut state = SettingsState::new(tmp.path().to_path_buf());
let instance: InstanceConfig = serde_json::from_value(serde_json::json!({
"name": "Test", "game_version": "1.21", "loader": "vanilla",
"loader_version": null, "created": "2026-01-01T00:00:00Z", "java_path": "test-java"
}))
.unwrap();
state.java_key = Some("test-java".to_owned());
state.java_label = "jdk17".to_owned();
let mut terminal = ratatui::Terminal::new(ratatui::backend::TestBackend::new(35, 8)).unwrap();
terminal
.draw(|frame| {
render(
frame,
frame.area(),
FocusedArea::Settings,
&mut state,
Some(&instance),
)
})
.unwrap();
let text = terminal
.backend()
.buffer()
.content()
.iter()
.map(|cell| cell.symbol())
.collect::<String>();
assert!(text.contains(LOCAL_PROFILE_LABEL));
state.pane = SettingsPane::Info;
terminal
.draw(|frame| {
render(
frame,
frame.area(),
FocusedArea::Settings,
&mut state,
Some(&instance),
)
})
.unwrap();
let text = terminal
.backend()
.buffer()
.content()
.iter()
.map(|cell| cell.symbol())
.collect::<String>();
assert!(text.contains("Memory"));
assert!(text.contains("jdk17"));
}
#[test]
fn removing_selected_last_profile_clamps_selection() {
let tmp = tempfile::tempdir().unwrap();