feat(modpacks): manage installed pack versions
This commit is contained in:
1 parent
16e2f3204d
commit
a839925041
13 files changed
+301
-67
No files matched your search
@@ -119,6 +119,89 @@ fn installed_version_hint_requires_selected_provider_match() {
|
||||
assert!(ui.screen().contains("[v] versions"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn managed_modpack_instance_exposes_direct_version_selector() {
|
||||
let mut ui = UiHarness::new();
|
||||
ui.add_instance("Managed Pack");
|
||||
|
||||
ui.draw();
|
||||
assert!(!ui.screen().contains("[v] versions"));
|
||||
ui.app.instances_state.instances[0].modpack_source = Some(ProviderProject {
|
||||
provider: "unsupported".to_owned(),
|
||||
project_id: "pack".to_owned(),
|
||||
version_id: "current".to_owned(),
|
||||
});
|
||||
|
||||
ui.draw();
|
||||
assert!(ui.screen().contains("[v] versions"));
|
||||
ui.key(KeyCode::Char('v'));
|
||||
let popup = ui
|
||||
.app
|
||||
.modpack_versions_state
|
||||
.as_ref()
|
||||
.and_then(|state| state.version_popup.as_ref())
|
||||
.unwrap();
|
||||
assert!(!popup.selecting_minecraft_version);
|
||||
assert_eq!(popup.current_version_id.as_deref(), Some("current"));
|
||||
|
||||
ui.key(KeyCode::Esc);
|
||||
assert!(ui.app.modpack_versions_state.is_none());
|
||||
|
||||
ui.key(KeyCode::Char('v'));
|
||||
let popup = ui
|
||||
.app
|
||||
.modpack_versions_state
|
||||
.as_mut()
|
||||
.and_then(|state| state.version_popup.as_mut())
|
||||
.unwrap();
|
||||
popup.loading = false;
|
||||
popup.versions = vec![crate::net::modrinth::VersionInfo {
|
||||
id: "current".to_owned(),
|
||||
project_id: "pack".to_owned(),
|
||||
name: "Current".to_owned(),
|
||||
version_number: "1.0".to_owned(),
|
||||
game_versions: vec!["1.21.1".to_owned()],
|
||||
loaders: Vec::new(),
|
||||
version_type: crate::net::modrinth::VersionType::Release,
|
||||
dependencies: Vec::new(),
|
||||
date_published: String::new(),
|
||||
files: Vec::new(),
|
||||
}];
|
||||
ui.key(KeyCode::Enter);
|
||||
assert!(ui.app.modpack_versions_state.is_none());
|
||||
assert_eq!(
|
||||
ui.app.modpack_update_popup.as_ref().unwrap().action,
|
||||
crate::tui::widgets::popups::modpack_update::Action::Reinstall
|
||||
);
|
||||
|
||||
ui.app.modpack_update_popup = None;
|
||||
ui.key(KeyCode::Char('v'));
|
||||
let popup = ui
|
||||
.app
|
||||
.modpack_versions_state
|
||||
.as_mut()
|
||||
.and_then(|state| state.version_popup.as_mut())
|
||||
.unwrap();
|
||||
popup.loading = false;
|
||||
popup.versions = vec![crate::net::modrinth::VersionInfo {
|
||||
id: "new".to_owned(),
|
||||
project_id: "pack".to_owned(),
|
||||
name: "New".to_owned(),
|
||||
version_number: "2.0".to_owned(),
|
||||
game_versions: vec!["1.21.1".to_owned()],
|
||||
loaders: Vec::new(),
|
||||
version_type: crate::net::modrinth::VersionType::Release,
|
||||
dependencies: Vec::new(),
|
||||
date_published: String::new(),
|
||||
files: Vec::new(),
|
||||
}];
|
||||
ui.key(KeyCode::Enter);
|
||||
assert_eq!(
|
||||
ui.app.modpack_update_popup.as_ref().unwrap().action,
|
||||
crate::tui::widgets::popups::modpack_update::Action::Change
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn world_datapack_version_action_requires_selected_provider_match() {
|
||||
let mut ui = UiHarness::new();
|
||||
|
||||
@@ -94,6 +94,7 @@ impl UiHarness {
|
||||
content_manifest: None,
|
||||
content_update_snapshot: None,
|
||||
content_update_popup: None,
|
||||
modpack_versions_state: None,
|
||||
modpack_update_popup: None,
|
||||
provider_conflict: None,
|
||||
dismissed_provider_conflicts: HashSet::new(),
|
||||
|
||||
@@ -537,6 +537,29 @@ fn modpacks_choose_minecraft_before_filtering_pack_versions() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn managed_modpack_versions_open_directly_and_mark_reinstall() {
|
||||
let mut state = DiscoveryState::new_modpacks();
|
||||
let source = crate::instance::ProviderProject {
|
||||
provider: "modrinth".to_owned(),
|
||||
project_id: "pack".to_owned(),
|
||||
version_id: "current".to_owned(),
|
||||
};
|
||||
|
||||
let request = state
|
||||
.begin_managed_modpack_versions("Managed Pack", source)
|
||||
.unwrap();
|
||||
assert_eq!(request.current_version_id.as_deref(), Some("current"));
|
||||
let popup = state.version_popup.as_mut().unwrap();
|
||||
assert!(!popup.selecting_minecraft_version);
|
||||
popup.loading = false;
|
||||
popup.versions = vec![version("current"), version("older")];
|
||||
|
||||
assert_eq!(popup.title(), "Reinstall Managed Pack");
|
||||
popup.selected = 1;
|
||||
assert_eq!(popup.title(), "Change Managed Pack version");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn project_page_loads_for_the_selected_discovery_entry() {
|
||||
let project = DiscoveryProject {
|
||||
|
||||
@@ -79,38 +79,3 @@ fn instances_list_renders_empty() {
|
||||
|
||||
insta::assert_snapshot!(terminal.backend());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn managed_modpack_update_is_badged_in_the_instance_list() {
|
||||
let mut state = State::with_instances(vec![synthetic_instance("Managed Pack")]);
|
||||
state.modpack_updates.insert(
|
||||
"Managed Pack".to_owned(),
|
||||
crate::net::modrinth::VersionInfo {
|
||||
id: "new".to_owned(),
|
||||
project_id: "pack".to_owned(),
|
||||
name: "New".to_owned(),
|
||||
version_number: "2.0".to_owned(),
|
||||
game_versions: Vec::new(),
|
||||
loaders: Vec::new(),
|
||||
version_type: crate::net::modrinth::VersionType::Release,
|
||||
dependencies: Vec::new(),
|
||||
date_published: String::new(),
|
||||
files: Vec::new(),
|
||||
},
|
||||
);
|
||||
let backend = TestBackend::new(40, 5);
|
||||
let mut terminal = Terminal::new(backend).unwrap();
|
||||
|
||||
terminal
|
||||
.draw(|frame| render(frame, frame.area(), FocusedArea::Instances, &mut state))
|
||||
.unwrap();
|
||||
|
||||
let text = terminal
|
||||
.backend()
|
||||
.buffer()
|
||||
.content()
|
||||
.iter()
|
||||
.map(|cell| cell.symbol())
|
||||
.collect::<String>();
|
||||
assert!(text.contains("Managed Pack Update"));
|
||||
}
|
||||
Reference in new issue
Block a user