Finish Home and Phone settings cohesion
This commit is contained in:
@@ -83,6 +83,21 @@ wait_for_file_content() {
|
||||
fail 'preferences file did not contain the complete atomic update'
|
||||
}
|
||||
|
||||
wait_for_reset_file_content() {
|
||||
local expected='{"initialized":false,"favorites":[]}'
|
||||
local state_file=""
|
||||
|
||||
for _ in $(seq 1 18); do
|
||||
state_file="$(find "$state_home" -name panama-home.json -print -quit)"
|
||||
if [[ -n "$state_file" ]] \
|
||||
&& jq -e --argjson expected "$expected" '. == $expected' "$state_file" >/dev/null; then
|
||||
return
|
||||
fi
|
||||
sleep 0.01
|
||||
done
|
||||
fail 'reset did not persist the default Home state before the debounce interval'
|
||||
}
|
||||
|
||||
# A leading JSON whitespace prevents qs from expanding the array into IPC
|
||||
# positional arguments; JSON.parse() intentionally accepts that whitespace.
|
||||
initial_ids=' ["light.kitchen","light.hall","light.desk"]'
|
||||
@@ -90,6 +105,7 @@ expected='{"initialized":true,"favorites":[{"id":"light.desk","alias":""},{"id":
|
||||
expected_file='{"initialized":true,"favorites":[{"id":"light.desk","alias":""},{"id":"light.kitchen","alias":"Island"}]}'
|
||||
empty_expected='{"initialized":true,"favorites":[],"saveError":""}'
|
||||
empty_file='{"initialized":true,"favorites":[]}'
|
||||
reset_expected='{"initialized":false,"favorites":[],"saveError":""}'
|
||||
|
||||
start_harness
|
||||
qs_for_harness ipc call home-pref-test initialize "$initial_ids" >/dev/null
|
||||
@@ -99,9 +115,20 @@ qs_for_harness ipc call home-pref-test remove light.hall >/dev/null
|
||||
wait_for_status "$expected"
|
||||
wait_for_file_content "$expected_file"
|
||||
|
||||
qs_for_harness ipc call home-pref-test reset >/dev/null
|
||||
wait_for_status "$reset_expected"
|
||||
wait_for_reset_file_content
|
||||
|
||||
stop_harness
|
||||
start_harness
|
||||
wait_for_status "$reset_expected"
|
||||
|
||||
qs_for_harness ipc call home-pref-test initialize "$initial_ids" >/dev/null
|
||||
qs_for_harness ipc call home-pref-test alias light.kitchen ' Island ' >/dev/null
|
||||
qs_for_harness ipc call home-pref-test move light.desk 0 >/dev/null
|
||||
qs_for_harness ipc call home-pref-test remove light.hall >/dev/null
|
||||
wait_for_status "$expected"
|
||||
wait_for_file_content "$expected_file"
|
||||
|
||||
qs_for_harness ipc call home-pref-test remove light.desk >/dev/null
|
||||
qs_for_harness ipc call home-pref-test remove light.kitchen >/dev/null
|
||||
|
||||
Reference in New Issue
Block a user