feat: double Esc to exit main menu; fix Cryptgeon test for new payload schema
- First Esc in main screen shows "Press Esc again to quit" in footer; second Esc exits. Any other key resets the pending state. - Update test_posts_to_correct_endpoint to expect contents as base64 string and presence of meta field, matching the updated Cryptgeon API payload. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -745,6 +745,7 @@ def show_main_screen(
|
|||||||
n_items = n_certs + len(_MENU_ITEMS)
|
n_items = n_certs + len(_MENU_ITEMS)
|
||||||
checked: set[str] = set(initial_checked) if initial_checked else set()
|
checked: set[str] = set(initial_checked) if initial_checked else set()
|
||||||
cursor = clamp(initial_cursor, 0, max(0, n_items - 1))
|
cursor = clamp(initial_cursor, 0, max(0, n_items - 1))
|
||||||
|
esc_pending = False
|
||||||
|
|
||||||
def is_cert(idx): return idx < n_certs
|
def is_cert(idx): return idx < n_certs
|
||||||
def menu_item(idx): return _MENU_ITEMS[idx - n_certs] if idx >= n_certs else None
|
def menu_item(idx): return _MENU_ITEMS[idx - n_certs] if idx >= n_certs else None
|
||||||
@@ -763,7 +764,10 @@ def show_main_screen(
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
# Footer hint
|
# Footer hint
|
||||||
hint = " ↑↓:Navigate Space:Check Enter:Confirm R:Revoke A:Toggle view Q:Quit"
|
if esc_pending:
|
||||||
|
hint = " Press Esc again to quit"
|
||||||
|
else:
|
||||||
|
hint = " ↑↓:Navigate Space:Check Enter:Confirm R:Revoke A:Toggle view Q:Quit"
|
||||||
try:
|
try:
|
||||||
stdscr.addstr(sh - 1, 0, hint[:sw], curses.color_pair(COLOR_DISABLED))
|
stdscr.addstr(sh - 1, 0, hint[:sw], curses.color_pair(COLOR_DISABLED))
|
||||||
except curses.error:
|
except curses.error:
|
||||||
@@ -810,6 +814,14 @@ def show_main_screen(
|
|||||||
draw()
|
draw()
|
||||||
key = stdscr.getch()
|
key = stdscr.getch()
|
||||||
|
|
||||||
|
if key == 27: # Esc
|
||||||
|
if esc_pending:
|
||||||
|
return ScreenResult(action=Action.EXIT)
|
||||||
|
esc_pending = True
|
||||||
|
continue
|
||||||
|
|
||||||
|
esc_pending = False
|
||||||
|
|
||||||
if key in (ord("q"), ord("Q")):
|
if key in (ord("q"), ord("Q")):
|
||||||
return ScreenResult(action=Action.EXIT)
|
return ScreenResult(action=Action.EXIT)
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,8 @@ def test_posts_to_correct_endpoint(mock_open):
|
|||||||
req = mock_open.call_args[0][0]
|
req = mock_open.call_args[0][0]
|
||||||
assert req.full_url == "https://cg.example.com/api/notes/"
|
assert req.full_url == "https://cg.example.com/api/notes/"
|
||||||
body = json.loads(req.data)
|
body = json.loads(req.data)
|
||||||
assert isinstance(body["contents"], list)
|
assert isinstance(body["contents"], str)
|
||||||
|
assert body["meta"] == ""
|
||||||
assert body["views"] == 1
|
assert body["views"] == 1
|
||||||
assert body["type"] == "text"
|
assert body["type"] == "text"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user