[Test🧪] Cover the dangerous-command confirmation flow
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 82/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- rust
- Domain
- cli, testing-qa
Research direction
Start with the existing mod tests in rocketmq-tools/rocketmq-admin/rocketmq-admin-tui/src/rocketmq_tui_app.rs and its handle_key_event setup, then inspect handle_confirmation_key, apply_action, and prepare_execution. Add the listed confirmation-flow cases there, and test confirmation_prompt in src/state.rs. Done means every acceptance case is asserted, no production code changes are made, and cargo fmt -p rocketmq-admin-tui -- --check plus cargo test -p rocketmq-admin-tui pass.
Written by the indexing model from the issue text.
Description
Prerequisites
- I have searched existing test issues
Test Scope
Crate: rocketmq-admin-tui
Files: rocketmq-tools/rocketmq-admin/rocketmq-admin-tui/src/rocketmq_tui_app.rs
handle_confirmation_key at line 316, the Confirmation arm of apply_action at line 522,
prepare_execution at line 643
rocketmq-tools/rocketmq-admin/rocketmq-admin-tui/src/state.rs
confirmation_prompt at line 566
Coverage: no test ever enters CommandExecutionState::Confirming
The TUI refuses to run a command whose risk level requires confirmation until the
operator types an expected string back. That gate is the last thing standing
between a mistyped shortcut and a destructive admin call, and no test exercises
it.
// src/rocketmq_tui_app.rs lines 331-343
KeyCode::Enter => {
if let CommandExecutionState::Confirming {
execution_id,
command_id,
expected,
} = self.state.execution.clone()
{
if self.state.confirm_input.trim() == expected {
self.start_execution(execution_id, command_id);
} else {
self.state.last_error = Some(format!("confirmation must match '{expected}'"));
}
}
}
The whole path is untested: entering Confirming when a dangerous command is
executed, the exact-match rule including the trim, rejecting a mismatch, Esc
cancelling, and Backspace editing the typed text. Nothing in the repository's
tests mentions Action::ConfirmRequested, Action::HelpToggled,
Action::ResultCleared, Action::ArgChanged, Action::FocusNext, or
Action::FocusPrevious either.
The test harness already exists. src/rocketmq_tui_app.rs has a mod tests block
at line 831 that builds an app with RocketmqTuiApp::new(test_client_runtime())
and drives it through handle_key_event, so the new cases belong beside the
existing ones and need no new scaffolding.
Test Cases
Add cases to the existing mod tests in src/rocketmq_tui_app.rs. Follow the
style of the tests already there for constructing the app and sending keys.
Entering confirmation:
- Selecting a command whose risk level is
Dangerousand sendingCtrl+R
leavesstate.executioninCommandExecutionState::Confirming, and the
capturedexpectedstring is the one the command declares. - A command that does not require confirmation executes directly, so the new
test proves the gate is specific rather than blanket.
Matching:
- Typing the exact
expectedstring and pressingEnterstarts the
execution, provingconfirm_inputreaches the execution state. - Typing the expected string with surrounding whitespace and pressing
Enter
also starts it, pinning the.trim()in the comparison. - Typing a wrong string and pressing
Enterdoes not start execution,
leaves the state inConfirming, and setslast_errorto a message
containing the expected value. - After a mismatch, typing the correct string and pressing
Enterstill
works, proving the mismatch did not move the state machine.
Editing and cancelling:
-
Backspaceremoves the last character ofconfirm_input, including on an
already-empty input where it must not panic. -
EscemitsAction::CancelExecutionand leavesConfirming. - A character key appends to
confirm_inputrather than reaching the global
shortcut table.
confirmation_prompt in src/state.rs:
- A
Dangerouscommand produces wording that includes the worddangerous,
and a lower-risk mutating command does not. - A command with no confirmation requirement returns
None.
Willing to contribute?
- I can submit a PR for this
Acceptance Criteria
- Every case above is covered by an assertion in
src/rocketmq_tui_app.rsor, forconfirmation_prompt, insrc/state.rs. - No production code change. These tests pin the current gate.
-
cargo test -p rocketmq-admin-tuipasses.
Validation
Run from the repository root:
cargo fmt -p rocketmq-admin-tui -- --check
cargo test -p rocketmq-admin-tui
- Dominant language
- Rust
- Stars
- 1.5k
- Forks
- 264
- Avg merge
- 1h 34m
- Merged PRs (30d)
- 567
Contributor guide
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 mxsm/rocketmq-rust
-
Difficulty level/Easy good first issue help wanted rocketmq-tools crate rust testing🧪
Difficulty 2/5 1-3 hours Newbie friendliness 94/100
mxsm/rocketmq-rust#10783 ·
-
bug🐛 Difficulty level/Easy good first issue help wanted rocketmq-tools crate rust
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
mxsm/rocketmq-rust#10781 ·
-
Difficulty level/Easy enhancement✨ good first issue help wanted rocketmq-tui crate rust
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
mxsm/rocketmq-rust#10779 ·
-
Difficulty level/Easy documentation📝 good first issue help wanted rocketmq-tools crate rust
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
mxsm/rocketmq-rust#10774 ·
-
Difficulty level/Easy good first issue help wanted rocketmq-tools crate rust testing🧪
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
mxsm/rocketmq-rust#10773 ·
All issues in mxsm/rocketmq-rust
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
kwakseongjae/auto-hwp#319 ·
-
area:cli bug filter-quality good first issue priority:medium
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
bevyengine/bevy#25861 ·
-
comp-datalake
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ClickHouse/ClickHouse#121222 ·
-
enhancement remote
Difficulty 2/5 1-3 hours Newbie friendliness 68/100