Skip to content

Commit 3f3cf14

Browse files
author
Nitish [C] Dhok
committed
automated ctrl+s command and refactor ctrl+j command for multiline.
1 parent da624e7 commit 3f3cf14

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

e2etests/tests/core_session/test_help_command.rs

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#[allow(unused_imports)]
22
use q_cli_e2e_tests::q_chat_helper;
33

4+
fn clean_terminal_output(input: &str) -> String {
5+
input.replace("(B", "")
6+
}
7+
48
#[test]
59
#[cfg(all(feature = "help", feature = "sanity"))]
610
fn test_help_command() -> Result<(), Box<dyn std::error::Error>> {
@@ -57,8 +61,10 @@ fn test_multiline_command() -> Result<(), Box<dyn std::error::Error>> {
5761

5862
println!("✅ Q Chat session started");
5963

60-
let multiline_input = "what is aws explain in 100 words.\nwhat is AI explain in 100 words";
61-
let response = chat.send_prompt(multiline_input)?;
64+
// Ctrl+J produces ASCII Line Feed (0x0A)
65+
let ctrl_j = "\x0A";
66+
let multiline_input = format!("what is aws explain in 100 words.{}what is AI explain in 100 words", ctrl_j);
67+
let response = chat.execute_command(&multiline_input)?;
6268

6369
println!("📝 Response: {} bytes", response.len());
6470
println!("📝 FULL OUTPUT:");
@@ -102,6 +108,38 @@ fn test_whoami_command() -> Result<(), Box<dyn std::error::Error>> {
102108
println!("✅ All whoami command functionality verified!");
103109

104110
// Release the lock
111+
drop(chat);
112+
Ok(())
113+
}
114+
115+
#[test]
116+
#[cfg(all(feature = "help", feature = "sanity"))]
117+
fn test_ctrls_command() -> Result<(), Box<dyn std::error::Error>> {
118+
println!("\n🔍 Testing ctrl+s input... | Description: Tests <code>ctrl+s</code>command");
119+
120+
let session = q_chat_helper::get_chat_session();
121+
let mut chat = session.lock().unwrap_or_else(|poisoned| poisoned.into_inner());
122+
123+
println!("✅ Q Chat session started");
124+
125+
// Ctrl+J produces ASCII Line Feed (0x0A)
126+
let ctrl_j = "\x13";
127+
let response = chat.execute_command(ctrl_j)?;
128+
let cleaned_response = clean_terminal_output(&response);
129+
130+
println!("📝 Response: {} bytes", cleaned_response.len());
131+
println!("📝 FULL OUTPUT:");
132+
println!("{}", cleaned_response);
133+
println!("📝 END OUTPUT");
134+
assert!(cleaned_response.contains("agent"),"Response should contain /agent");
135+
assert!(cleaned_response.contains("editor"),"Response should contain /editor");
136+
assert!(cleaned_response.contains("clear"),"Response should contain /clear");
137+
assert!(cleaned_response.contains("experiment"),"Response should contain /experiment");
138+
assert!(cleaned_response.contains("context"),"Response should contain /context");
139+
140+
//pressing esc button to close ctrl+s window
141+
let esc = chat.execute_command("\x1B")?;
142+
105143
drop(chat);
106144
Ok(())
107145
}

0 commit comments

Comments
 (0)