1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-17 14:23:54 +00:00

fix(uninstall): show full preview paths and add regression tests

This commit is contained in:
tw93
2026-02-11 14:22:22 +08:00
parent 649f638a53
commit 4c60fcca73
3 changed files with 79 additions and 19 deletions

View File

@@ -517,6 +517,24 @@ EOF
[[ "$output" == *"App saved states optimized"* ]]
}
@test "opt_cache_refresh continues on permission denied (silent exit)" {
local cache_dir="$HOME/Library/Caches/com.apple.QuickLook.thumbnailcache"
mkdir -p "$cache_dir"
touch "$cache_dir/test.db"
run env HOME="$HOME" PROJECT_ROOT="$PROJECT_ROOT" bash --noprofile --norc << 'EOF'
set -euo pipefail
source "$PROJECT_ROOT/lib/core/common.sh"
source "$PROJECT_ROOT/lib/optimize/tasks.sh"
qlmanage() { return 0; }
safe_remove() { return 1; }
opt_cache_refresh
EOF
[ "$status" -eq 0 ]
[[ "$output" == *"QuickLook thumbnails refreshed"* ]]
}
@test "opt_cache_refresh cleans Quick Look cache" {
mkdir -p "$HOME/Library/Caches/com.apple.QuickLook.thumbnailcache"
touch "$HOME/Library/Caches/com.apple.QuickLook.thumbnailcache/test.db"

View File

@@ -123,6 +123,63 @@ EOF
[ "$status" -eq 0 ]
}
@test "batch_uninstall_applications preview shows full related file list" {
mkdir -p "$HOME/Applications/TestApp.app"
mkdir -p "$HOME/Library/Application Support/TestApp"
mkdir -p "$HOME/Library/Caches/TestApp"
mkdir -p "$HOME/Library/Logs/TestApp"
touch "$HOME/Library/Logs/TestApp/log1.log"
touch "$HOME/Library/Logs/TestApp/log2.log"
touch "$HOME/Library/Logs/TestApp/log3.log"
touch "$HOME/Library/Logs/TestApp/log4.log"
touch "$HOME/Library/Logs/TestApp/log5.log"
touch "$HOME/Library/Logs/TestApp/log6.log"
run env HOME="$HOME" PROJECT_ROOT="$PROJECT_ROOT" bash --noprofile --norc << 'EOF'
set -euo pipefail
source "$PROJECT_ROOT/lib/core/common.sh"
source "$PROJECT_ROOT/lib/uninstall/batch.sh"
request_sudo_access() { return 0; }
start_inline_spinner() { :; }
stop_inline_spinner() { :; }
enter_alt_screen() { :; }
leave_alt_screen() { :; }
hide_cursor() { :; }
show_cursor() { :; }
remove_apps_from_dock() { :; }
pgrep() { return 1; }
pkill() { return 0; }
sudo() { return 0; }
has_sensitive_data() { return 1; }
find_app_system_files() { return 0; }
find_app_files() {
cat << LIST
$HOME/Library/Application Support/TestApp
$HOME/Library/Caches/TestApp
$HOME/Library/Logs/TestApp/log1.log
$HOME/Library/Logs/TestApp/log2.log
$HOME/Library/Logs/TestApp/log3.log
$HOME/Library/Logs/TestApp/log4.log
$HOME/Library/Logs/TestApp/log5.log
$HOME/Library/Logs/TestApp/log6.log
LIST
}
selected_apps=()
selected_apps+=("0|$HOME/Applications/TestApp.app|TestApp|com.example.TestApp|0|Never")
files_cleaned=0
total_items=0
total_size_cleaned=0
printf 'q' | batch_uninstall_applications
EOF
[ "$status" -eq 0 ]
[[ "$output" == *"~/Library/Logs/TestApp/log6.log"* ]]
[[ "$output" != *"more files"* ]]
}
@test "safe_remove can remove a simple directory" {
mkdir -p "$HOME/test_dir"
touch "$HOME/test_dir/file.txt"