TUI tests: verify cancelling secret drafts leaves the vault unchanged
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 88/100
Research direction
Start with secret_modal_key_events in crates/cli/src/tui/events.rs and secret_modal_edit_lifecycle in crates/cli/src/tui/app.rs; reuse the nearby isolated store and MemoryKeychain fixtures. Drive create and edit cancellation through handle_key_event, then verify persisted values and version counts, plus the fields when reopening each dialogue. Run cargo test -p sotto-cli tui:: and cargo fmt --all --check; done means the cancellation cases preserve vault state and the save control still adds the expected version.
Written by the indexing model from the issue text.
Description
The problem
Cancelling a secret draft in the dashboard should discard it without writing to the vault. The existing keyboard test opens an edit dialogue and immediately presses Escape, then checks only that the dialogue closed. It never changes the draft before cancelling or checks the stored value and version history afterwards.
Add regression coverage for this existing behaviour. This is a test-coverage task, not a claim that cancellation currently saves a draft.
Evidence and starting points
Inspected a clean checkout of main at 24c48b0e876b89029fa7013101ffb44d46fa4dab:
secret_modal_key_eventsexercises creation and saving, but its cancellation check only assertsshow_secret_modal == falseafter opening an unchanged edit dialogue.close_secret_modalcloses the dialogue and clears its draft name and value. The Escape branch inhandle_key_eventcalls it.secret_modal_edit_lifecyclecovers a successful save, not cancellation. Nearby tests show how to assert both stored values andapp.secret_history(...)with an isolated store andMemoryKeychain.
Verified through source and test inspection on macOS. Rust tests and an interactive terminal session were not run for this issue. Existing open/closed issues and open PRs were checked for overlap.
Proposed approach
Extend the existing TUI tests using synthetic values and the current in-memory fixtures. Drive cancellation through handle_key_event so the tests protect the user's Escape action, not just the close helper in isolation. No network, system keychain or clipboard access is needed.
Acceptance criteria
- Cancel creation: open New through the keyboard handler, enter a valid unused name and non-empty value, then press Escape. The dialogue closes, the dashboard keeps running, and querying the underlying vault confirms that the draft was not created and the existing entries are unchanged.
- Cancel editing: seed an existing secret, open Edit through the keyboard handler, change its draft value, then press Escape. The original stored bytes and version-history count remain unchanged. Check persistence through the app/store, not only the cached dashboard list.
- Reopen after cancellation: reopening New starts with empty fields; reopening Edit loads the original stored value rather than the discarded draft. If the previous draft was unmasked, the reopened dialogue starts masked as it does today.
- Include a control showing that editing the value and pressing Enter still saves it and adds the expected version. Reuse or strengthen the existing save test rather than duplicating it unnecessarily.
- Keep this focused on cancellation and its regression tests. Do not add a confirmation prompt, change shortcut behaviour, alter secret-name rules or modify cryptography.
Run cargo test -p sotto-cli tui:: and cargo fmt --all --check. The cancellation assertions should detect an accidental save on Escape, including an extra version even if its value matches the original.
This is suitable for a first contribution because the fixtures and save-path tests already exist. Follow CONTRIBUTING.md and sign off commits with git commit -s.
- Dominant language
- Rust
- Stars
- 31
- Forks
- 42
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 142
Getting set up
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from getsotto/sotto
-
enhancement good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
enhancement good first issue help wanted
Difficulty 2/5 Half a day Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
good first issue help wanted test-coverage
Difficulty 2/5 3-5 days Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
documentation good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
enhancement good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
Similar issues
-
Panic on live viewport resize when unstyled elements exist in display: none subtreePossibly taken @GoCoder7 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
DioxusLabs/blitz#1488 ·
Maintainers usually reply within 1 day
-
🏷️ good first issue enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
S-Needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
vectordotdev/vrl#2042 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day