fix(tui): guard contextual content actions
This commit is contained in:
1 parent
59707b77d2
commit
70286ed9b8
7 files changed
+114
-2
No files matched your search
@@ -32,6 +32,50 @@ fn global_navigation_returns_from_log_overlay() {
|
||||
assert!(ui.app.exit);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn escape_returns_through_nested_sections() {
|
||||
let mut ui = UiHarness::new();
|
||||
|
||||
for focused in [
|
||||
FocusedArea::Content,
|
||||
FocusedArea::Account,
|
||||
FocusedArea::Settings,
|
||||
] {
|
||||
ui.app.focused = focused;
|
||||
ui.key(KeyCode::Esc);
|
||||
assert_eq!(ui.app.focused, FocusedArea::Instances);
|
||||
}
|
||||
|
||||
ui.app.focused = FocusedArea::Content;
|
||||
ui.app.content_tab = ContentTab::Worlds;
|
||||
ui.app.open_world_datapacks = Some(("World".to_owned(), PathBuf::from("World")));
|
||||
ui.key(KeyCode::Esc);
|
||||
|
||||
assert_eq!(ui.app.focused, FocusedArea::Content);
|
||||
assert!(ui.app.open_world_datapacks.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unmatched_installed_content_has_no_version_action() {
|
||||
let mut ui = UiHarness::new();
|
||||
ui.add_instance("Unmatched");
|
||||
ui.app.focused = FocusedArea::Content;
|
||||
ui.app.content_tab = ContentTab::Mods;
|
||||
let path = ui
|
||||
.instance_path("Unmatched")
|
||||
.join("minecraft/mods/unknown.jar");
|
||||
std::fs::create_dir_all(path.parent().unwrap()).unwrap();
|
||||
std::fs::write(&path, []).unwrap();
|
||||
ui.app.mods_state.entries = vec![content_entry("Unknown mod", path)];
|
||||
ui.app.mods_state.list_state.selected = Some(0);
|
||||
|
||||
ui.draw();
|
||||
assert!(!ui.screen().contains("[v] versions"));
|
||||
|
||||
ui.key(KeyCode::Char('v'));
|
||||
assert!(ui.app.mods_discovery_state.version_popup.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn worlds_reserves_q_for_available_quick_launch() {
|
||||
let mut ui = UiHarness::new();
|
||||
|
||||
@@ -41,6 +41,24 @@ fn entry(name: &str) -> ContentEntry {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn selected_provider_project_tracks_the_filtered_selection() {
|
||||
let mut state = ContentListState {
|
||||
entries: vec![entry("Unmatched"), entry("Matched")],
|
||||
..Default::default()
|
||||
};
|
||||
state.entries[1].provider_project = Some(crate::instance::ProviderProject {
|
||||
provider: "modrinth".to_owned(),
|
||||
project_id: "matched".to_owned(),
|
||||
version_id: "version".to_owned(),
|
||||
});
|
||||
state.list_state.selected = Some(0);
|
||||
|
||||
assert!(!state.selected_has_provider_project());
|
||||
state.list_state.selected = Some(1);
|
||||
assert!(state.selected_has_provider_project());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn world_cards_preview_up_to_three_datapacks() {
|
||||
let lines = world_descriptions(&WorldDetails {
|
||||
|
||||
Reference in new issue
Block a user