aboutsummaryrefslogtreecommitdiff
path: root/pocketbook/tests/test_app_toggle.py
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-26 14:05:40 -0500
committerCraig Jennings <c@cjennings.net>2026-05-26 14:05:40 -0500
commit70e89e946cbdff307284d11a46558161f713607c (patch)
treec305ce9249fac0aef1318f5caabae0df31be7e95 /pocketbook/tests/test_app_toggle.py
parent92f4a9394ae1b662d037a3016e94058a3881bdb8 (diff)
downloadarchsetup-70e89e946cbdff307284d11a46558161f713607c.tar.gz
archsetup-70e89e946cbdff307284d11a46558161f713607c.zip
refactor: fold pocketbook in-tree and drop its install steps
Pocketbook is nowhere near ready, so I pulled it back from publication: deleted the github mirror and the cjennings.net repo, removed the server mirror hook, and copied the package into pocketbook/ here until it's ready to spin back out. Dropped the steps that provisioned it on a fresh install: the gtk4-layer-shell dep and the pip install in archsetup, and the clone in post-install.sh. That clone pointed at the now-deleted github repo, so it would have failed a fresh run regardless. Re-wiring the install is tracked in the pocketbook backlog.
Diffstat (limited to 'pocketbook/tests/test_app_toggle.py')
-rw-r--r--pocketbook/tests/test_app_toggle.py96
1 files changed, 96 insertions, 0 deletions
diff --git a/pocketbook/tests/test_app_toggle.py b/pocketbook/tests/test_app_toggle.py
new file mode 100644
index 0000000..cb5ab89
--- /dev/null
+++ b/pocketbook/tests/test_app_toggle.py
@@ -0,0 +1,96 @@
+from pocketbook.app import ToggleStateMachine, EscapeStateMachine, navigate
+
+
+class TestToggleStateMachine:
+ def test_initial_state_visible(self):
+ sm = ToggleStateMachine(start_hidden=False)
+ assert sm.visible is True
+
+ def test_initial_state_hidden(self):
+ sm = ToggleStateMachine(start_hidden=True)
+ assert sm.visible is False
+
+ def test_toggle_alternates(self):
+ sm = ToggleStateMachine(start_hidden=False)
+ assert sm.visible is True
+ sm.toggle()
+ assert sm.visible is False
+ sm.toggle()
+ assert sm.visible is True
+
+ def test_toggle_from_hidden(self):
+ sm = ToggleStateMachine(start_hidden=True)
+ assert sm.visible is False
+ sm.toggle()
+ assert sm.visible is True
+ sm.toggle()
+ assert sm.visible is False
+
+
+class TestEscapeStateMachine:
+ def test_escape_while_editing_returns_exit_edit(self):
+ esc = EscapeStateMachine()
+ toggle = ToggleStateMachine(start_hidden=False)
+ action = esc.escape(is_editing=True, toggle=toggle)
+ assert action == "exit_edit"
+ # Toggle state should not change
+ assert toggle.visible is True
+
+ def test_escape_while_browsing_returns_hide(self):
+ esc = EscapeStateMachine()
+ toggle = ToggleStateMachine(start_hidden=False)
+ action = esc.escape(is_editing=False, toggle=toggle)
+ assert action == "hide"
+ assert toggle.visible is False
+
+ def test_escape_edit_then_browse_hides(self):
+ """Simulates: editing → Escape (exit edit) → Escape (hide)."""
+ esc = EscapeStateMachine()
+ toggle = ToggleStateMachine(start_hidden=False)
+
+ # First escape: exit edit mode
+ action1 = esc.escape(is_editing=True, toggle=toggle)
+ assert action1 == "exit_edit"
+ assert toggle.visible is True
+
+ # Second escape: now in browse mode, hide panel
+ action2 = esc.escape(is_editing=False, toggle=toggle)
+ assert action2 == "hide"
+ assert toggle.visible is False
+
+ def test_escape_hide_does_not_change_when_already_hidden(self):
+ esc = EscapeStateMachine()
+ toggle = ToggleStateMachine(start_hidden=True)
+ assert toggle.visible is False
+ action = esc.escape(is_editing=False, toggle=toggle)
+ assert action == "hide"
+ # Toggled again — now visible (edge case if called when hidden)
+ assert toggle.visible is True
+
+
+class TestNavigate:
+ def test_no_notes(self):
+ assert navigate(None, 0, 1) is None
+ assert navigate(None, 0, -1) is None
+
+ def test_no_focus_next_goes_to_first(self):
+ assert navigate(None, 3, 1) == 0
+
+ def test_no_focus_prev_goes_to_last(self):
+ assert navigate(None, 3, -1) == 2
+
+ def test_next_from_middle(self):
+ assert navigate(1, 3, 1) == 2
+
+ def test_prev_from_middle(self):
+ assert navigate(1, 3, -1) == 0
+
+ def test_next_clamps_at_end(self):
+ assert navigate(2, 3, 1) == 2
+
+ def test_prev_clamps_at_start(self):
+ assert navigate(0, 3, -1) == 0
+
+ def test_single_note(self):
+ assert navigate(0, 1, 1) == 0
+ assert navigate(0, 1, -1) == 0