feat: add Continue and Cancel buttons to Certificate Details form

Tab (or Down/Enter on a field) now cycles through the three text fields
and then onto [ Continue ] and [ Cancel ] buttons at the bottom of the
form.  Enter or Space activates the focused button.  Ctrl-G still
confirms immediately from any position.  Escape still cancels.

The form window is trimmed from h=16 to h=13 since the buttons replace
the now-redundant empty space below the password field.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Vlad Doloman
2026-06-24 13:53:20 +03:00
parent 567c3e9759
commit 6ed7f9feef
2 changed files with 65 additions and 28 deletions

View File

@@ -78,16 +78,11 @@ def test_show_cert_form_cancel():
def test_show_cert_form_confirm():
"""Pressing Enter three times advances through all 3 fields and confirms.
The form has 3 active fields (cn, email, password). Enter on field 0
advances to field 1; Enter on field 1 advances to field 2; Enter on
field 2 (the last) confirms. We therefore need 3 Enter keypresses.
"""
"""Enter advances through the 3 fields to the Continue button; Enter on
Continue confirms. That's 4 Enter keypresses total."""
stdscr = _make_stdscr()
win = _make_win(rows=20, cols=70)
# Three Enter keypresses to advance through each field and confirm.
win.getch.side_effect = [10, 10, 10]
win.getch.side_effect = [10, 10, 10, 10]
with patch("curses.newwin", return_value=win):
result = show_cert_form(stdscr, cn="bob", email="bob@example.com")
assert isinstance(result, CertFormResult)
@@ -95,3 +90,15 @@ def test_show_cert_form_confirm():
assert result.cn == "bob"
assert result.email == "bob@example.com"
assert len(result.password) > 0
def test_show_cert_form_cancel_button():
"""Tab to the Cancel button (4 Tabs from start) and press Enter cancels."""
stdscr = _make_stdscr()
win = _make_win(rows=20, cols=70)
# Tab×4: cn→email→password→Continue→Cancel, then Enter
win.getch.side_effect = [9, 9, 9, 9, 10]
with patch("curses.newwin", return_value=win):
result = show_cert_form(stdscr, cn="alice", email="alice@example.com")
assert isinstance(result, CertFormResult)
assert result.confirmed is False