Files
Panama/tests/quickshell/settings-backup-live-contract.sh
T

48 lines
2.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# The helper proves the two stores round-trip in an isolated XDG tree. This
# source contract pins the live handoff without launching a second copy of the
# daily-driver shell or invoking Hyprland during tests.
set -euo pipefail
repo_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
service="$repo_dir/config/dot/quickshell/services/SettingsBackup.qml"
fail() {
printf 'settings backup live contract: %s\n' "$1" >&2
exit 1
}
rg -q 'DesktopPreferences\.reload\(\)' "$service" \
|| fail 'restore does not reload DesktopPreferences'
rg -q 'HomePreferences\.resetHomeDefaults\(\)' "$service" \
|| fail 'restore does not clear current Home state before reloading it'
rg -q 'HomePreferences\.initialize\(' "$service" \
|| fail 'restore does not reload restored Home favourites through the public API'
rg -q 'HomePreferences\.setAlias\(' "$service" \
|| fail 'restore does not reload restored Home aliases through the public API'
if rg -q 'HomePreferences\.(favorites|initialized)\s*=' "$service"; then
fail 'restore bypasses the durable HomePreferences API with direct alias mutation'
fi
rg -q 'SystemSettings\.applyPersistedDisplayPolicy\(\)' "$service" \
|| fail 'restore does not reapply compositor-backed preferences'
rg -q 'Keybinds\.applyReload\(\)' "$service" \
|| fail 'restore does not regenerate and reload rebound shortcuts'
rg -q 'Wallpaper\.set\(' "$service" \
|| fail 'restore does not reapply the restored wallpaper'
rg -q 'Quickshell\.reload\(false\)' "$service" \
|| fail 'restore does not soft-reload HomePreferences and reactive theme state'
rg -q 'actionRun\.exec\(\[root\.helperPath, "save", root\.serialiseHomeState\(\)\]\)' "$service" \
|| fail 'save does not hand the live HomePreferences state to the canonical backup store'
# User-controlled snapshot names must remain argv values. Restoring through a
# shell command would make validation in the helper the only line of defence.
rg -q 'actionRun\.exec\(\[root\.helperPath, "restore", name\]\)' "$service" \
|| fail 'restore is not executed through an argument array'
if rg -q 'bash.*-c|sh.*-c' "$service"; then
fail 'the restore service constructs a shell command'
fi
printf 'settings backup live contract: PASS\n'