fix(tui): polish log filters and unlinked badge styling
This commit is contained in:
1 parent
b5c680ed55
commit
41707c8a09
7 files changed
+70
-79
No files matched your search
+17
-5
@@ -985,6 +985,7 @@ fn mouse_drag_selects_overlay_characters_for_yank_and_escape_closes() {
|
||||
#[test]
|
||||
fn log_level_popup_does_not_delete_logs_or_leave_on_tab() {
|
||||
use crate::instance::logs::files::LogFileEntry;
|
||||
use ratatui::layout::{Constraint, Rect};
|
||||
let mut ui = UiHarness::new();
|
||||
ui.add_instance("A");
|
||||
ui.app.focused = FocusedArea::Content;
|
||||
@@ -995,6 +996,7 @@ fn log_level_popup_does_not_delete_logs_or_leave_on_tab() {
|
||||
path: ui.instance_path("A").join("a.log"),
|
||||
});
|
||||
ui.app.logs_state.list_state.selected = Some(0);
|
||||
ui.app.logs_state.viewer_lines = vec!["12:00:00:INFO:rmcl: hello".to_owned()];
|
||||
ui.key(KeyCode::Char('f'));
|
||||
ui.key(KeyCode::Char('d'));
|
||||
assert_eq!(ui.app.focused, FocusedArea::Content);
|
||||
@@ -1004,12 +1006,24 @@ fn log_level_popup_does_not_delete_logs_or_leave_on_tab() {
|
||||
ui.draw();
|
||||
assert!(ui.screen().contains("· Error"));
|
||||
assert!(ui.screen().contains("[Esc] close"));
|
||||
let popup = Rect::new(0, 0, 100, 30).centered(Constraint::Length(26), Constraint::Length(7));
|
||||
assert_eq!(
|
||||
ui.screen()
|
||||
.lines()
|
||||
.nth(popup.y as usize)
|
||||
.unwrap()
|
||||
.chars()
|
||||
.skip(popup.x as usize + 2)
|
||||
.take(12)
|
||||
.collect::<String>(),
|
||||
" Log levels "
|
||||
);
|
||||
ui.key(KeyCode::Esc);
|
||||
assert!(!ui.app.logs_state.filter_open);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn selected_unlinked_content_explains_why_versions_are_unavailable() {
|
||||
fn selected_unlinked_content_shows_only_the_badge() {
|
||||
let mut ui = UiHarness::new();
|
||||
ui.add_instance("A");
|
||||
let minecraft = ui
|
||||
@@ -1037,10 +1051,8 @@ fn selected_unlinked_content_explains_why_versions_are_unavailable() {
|
||||
ui.app.focused = FocusedArea::Content;
|
||||
ui.draw();
|
||||
assert!(ui.screen().contains("Unlinked"));
|
||||
assert!(
|
||||
ui.screen()
|
||||
.contains("No online source linked; version switching unavailable.")
|
||||
);
|
||||
assert!(!ui.screen().contains("No online source linked"));
|
||||
assert!(!ui.screen().contains("version switching unavailable"));
|
||||
ui.key(KeyCode::Char('v'));
|
||||
assert!(ui.app.mods_discovery_state.version_popup.is_none());
|
||||
|
||||
|
||||
@@ -1424,7 +1424,7 @@ fn unlinked_badge_is_subdued_and_requires_a_completed_unmatched_lookup() {
|
||||
});
|
||||
state.apply_manifest(&manifest, &minecraft, ContentKind::Mod);
|
||||
state.apply_update_snapshot(None);
|
||||
assert!(state.selected_is_unlinked());
|
||||
assert!(state.unlinked_paths.contains(&state.entries[0].path));
|
||||
let picker = ratatui_image::picker::Picker::halfblocks();
|
||||
let theme = crate::config::theme::THEME.as_ref();
|
||||
let mut terminal = ratatui::Terminal::new(ratatui::backend::TestBackend::new(50, 4)).unwrap();
|
||||
@@ -1447,9 +1447,9 @@ fn unlinked_badge_is_subdued_and_requires_a_completed_unmatched_lookup() {
|
||||
let buffer = terminal.backend().buffer();
|
||||
let row = (0..50).map(|x| buffer[(x, 0)].symbol()).collect::<String>();
|
||||
let x = row.find("Unlinked").expect("unlinked badge") as u16;
|
||||
assert_eq!(buffer[(x, 0)].fg, theme.text_dim());
|
||||
assert_eq!(buffer[(x, 0)].bg, theme.surface());
|
||||
assert!(!buffer[(x, 0)].modifier.contains(Modifier::BOLD));
|
||||
assert_eq!(buffer[(x, 0)].fg, theme.background());
|
||||
assert_eq!(buffer[(x, 0)].bg, theme.text_dim());
|
||||
assert!(buffer[(x, 0)].modifier.contains(Modifier::BOLD));
|
||||
assert!(terminal.backend().to_string().contains("1.0.0"));
|
||||
}
|
||||
for resolution in [
|
||||
@@ -1471,7 +1471,7 @@ fn unlinked_badge_is_subdued_and_requires_a_completed_unmatched_lookup() {
|
||||
] {
|
||||
manifest.files[0].resolution = resolution;
|
||||
state.apply_manifest(&manifest, &minecraft, ContentKind::Mod);
|
||||
assert!(!state.selected_is_unlinked());
|
||||
assert!(state.unlinked_paths.is_empty());
|
||||
}
|
||||
state.apply_manifest(&ContentManifest::default(), &minecraft, ContentKind::Mod);
|
||||
assert!(state.unlinked_paths.is_empty());
|
||||
|
||||
@@ -113,11 +113,11 @@ fn log_levels_share_one_color_mapping_in_viewer_and_overlay() {
|
||||
}
|
||||
assert_eq!(
|
||||
line_level_style("12:17:28:DEBUG:rmcl::net: fetching").fg,
|
||||
Some(theme.info())
|
||||
Some(theme.text_dim())
|
||||
);
|
||||
assert_eq!(
|
||||
line_level_style("12:17:28:TRACE:rmcl::net: fetching").fg,
|
||||
Some(theme.text_dim())
|
||||
Some(theme.border())
|
||||
);
|
||||
assert_ne!(
|
||||
log_level_style(LogLevel::Debug).fg,
|
||||
@@ -228,6 +228,23 @@ fn level_filter_panel_cycles_neutral_include_exclude_resets_and_closes() {
|
||||
assert!(!state.filter_open);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn level_filter_highlight_reaches_the_popup_right_edge() {
|
||||
use ratatui::layout::Constraint;
|
||||
let _guard = crate::tests::TEST_LOCK
|
||||
.lock()
|
||||
.unwrap_or_else(|error| error.into_inner());
|
||||
let mut terminal = ratatui::Terminal::new(ratatui::backend::TestBackend::new(80, 20)).unwrap();
|
||||
let popup = Rect::new(0, 0, 80, 20).centered(Constraint::Length(26), Constraint::Length(7));
|
||||
terminal
|
||||
.draw(|frame| render_level_filter(frame, 0, &[None; 5]))
|
||||
.unwrap();
|
||||
let buffer = terminal.backend().buffer();
|
||||
let theme = THEME.as_ref();
|
||||
assert_eq!(buffer[(popup.right() - 2, popup.y + 1)].bg, theme.stripe());
|
||||
assert_eq!(buffer[(popup.right() - 2, popup.y + 2)].bg, theme.surface());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn level_filter_hides_matching_lines_but_keeps_unclassified_ones() {
|
||||
fn rendered(state: &mut LogsState) -> String {
|
||||
|
||||
Reference in new issue
Block a user