tui2: add export-field actions and density/tree ui polish

This commit is contained in:
thePR0M3TH3AN committed 2026-03-02 11:04:20 -05:00
1 parent 93cf78b2c8
commit a67ee2d9da
5 files changed
+519 -7

No files matched your search

+12
View File
@@ -504,6 +504,8 @@ async def test_tui2_matrix_actions_palette_events_and_guards() -> None:
app._run_palette_command("page")
app._run_palette_command("page abc")
app._run_palette_command("page 0")
app._run_palette_command("density")
app._run_palette_command("density noisy")
app._run_palette_command("help-commands now")
app._run_palette_command("onboarding now")
app._run_palette_command("quickstart now")
@@ -577,6 +579,10 @@ async def test_tui2_matrix_actions_palette_events_and_guards() -> None:
app._run_palette_command("lock now")
app._run_palette_command("unlock")
app._run_palette_command("doc-export one two")
app._run_palette_command("copy")
app._run_palette_command("copy password nope")
app._run_palette_command("export-field")
app._run_palette_command("export-field private /tmp/matrix-key.bad nope")
app._run_palette_command("filter")
app._run_palette_command("archive-filter")
app._run_palette_command("archive-filter bogus")
@@ -592,6 +598,8 @@ async def test_tui2_matrix_actions_palette_events_and_guards() -> None:
app._run_palette_command("lock")
app._run_palette_command("unlock hunter2")
app._run_palette_command("search Doc")
app._run_palette_command("density comfortable")
app._run_palette_command("density compact")
app._run_palette_command("filter document")
app._run_palette_command("archive-filter all")
app._run_palette_command("archive-filter archived")
@@ -624,9 +632,13 @@ async def test_tui2_matrix_actions_palette_events_and_guards() -> None:
app._run_palette_command("2fa-refresh")
app._run_palette_command("2fa-hide")
app._run_palette_command("doc-export /tmp/seedpass-matrix-export")
app._run_palette_command("copy content")
app._run_palette_command("export-field content /tmp/seedpass-matrix-content.txt")
await pilot.pause()
app._run_palette_command("open 2")
app._run_palette_command("copy password confirm")
app._run_palette_command("export-field password /tmp/seedpass-matrix-password.txt confirm")
app.action_reveal_selected()
await pilot.pause()
assert "pw-2-" in str(app.query_one("#secret-detail").render())
@@ -643,6 +643,16 @@ async def test_tui2_textual_pagination_and_search_flow() -> None:
await pilot.pause()
assert "Page: 2/3" in _filters_text(app)
app.action_toggle_density()
await pilot.pause()
assert "Density: comfortable" in _status_text(app)
assert "Density: comfortable" in _filters_text(app)
app._run_palette_command("density compact")
await pilot.pause()
assert "Density set to compact" in _status_text(app)
assert "Density: compact" in _filters_text(app)
app.query_one("#search", Input).value = "Entry 44"
app._load_entries(query="Entry 44", reset_page=True)
await pilot.pause()
@@ -978,6 +988,99 @@ async def test_tui2_textual_sensitive_confirm_and_secret_mode_clipboard() -> Non
assert "Nostr #2 QR" in _widget_text(app, "#secret-detail")
@pytest.mark.anyio
async def test_tui2_textual_copy_command_for_core_and_advanced_fields(tmp_path) -> None:
service = FakeEntryService(
[
{
"id": 1,
"kind": "password",
"label": "Login 1",
"length": 16,
"username": "alice",
"url": "https://example.com",
},
{
"id": 2,
"kind": "ssh",
"label": "SSH 2",
"private_key": "SSH_PRIVATE_2",
"public_key": "ssh-ed25519 AAAA-2",
},
{"id": 3, "kind": "nostr", "label": "Nostr 3", "npub": "npub3", "nsec": "nsec3"},
{"id": 4, "kind": "key_value", "label": "KV 4", "key": "TOKEN", "value": "abc123"},
]
)
app = _build_app(service)
async with app.run_test() as pilot:
await pilot.pause()
app._run_palette_command("open 1")
app._run_palette_command("copy password")
await pilot.pause()
assert "copy password is sensitive" in _status_text(app)
app._run_palette_command("copy password confirm")
await pilot.pause()
assert "Copied password to clipboard" in _status_text(app)
assert service.clipboard_values[-1] == "pw-1-16"
app._run_palette_command("copy username")
await pilot.pause()
assert "Copied username to clipboard" in _status_text(app)
assert service.clipboard_values[-1] == "alice"
app._run_palette_command("open 2")
app._run_palette_command("copy private")
await pilot.pause()
assert "copy private_key is sensitive" in _status_text(app)
app._run_palette_command("copy private confirm")
await pilot.pause()
assert "Copied private_key to clipboard" in _status_text(app)
assert service.clipboard_values[-1] == "SSH_PRIVATE_2"
app._run_palette_command("open 3")
app._run_palette_command("copy npub")
await pilot.pause()
assert "Copied npub to clipboard" in _status_text(app)
assert service.clipboard_values[-1] == "npub3"
app._run_palette_command("copy nsec confirm")
await pilot.pause()
assert "Copied nsec to clipboard" in _status_text(app)
assert service.clipboard_values[-1] == "nsec3"
app._run_palette_command("open 4")
app._run_palette_command("copy value confirm")
await pilot.pause()
assert "Copied value to clipboard" in _status_text(app)
assert service.clipboard_values[-1] == "abc123"
app._run_palette_command("export-field value value.txt confirm")
await pilot.pause()
assert "Exported value to" in _status_text(app)
assert (Path.cwd() / "value.txt").exists()
assert (Path.cwd() / "value.txt").read_text(encoding="utf-8") == "abc123"
(Path.cwd() / "value.txt").unlink(missing_ok=True)
out_file = tmp_path / "nostr.nsec"
app._run_palette_command("open 3")
app._run_palette_command(f"export-field nsec {out_file}")
await pilot.pause()
assert "export-field nsec is sensitive" in _status_text(app)
app._run_palette_command(f"export-field nsec {out_file} confirm")
await pilot.pause()
assert "Exported nsec to" in _status_text(app)
assert out_file.read_text(encoding="utf-8") == "nsec3"
app._run_palette_command("open 4")
app._run_palette_command("copy bogus")
await pilot.pause()
assert "copy field unsupported for key_value" in _status_text(app)
@pytest.mark.anyio
async def test_tui2_textual_retry_after_search_failure() -> None:
service = FakeEntryService(
@@ -1792,6 +1895,30 @@ async def test_tui2_textual_profiles_and_settings_palette_validation() -> None:
await pilot.pause()
assert "Usage: unlock <password>" in _status_text(app)
app._run_palette_command("copy")
await pilot.pause()
assert "Usage: copy <field> (optional: confirm)" in _status_text(app)
app._run_palette_command("copy password nope")
await pilot.pause()
assert "Usage: copy <field> (optional: confirm)" in _status_text(app)
app._run_palette_command("export-field")
await pilot.pause()
assert "Usage: export-field <field> <path> (optional: confirm)" in _status_text(app)
app._run_palette_command("export-field password /tmp/x nope")
await pilot.pause()
assert "Usage: export-field <field> <path> (optional: confirm)" in _status_text(app)
app._run_palette_command("density")
await pilot.pause()
assert "Usage: density <compact|comfortable>" in _status_text(app)
app._run_palette_command("density noisy")
await pilot.pause()
assert "density must be one of: compact, comfortable" in _status_text(app)
@pytest.mark.anyio
async def test_tui2_textual_palette_session_status_lock_and_unlock() -> None: