Skip to content

Commit a3d2f9f

Browse files
author
Nitish [C] Dhok
committed
kiro-cli e2e tests: Automated kiro-cli issue --help,--force -f -h subcommands.
1 parent 0e43e01 commit a3d2f9f

File tree

4 files changed

+185
-0
lines changed

4 files changed

+185
-0
lines changed

e2etests/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,4 @@ setup_subcommands = [] # KIRO-CLI setup subcommand
5454
diagnostics = [] # KIRO-CLI diagnostics subcommand
5555
init_subcommand = [] # KIRO-CLI init subcommand
5656
theme_subcommand = [] # KIRO-CLI thenme subcomnmand
57+
issue_subcommand = [] # KIRO-CLI issue subcommand

e2etests/tests/all_tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ mod setup_subcommands;
1818
mod diagnostics;
1919
mod init_subcommand;
2020
mod theme_subcommand;
21+
mod issue_subcommand;
2122

2223
use q_cli_e2e_tests::q_chat_helper;
2324

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub mod test_kiro_cli_issue_subcommand;
Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
#[allow(unused_imports)]
2+
use q_cli_e2e_tests::q_chat_helper;
3+
4+
#[test]
5+
#[cfg(all(feature = "issue_subcommand", feature = "sanity"))]
6+
fn test_kiro_cli_issue_help_subcommand() -> Result<(), Box<dyn std::error::Error>> {
7+
println!("\n🔍 Testing kiro-cli issue --help ... | Description: Tests the <code> kiro-cli issue --help </code> subcommand to verify help options.");
8+
9+
println!("\n🔍 Executing 'kiro-cli issue --help' subcommand...");
10+
let response = q_chat_helper::execute_q_subcommand("kiro-cli", &["issue", "--help"])?;
11+
12+
println!("📝 FULL OUTPUT:");
13+
println!("{}", response);
14+
println!("📝 END OUTPUT");
15+
16+
assert!(response.contains("Usage:"), "Expected 'Usage:' in the output");
17+
assert!(response.contains("Options:"), "Expected 'Options:' in the output");
18+
assert!(response.contains("-h"), "Expected '-h' in the output");
19+
assert!(response.contains("--help"), "Expected '--help' in the output");
20+
21+
println!("✅ Kiro Cli issue --help subcommand executed successfully!");
22+
23+
Ok(())
24+
}
25+
26+
#[test]
27+
#[cfg(all(feature = "issue_subcommand", feature = "sanity"))]
28+
fn test_kiro_cli_issue_h_subcommand() -> Result<(), Box<dyn std::error::Error>> {
29+
println!("\n🔍 Testing kiro-cli issue -h ... | Description: Tests the <code> kiro-cli issue -h </code> subcommand to verify help options.");
30+
31+
println!("\n🔍 Executing 'kiro-cli issue -h' subcommand...");
32+
let response = q_chat_helper::execute_q_subcommand("kiro-cli", &["issue", "-h"])?;
33+
34+
println!("📝 FULL OUTPUT:");
35+
println!("{}", response);
36+
println!("📝 END OUTPUT");
37+
38+
assert!(response.contains("Usage:"), "Expected 'Usage:' in the output");
39+
assert!(response.contains("Options:"), "Expected 'Options:' in the output");
40+
assert!(response.contains("-h"), "Expected '-h' in the output");
41+
assert!(response.contains("--help"), "Expected '--help' in the output");
42+
43+
println!("✅ Kiro Cli issue -h subcommand executed successfully!");
44+
45+
Ok(())
46+
}
47+
48+
#[test]
49+
#[cfg(all(feature = "issue_subcommand", feature = "sanity"))]
50+
fn test_kiro_cli_issue_force_subcommand() -> Result<(), Box<dyn std::error::Error>> {
51+
println!("\n🔍 Testing kiro-cli issue --force ... | Description: Tests the <code> kiro-cli issue --force </code> subcommand to verify interactive issue creation.");
52+
53+
println!("\n🔍 Executing 'kiro-cli issue --force' subcommand...");
54+
55+
let session = q_chat_helper::get_chat_session();
56+
let mut chat = session.lock().unwrap_or_else(|poisoned| poisoned.into_inner());
57+
58+
// Execute the command with longer timeout
59+
let response = chat.execute_command_with_timeout("!kiro-cli issue --force", Some(1000))?;
60+
61+
println!("📝 INITIAL OUTPUT:");
62+
println!("{}", response);
63+
64+
// Check if we got the interactive prompt
65+
if response.contains("Issue Title") {
66+
println!("🔍 Detected interactive prompt, sending test title...");
67+
68+
// Send the issue title
69+
let title_response = chat.send_key_input("Test issue from automated test")?;
70+
71+
println!("📝 TITLE INPUT RESPONSE:");
72+
println!("{}", title_response);
73+
74+
// Send Enter to confirm the input and wait longer for GitHub processing
75+
let enter_response = chat.send_key_input_with_timeout("\r", Some(1000))?;
76+
77+
println!("📝 ENTER RESPONSE:");
78+
println!("{}", enter_response);
79+
80+
// Wait additional time for GitHub redirect and read any remaining output
81+
std::thread::sleep(std::time::Duration::from_secs(3));
82+
let final_response = chat.send_key_input_with_timeout("", Some(1000))?;
83+
84+
println!("📝 FINAL OUTPUT:");
85+
println!("{}", final_response);
86+
87+
// Combine all outputs
88+
let combined_output = format!("{}{}{}{}", response, title_response, enter_response, final_response);
89+
90+
// Basic success criteria
91+
assert!(!combined_output.contains("Error"), "Should not contain error messages");
92+
assert!(combined_output.contains("Test issue from automated test"), "Should contain our input text");
93+
94+
// Check for GitHub redirect message
95+
if combined_output.contains("Heading over to GitHub") {
96+
println!("✅ Issue creation process completed with GitHub redirect!");
97+
} else if combined_output.contains("GitHub") ||
98+
combined_output.contains("Issue created") ||
99+
combined_output.contains("✔") {
100+
println!("✅ Issue creation process completed successfully!");
101+
} else {
102+
println!("ℹ️ Issue creation process completed (interactive input successful)");
103+
println!("🔍 Debug: Looking for 'Heading over to GitHub' in output...");
104+
}
105+
} else {
106+
// If no interactive prompt, check for other expected behaviors
107+
assert!(!response.contains("Error"), "Should not contain error messages");
108+
println!("ℹ️ Command executed without interactive prompt");
109+
}
110+
111+
println!("✅ Kiro Cli issue --force subcommand executed successfully!");
112+
113+
Ok(())
114+
}
115+
116+
#[test]
117+
#[cfg(all(feature = "issue_subcommand", feature = "sanity"))]
118+
fn test_kiro_cli_issue_f_subcommand() -> Result<(), Box<dyn std::error::Error>> {
119+
println!("\n🔍 Testing kiro-cli issue -f ... | Description: Tests the <code> kiro-cli issue -f </code> subcommand to verify interactive issue creation. using -f ");
120+
121+
println!("\n🔍 Executing 'kiro-cli issue -f' subcommand...");
122+
123+
let session = q_chat_helper::get_chat_session();
124+
let mut chat = session.lock().unwrap_or_else(|poisoned| poisoned.into_inner());
125+
126+
// Execute the command with longer timeout
127+
let response = chat.execute_command_with_timeout("!kiro-cli issue -f", Some(1000))?;
128+
129+
println!("📝 INITIAL OUTPUT:");
130+
println!("{}", response);
131+
132+
// Check if we got the interactive prompt
133+
if response.contains("Issue Title") {
134+
println!("🔍 Detected interactive prompt, sending test title...");
135+
136+
// Send the issue title
137+
let title_response = chat.send_key_input("Test issue from automated test")?;
138+
139+
println!("📝 TITLE INPUT RESPONSE:");
140+
println!("{}", title_response);
141+
142+
// Send Enter to confirm the input and wait longer for GitHub processing
143+
let enter_response = chat.send_key_input_with_timeout("\r", Some(1000))?;
144+
145+
println!("📝 ENTER RESPONSE:");
146+
println!("{}", enter_response);
147+
148+
// Wait additional time for GitHub redirect and read any remaining output
149+
std::thread::sleep(std::time::Duration::from_secs(3));
150+
let final_response = chat.send_key_input_with_timeout("", Some(1000))?;
151+
152+
println!("📝 FINAL OUTPUT:");
153+
println!("{}", final_response);
154+
155+
// Combine all outputs
156+
let combined_output = format!("{}{}{}{}", response, title_response, enter_response, final_response);
157+
158+
// Basic success criteria
159+
assert!(!combined_output.contains("Error"), "Should not contain error messages");
160+
assert!(combined_output.contains("Test issue from automated test"), "Should contain our input text");
161+
162+
// Check for GitHub redirect message
163+
if combined_output.contains("Heading over to GitHub") {
164+
println!("✅ Issue creation process completed with GitHub redirect!");
165+
} else if combined_output.contains("GitHub") ||
166+
combined_output.contains("Issue created") ||
167+
combined_output.contains("✔") {
168+
println!("✅ Issue creation process completed successfully!");
169+
} else {
170+
println!("ℹ️ Issue creation process completed (interactive input successful)");
171+
println!("🔍 Debug: Looking for 'Heading over to GitHub' in output...");
172+
}
173+
} else {
174+
// If no interactive prompt, check for other expected behaviors
175+
assert!(!response.contains("Error"), "Should not contain error messages");
176+
println!("ℹ️ Command executed without interactive prompt");
177+
}
178+
179+
println!("✅ Kiro Cli issue -f subcommand executed successfully!");
180+
181+
Ok(())
182+
}

0 commit comments

Comments
 (0)