feat(discovery): add sorting side panel
This commit is contained in:
1 parent
2b900253d0
commit
53a95c6022
14 files changed
+309
-30
No files matched your search
@@ -90,6 +90,30 @@ fn content_mode_toggles_both_ways() {
|
||||
assert_eq!(ContentMode::Discover.toggle(), ContentMode::Installed);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sort_panel_keeps_results_navigation_available() {
|
||||
use crate::instance::content::provider::DiscoverySort;
|
||||
|
||||
let mut state = DiscoveryState::new_modpacks();
|
||||
state.list.entries = vec![
|
||||
project_entry(project("one"), None),
|
||||
project_entry(project("two"), None),
|
||||
];
|
||||
state.list.list_state.selected = Some(0);
|
||||
|
||||
assert!(handle_key(&KeyEvent::from(KeyCode::Char('s')), &mut state));
|
||||
assert!(state.sort_panel_open);
|
||||
assert!(!state.sort_panel_focused);
|
||||
assert!(handle_key(&KeyEvent::from(KeyCode::Char('j')), &mut state));
|
||||
assert_eq!(state.list.list_state.selected, Some(1));
|
||||
|
||||
assert!(handle_key(&KeyEvent::from(KeyCode::Char('l')), &mut state));
|
||||
assert!(handle_key(&KeyEvent::from(KeyCode::Char('j')), &mut state));
|
||||
assert!(handle_key(&KeyEvent::from(KeyCode::Enter), &mut state));
|
||||
assert_eq!(state.sort, DiscoverySort::Downloads);
|
||||
assert!(state.search_due());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn duplicate_provider_titles_share_one_identity() {
|
||||
let mut modrinth = project("sodium");
|
||||
|
||||
@@ -97,6 +97,24 @@ fn discovery_version_popup_renders_over_a_project_page() {
|
||||
assert!(format!("{}", terminal.backend()).contains("Install Project"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn discovery_sort_panel_renders_beside_results() {
|
||||
use crate::instance::ContentKind;
|
||||
use ratatui::{Terminal, backend::TestBackend};
|
||||
|
||||
let mut state = DiscoveryState::new(ContentKind::Mod);
|
||||
state.sort_panel_open = true;
|
||||
let mut terminal = Terminal::new(TestBackend::new(80, 20)).unwrap();
|
||||
let picker = ratatui_image::picker::Picker::halfblocks();
|
||||
terminal
|
||||
.draw(|frame| render_discovery_popup(frame, frame.area(), &mut state, &picker))
|
||||
.unwrap();
|
||||
|
||||
let rendered = format!("{}", terminal.backend());
|
||||
assert!(rendered.contains("Sort"));
|
||||
assert!(rendered.contains("Most downloaded"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn confirmation_metadata_is_human_readable() {
|
||||
assert_eq!(
|
||||
|
||||
Reference in new issue
Block a user