feat(tui): Enter sends chat to the selected friend
Composer Enter only ran slash commands, so typed messages were dropped. Wire Node::send, keep /commands, reject unknown /foo as not-chat.
This commit is contained in:
parent
c141eb45b8
commit
c4ccca7e8c
4 changed files with 105 additions and 13 deletions
45
tests/send.rs
Normal file
45
tests/send.rs
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
//! Composer Enter must send chat to the selected friend, not only slash commands.
|
||||
|
||||
use onionwire::tui::{composer_enter, ComposerAction, SlashCmd, WipeKind};
|
||||
|
||||
#[test]
|
||||
fn enter_plain_text_is_send() {
|
||||
assert_eq!(
|
||||
composer_enter("hello wire"),
|
||||
Some(ComposerAction::Send("hello wire".into()))
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn enter_trims_but_sends() {
|
||||
assert_eq!(
|
||||
composer_enter(" hi there "),
|
||||
Some(ComposerAction::Send("hi there".into()))
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn enter_empty_does_nothing() {
|
||||
assert_eq!(composer_enter(""), None);
|
||||
assert_eq!(composer_enter(" "), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn enter_slash_cmds_are_not_chat() {
|
||||
assert_eq!(
|
||||
composer_enter("/wipe"),
|
||||
Some(ComposerAction::Cmd(SlashCmd::Wipe(WipeKind::Messages)))
|
||||
);
|
||||
assert_eq!(
|
||||
composer_enter("/who"),
|
||||
Some(ComposerAction::Cmd(SlashCmd::Who))
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn enter_unknown_slash_is_not_chat() {
|
||||
assert_eq!(
|
||||
composer_enter("/nope"),
|
||||
Some(ComposerAction::UnknownSlash("/nope".into()))
|
||||
);
|
||||
}
|
||||
|
|
@ -40,8 +40,8 @@ fn help_overlay_lists_core_bindings() {
|
|||
let help = help_overlay_text();
|
||||
assert!(!help.is_empty());
|
||||
for needle in [
|
||||
"Tab", "F2", "F3", "F4", "F5", "/profile", "/pay", "/tip", "/backup", "/restore", "Ctrl-Q",
|
||||
"?",
|
||||
"Tab", "F2", "F3", "F4", "F5", "send chat", "/profile", "/pay", "/tip", "/backup",
|
||||
"/restore", "Ctrl-Q", "?",
|
||||
] {
|
||||
assert!(help.contains(needle), "help overlay missing {needle:?}");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue