feat: redesign cli ux progress

This commit is contained in:
stoorps 2026-03-20 17:47:32 +00:00
parent ab60ee641f
commit c63b2917da
Signed by: stoorps
SSH key fingerprint: SHA256:AZlPfu9hTu042EGtZElmDQoy+KvMOeShLDan/fYLoNI
21 changed files with 994 additions and 99 deletions

View file

@ -1,8 +1,12 @@
use aim_core::app::interaction::{InteractionKind, InteractionRequest};
use aim_core::app::list::build_list_rows;
use aim_core::app::remove::{build_removal_plan, resolve_registered_app};
use aim_core::app::progress::{OperationEvent, OperationStage};
use aim_core::app::remove::{
build_removal_plan, remove_registered_app_with_reporter, resolve_registered_app,
};
use aim_core::domain::app::{AppRecord, InstallMetadata, InstallScope};
use std::path::Path;
use tempfile::tempdir;
#[test]
fn remove_flow_rejects_unknown_app_names() {
@ -125,3 +129,55 @@ fn removal_plan_falls_back_to_derived_managed_user_paths() {
]
);
}
#[test]
fn remove_flow_reports_resolution_and_cleanup_events() {
let install_home = tempdir().unwrap();
let app = AppRecord {
stable_id: "bat".to_owned(),
display_name: "Bat".to_owned(),
source_input: None,
source: None,
installed_version: None,
update_strategy: None,
metadata: Vec::new(),
install: Some(InstallMetadata {
scope: InstallScope::User,
payload_path: Some(
install_home
.path()
.join(".local/lib/aim/appimages/bat.AppImage")
.display()
.to_string(),
),
desktop_entry_path: None,
icon_path: None,
}),
};
let mut events: Vec<OperationEvent> = Vec::new();
let mut reporter = |event: &OperationEvent| events.push(event.clone());
let result =
remove_registered_app_with_reporter("bat", &[app], install_home.path(), &mut reporter)
.unwrap();
assert_eq!(result.removed.stable_id, "bat");
assert!(events.iter().any(|event| {
matches!(
event,
OperationEvent::StageChanged {
stage: OperationStage::ResolveQuery,
..
}
)
}));
assert!(events.iter().any(|event| {
matches!(
event,
OperationEvent::StageChanged {
stage: OperationStage::Finalize,
..
}
)
}));
}