fix(tui): refine log selection and filters, label unlinked content

This commit is contained in:
objz committed 2026-10-04 12:12:11 +02:00
1 parent 8adadf75a8
commit b5c680ed55
13 files changed
+906 -365

No files matched your search

+86
View File
@@ -1391,6 +1391,92 @@ fn manifest_metadata_keeps_an_embedded_icon_renderer() {
assert!(state.image_protocols.contains_key("installed"));
}
#[test]
fn unlinked_badge_is_subdued_and_requires_a_completed_unmatched_lookup() {
use crate::instance::{
ContentFileRecord, ContentKind, ContentManifest, FileFingerprint, Resolution,
};
let minecraft = PathBuf::from("instance/minecraft");
let mut installed = entry("scoreboardinternal");
installed.path = minecraft.join("mods/local.jar");
installed.footer_label = Some("1.0.0".to_owned());
let mut state = ContentListState::default();
state.set_entries(vec![installed]);
let mut manifest = ContentManifest::default();
manifest.upsert(ContentFileRecord {
relative_path: PathBuf::from("mods/local.jar"),
kind: ContentKind::Mod,
enabled: true,
fingerprint: FileFingerprint {
size: 0,
modified_ns: 0,
hashes: Default::default(),
},
resolution: Resolution::Unmatched {
checked_at: 1,
providers: vec!["modrinth".to_owned()],
},
provider_aliases: Vec::new(),
provider_checks: vec!["modrinth".to_owned()],
required_dependencies: Vec::new(),
automatic_dependency: false,
cleanup_eligible: false,
});
state.apply_manifest(&manifest, &minecraft, ContentKind::Mod);
state.apply_update_snapshot(None);
assert!(state.selected_is_unlinked());
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();
for focused in [false, true] {
terminal
.draw(|frame| {
super::render(
frame,
frame.area(),
&mut state,
focused,
"Loading...",
"Empty",
&picker,
false,
false,
)
})
.unwrap();
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!(terminal.backend().to_string().contains("1.0.0"));
}
for resolution in [
Resolution::Pending,
Resolution::Unmatched {
checked_at: 1,
providers: Vec::new(),
},
Resolution::Ambiguous {
candidates: Vec::new(),
},
Resolution::Resolved {
project: crate::instance::ProviderProject {
provider: "modrinth".to_owned(),
project_id: "project".to_owned(),
version_id: "version".to_owned(),
},
},
] {
manifest.files[0].resolution = resolution;
state.apply_manifest(&manifest, &minecraft, ContentKind::Mod);
assert!(!state.selected_is_unlinked());
}
state.apply_manifest(&ContentManifest::default(), &minecraft, ContentKind::Mod);
assert!(state.unlinked_paths.is_empty());
}
#[test]
fn provider_metadata_fills_a_missing_installed_description() {
let mut state = ContentListState::default();